Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add chat screen to talawa-user-portal #986

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
881788c
Create login and register page for user portal
beingnoble03 Jun 3, 2023
5becb88
Lint public locales
beingnoble03 Jun 3, 2023
52a7c51
fix merge conflicts
beingnoble03 Jun 6, 2023
f923cef
Create tests for login page components
beingnoble03 Jun 11, 2023
e0a73a0
Add react import in tests
beingnoble03 Jun 11, 2023
8bef0fe
Create organizations screen for user portal
beingnoble03 Jun 22, 2023
5c9f41c
Fix failing tests and lint code
beingnoble03 Jun 22, 2023
93511fd
fix failing tests
beingnoble03 Jun 22, 2023
7e34d61
Add tests for organization screen and componenets
beingnoble03 Jun 27, 2023
d334920
Fix non-null assertions
beingnoble03 Jun 27, 2023
08f6de7
Fix non-null assertions in organizations test
beingnoble03 Jun 27, 2023
e6c14df
Merge branch 'develop' into talawa-user-portal
beingnoble03 Jun 29, 2023
ce5cbda
Fix bootstrap migration changes
beingnoble03 Jun 29, 2023
31bb350
Add Home Screen along with other components
beingnoble03 Jul 5, 2023
9833fbf
fix merge conflicts
beingnoble03 Jul 5, 2023
c4250c3
Fix failing tests
beingnoble03 Jul 5, 2023
1cb3ee4
Add required tests and Offcanvas navbar
beingnoble03 Jul 7, 2023
38ebe74
Remove unused variables from tests
beingnoble03 Jul 7, 2023
49b05dc
Sync the Mutations with talawa-api
beingnoble03 Jul 16, 2023
2512d70
Merge develop into talawa-user-portal
beingnoble03 Aug 2, 2023
24e139d
Add Settings and Donate Screen
beingnoble03 Aug 8, 2023
4bc6f00
Add multilingual support for the screens
beingnoble03 Aug 8, 2023
82e4323
Merge branch 'develop' into talawa-user-portal
beingnoble03 Aug 16, 2023
b8d4f1c
Add events screen without calendar view
beingnoble03 Aug 25, 2023
a619df2
Add multilingual support to Events screen
beingnoble03 Aug 25, 2023
a562699
Merge branch 'develop' into talawa-user-portal
beingnoble03 Aug 25, 2023
997de71
Fix failing tests due to merge
beingnoble03 Aug 26, 2023
02819f1
Add Post Comment functionality
beingnoble03 Sep 1, 2023
ae076f8
Refactor Events tests
beingnoble03 Sep 1, 2023
f1fa30b
Merge branch 'develop' into talawa-user-portal
beingnoble03 Sep 1, 2023
0deca89
Merge branch 'develop' into talawa-user-portal
beingnoble03 Sep 18, 2023
ed12705
Deprecate event registrants from query
beingnoble03 Sep 18, 2023
5722239
Add my tasks screen for user portal
beingnoble03 Oct 2, 2023
da2f5e9
Merge develop into talawa-user-portal
beingnoble03 Oct 2, 2023
f6e3562
Remove unnecessary comments from test files
beingnoble03 Oct 2, 2023
326e631
Add chat screen along with components
beingnoble03 Oct 9, 2023
d6405d3
Fix merge conflicts
beingnoble03 Oct 9, 2023
46c6e45
Add mui/system package for x-chart support
beingnoble03 Oct 9, 2023
062d3f9
Add chat screen tests and fix other bugs
beingnoble03 Oct 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.8.3",
"@mui/material": "^5.14.1",
"@mui/private-theming": "^5.14.13",
"@mui/system": "^5.14.12",
"@mui/x-charts": "^6.0.0-alpha.13",
"@mui/x-data-grid": "^6.8.0",
"@mui/x-date-pickers": "^6.6.0",
Expand Down
9 changes: 9 additions & 0 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -611,5 +611,14 @@
"taskNotCompleted": "The task has not been completed yet",
"event": "Event",
"organization": "Organization"
},
"userChat": {
"chat": "Chat",
"search": "Search",
"contacts": "Contacts"
},
"userChatRoom": {
"selectContact": "Select a contact to start conversation",
"sendMessage": "Send Message"
}
}
9 changes: 9 additions & 0 deletions public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -604,5 +604,14 @@
"taskNotCompleted": "La tâche n'est pas encore terminée",
"event": "Événement",
"organization": "Organisation"
},
"userChat": {
"chat": "Chat",
"search": "Recherche",
"contacts": "Contacts"
},
"userChatRoom": {
"selectContact": "Sélectionnez un contact pour démarrer la conversation",
"sendMessage": "Envoyer le message"
}
}
9 changes: 9 additions & 0 deletions public/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -605,5 +605,14 @@
"taskNotCompleted": "कार्य अभी तक पूरा नहीं हुआ है",
"event": "आयोजन",
"organization": "संगठन"
},
"userChat": {
"chat": "बात",
"search": "खोज",
"contacts": "संपर्क"
},
"userChatRoom": {
"selectContact": "बातचीत शुरू करने के लिए एक संपर्क चुनें",
"sendMessage": "मेसेज भेजें"
}
}
9 changes: 9 additions & 0 deletions public/locales/sp.json
Original file line number Diff line number Diff line change
Expand Up @@ -605,5 +605,14 @@
"taskNotCompleted": "La tarea aún no se ha completado",
"event": "Evento",
"organization": "Organización"
},
"userChat": {
"chat": "Charlar",
"search": "Buscar",
"contacts": "Contactos"
},
"userChatRoom": {
"selectContact": "Seleccione un contacto para iniciar una conversación",
"sendMessage": "Enviar mensaje"
}
}
9 changes: 9 additions & 0 deletions public/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -605,5 +605,14 @@
"taskNotCompleted": "任務還沒完成",
"event": "事件",
"organization": "組織"
},
"userChat": {
"chat": "聊天",
"search": "搜尋",
"contacts": "聯絡方式"
},
"userChatRoom": {
"selectContact": "選擇聯絡人開始對話",
"sendMessage": "傳訊息"
}
}
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import Settings from 'screens/UserPortal/Settings/Settings';
import Donate from 'screens/UserPortal/Donate/Donate';
import Events from 'screens/UserPortal/Events/Events';
import Tasks from 'screens/UserPortal/Tasks/Tasks';
import Chat from 'screens/UserPortal/Chat/Chat';

