Skip to content

Commit

Permalink
Add chat screen to talawa-user-portal (#986)
Browse files Browse the repository at this point in the history
* Create login and register page for user portal

* Lint public locales

* Create tests for login page components

* Add react import in tests

* Create organizations screen for user portal

* Fix failing tests and lint code

* fix failing tests

* Add tests for organization screen and componenets

* Fix non-null assertions

* Fix non-null assertions in organizations test

* Fix bootstrap migration changes

* Add Home Screen along with other components

* Fix failing tests

* Add required tests and Offcanvas navbar

* Remove unused variables from tests

* Sync the Mutations with talawa-api

* Add Settings and Donate Screen

* Add multilingual support for the screens

* Add events screen without calendar view

* Add multilingual support to Events screen

* Fix failing tests due to merge

* Add Post Comment functionality

* Refactor Events tests

* Deprecate event registrants from query

* Add my tasks screen for user portal

* Remove unnecessary comments from test files

* Add chat screen along with components

* Add mui/system package for x-chart support

* Add chat screen tests and fix other bugs
  • Loading branch information
beingnoble03 authored Oct 15, 2023
1 parent 18e6ed9 commit 046600a
Show file tree
Hide file tree
Showing 17 changed files with 776 additions and 0 deletions.
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;

setNewMessage(newMessageValue);
};

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

0 comments on commit 046600a

Please sign in to comment.