function app(): JSX.Element {
/*const { updatePluginLinks, updateInstalled } = bindActionCreators(
Expand Down Expand Up @@ -127,6 +128,7 @@ function app(): JSX.Element {
<SecuredRouteForUser path="/user/donate" component={Donate} />
<SecuredRouteForUser path="/user/events" component={Events} />
<SecuredRouteForUser path="/user/tasks" component={Tasks} />
<SecuredRouteForUser path="/user/chat" component={Chat} />

<Route exact path="*" component={PageNotFound} />
</Switch>
Expand Down
11 changes: 11 additions & 0 deletions src/GraphQl/Mutations/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,17 @@ export const UNLIKE_COMMENT = gql`
}
}
`;

export const CREATE_DIRECT_CHAT = gql`
mutation createDirectChat($userIds: [ID!]!, $organizationId: ID!) {
createDirectChat(
data: { userIds: $userIds, organizationId: $organizationId }
) {
_id
}
}
`;

//Plugin WebSocket listner
export const PLUGIN_SUBSCRIPTION = gql`
subscription onPluginUpdate {
Expand Down
42 changes: 42 additions & 0 deletions src/GraphQl/Queries/Queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,3 +714,45 @@ export const USER_TASKS_LIST = gql`
}
}
`;

export const DIRECT_CHATS_LIST = gql`
query DirectChatsByUserID($id: ID!) {
directChatsByUserID(id: $id) {
_id
creator {
_id
firstName
lastName
email
}
messages {
_id
createdAt
messageContent
receiver {
_id
firstName
lastName
email
}
sender {
_id
firstName
lastName
email
}
}
organization {
_id
name
}
users {
_id
firstName
lastName
email
image
}
}
}
`;
13 changes: 13 additions & 0 deletions src/components/UserPortal/ChatRoom/ChatRoom.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.chatAreaContainer {
padding: 10px;
flex-grow: 1;
background-color: rgba(196, 255, 211, 0.3);
}

.backgroundWhite {
background-color: white;
}

.grey {
color: grey;
}
81 changes: 81 additions & 0 deletions src/components/UserPortal/ChatRoom/ChatRoom.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import React from 'react';
import type { ChangeEvent } from 'react';
import { Paper } from '@mui/material';
import SendIcon from '@mui/icons-material/Send';
import { Button, Form, InputGroup } from 'react-bootstrap';
import styles from './ChatRoom.module.css';
import PermContactCalendarIcon from '@mui/icons-material/PermContactCalendar';
import { useTranslation } from 'react-i18next';

interface InterfaceChatRoomProps {
selectedContact: string;
}

export default function chatRoom(props: InterfaceChatRoomProps): JSX.Element {
const { t } = useTranslation('translation', {
keyPrefix: 'userChatRoom',
});

const [newMessage, setNewMessage] = React.useState('');

const handleNewMessageChange = (e: ChangeEvent<HTMLInputElement>): void => {
const newMessageValue = e.target.value;

Check warning on line 22 in src/components/UserPortal/ChatRoom/ChatRoom.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/UserPortal/ChatRoom/ChatRoom.tsx#L22

Added line #L22 was not covered by tests

setNewMessage(newMessageValue);

Check warning on line 24 in src/components/UserPortal/ChatRoom/ChatRoom.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/UserPortal/ChatRoom/ChatRoom.tsx#L24

Added line #L24 was not covered by tests
};

return (
<div className={`d-flex flex-column ${styles.chatAreaContainer}`}>
{!props.selectedContact ? (
<div
className={`d-flex flex-column justify-content-center align-items-center w-100 h-75 gap-2 ${styles.grey}`}
>
<PermContactCalendarIcon fontSize="medium" className={styles.grey} />
<h6>{t('selectContact')}</h6>
</div>
) : (
<>
<div className={`d-flex flex-grow-1 flex-column`}>
<Paper
variant="outlined"
sx={{
p: 2,
backgroundColor: 'white',
borderRadius: '20px 20px 5px 20px',
marginBottom: `10px`,
}}
>
My message
</Paper>
<Paper
variant="outlined"
sx={{
p: 2,
backgroundColor: '#31bb6b',
borderRadius: '20px 20px 20px 5px',
color: 'white',
marginBottom: `10px`,
}}
>
Other message
</Paper>
</div>
<div>
<InputGroup>
<Form.Control
placeholder={t('sendMessage')}
aria-label="Send Message"
value={newMessage}
onChange={handleNewMessageChange}
className={styles.backgroundWhite}
/>
<Button variant="primary" id="button-addon2">
<SendIcon fontSize="small" />
</Button>
</InputGroup>
</div>
</>
)}
</div>
);
}
33 changes: 33 additions & 0 deletions src/components/UserPortal/ContactCard/ContactCard.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.contact {
display: flex;
flex-direction: row;
padding: 10px 10px;
cursor: pointer;
border-radius: 10px;
margin-bottom: 10px;
border: 2px solid #f5f5f5;
}

.contactImage {
width: 50px;
height: auto;
border-radius: 10px;
}

.contactNameContainer {
display: flex;
flex-direction: column;
padding: 0px 10px;
}

.grey {
color: grey;
}

.bgGrey {
background-color: #f5f5f5;
}

.bgWhite {
background-color: white;
}
Loading
Loading