Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I_Helmet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22-J 62
I_Helmet
Commits
012d0369
Commit
012d0369
authored
Jun 09, 2022
by
Balasuriya D.A.M.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fecth All Messages
parent
ef8698b3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
7 deletions
+55
-7
IT18021080/Telemedicine-Chat-App/frontend/src/components/SingleChat.js
...lemedicine-Chat-App/frontend/src/components/SingleChat.js
+41
-2
IT18021080/Telemedicine-Chat-App/frontend/src/components/miscellaneous/UpdateGroupChatModal.js
...tend/src/components/miscellaneous/UpdateGroupChatModal.js
+2
-1
IT18021080/Telemedicine-Chat-App/frontend/src/components/styles.css
.../Telemedicine-Chat-App/frontend/src/components/styles.css
+6
-0
IT18021080/Telemedicine-Chat-App/frontend/src/index.js
IT18021080/Telemedicine-Chat-App/frontend/src/index.js
+6
-4
No files found.
IT18021080/Telemedicine-Chat-App/frontend/src/components/SingleChat.js
View file @
012d0369
import
{
Box
,
FormControl
,
IconButton
,
Input
,
Spinner
,
Text
,
useToast
}
from
"
@chakra-ui/react
"
;
import
{
Box
,
FormControl
,
IconButton
,
Input
,
Spinner
,
Text
,
useToast
}
from
"
@chakra-ui/react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
use
Effect
,
use
State
}
from
"
react
"
;
import
{
ChatState
}
from
"
../Context/ChatProvider
"
;
import
{
ChatState
}
from
"
../Context/ChatProvider
"
;
import
{
ArrowBackIcon
}
from
"
@chakra-ui/icons
"
;
import
{
ArrowBackIcon
}
from
"
@chakra-ui/icons
"
;
import
{
getSender
,
getSenderFull
}
from
"
../config/ChatLogics
"
;
import
{
getSender
,
getSenderFull
}
from
"
../config/ChatLogics
"
;
import
ProfileModal
from
"
./miscellaneous/ProfileModal
"
;
import
ProfileModal
from
"
./miscellaneous/ProfileModal
"
;
import
UpdateGroupChatModal
from
"
./miscellaneous/UpdateGroupChatModal
"
;
import
UpdateGroupChatModal
from
"
./miscellaneous/UpdateGroupChatModal
"
;
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
import
"
./styles.css
"
;
const
SingleChat
=
({
fetchAgain
,
setFetchAgain
})
=>
{
const
SingleChat
=
({
fetchAgain
,
setFetchAgain
})
=>
{
...
@@ -17,6 +18,43 @@ const SingleChat = ({ fetchAgain, setFetchAgain }) => {
...
@@ -17,6 +18,43 @@ const SingleChat = ({ fetchAgain, setFetchAgain }) => {
const
toast
=
useToast
();
const
toast
=
useToast
();
const
{
user
,
selectedChat
,
setSelectedChat
}
=
ChatState
();
const
{
user
,
selectedChat
,
setSelectedChat
}
=
ChatState
();
const
fetchMessages
=
async
()
=>
{
if
(
!
selectedChat
)
return
;
try
{
const
config
=
{
headers
:
{
Authorization
:
`Bearer
${
user
.
token
}
`
,
},
};
setLoading
(
true
);
const
{
data
}
=
await
axios
.
get
(
`/api/message/
${
selectedChat
.
_id
}
`
,
config
);
console
.
log
(
messages
);
setMessages
(
data
);
setLoading
(
false
);
}
catch
(
error
)
{
toast
({
title
:
"
Error Occured!
"
,
description
:
"
Failed to Load the Messages
"
,
status
:
"
error
"
,
duration
:
5000
,
isClosable
:
true
,
position
:
"
bottom
"
,
});
}
};
useEffect
(()
=>
{
fetchMessages
();
},
[
selectedChat
]);
const
sendMessage
=
async
(
event
)
=>
{
const
sendMessage
=
async
(
event
)
=>
{
if
(
event
.
key
===
"
Enter
"
&&
newMessage
)
{
if
(
event
.
key
===
"
Enter
"
&&
newMessage
)
{
try
{
try
{
...
@@ -91,6 +129,7 @@ const SingleChat = ({ fetchAgain, setFetchAgain }) => {
...
@@ -91,6 +129,7 @@ const SingleChat = ({ fetchAgain, setFetchAgain }) => {
<
UpdateGroupChatModal
<
UpdateGroupChatModal
fetchAgain
=
{
fetchAgain
}
fetchAgain
=
{
fetchAgain
}
setFetchAgain
=
{
setFetchAgain
}
setFetchAgain
=
{
setFetchAgain
}
fetchMessages
=
{
fetchMessages
}
/
>
/
>
<
/
>
<
/
>
)}
)}
...
@@ -115,7 +154,7 @@ const SingleChat = ({ fetchAgain, setFetchAgain }) => {
...
@@ -115,7 +154,7 @@ const SingleChat = ({ fetchAgain, setFetchAgain }) => {
margin
=
"
auto
"
margin
=
"
auto
"
/>
/>
)
:
(
)
:
(
<
div
>
{
/* Messages */
}
<
/div
>
<
div
className
=
"
messages
"
>
{
/* Messages */
}
<
/div
>
)}
)}
<
FormControl
onKeyDown
=
{
sendMessage
}
isRequired
mt
=
{
3
}
>
<
FormControl
onKeyDown
=
{
sendMessage
}
isRequired
mt
=
{
3
}
>
...
...
IT18021080/Telemedicine-Chat-App/frontend/src/components/miscellaneous/UpdateGroupChatModal.js
View file @
012d0369
...
@@ -6,7 +6,7 @@ import UserBadgeItem from "../UserAvatar/UserBadgeItem";
...
@@ -6,7 +6,7 @@ import UserBadgeItem from "../UserAvatar/UserBadgeItem";
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
import
UserListItem
from
"
../UserAvatar/UserListItem
"
;
import
UserListItem
from
"
../UserAvatar/UserListItem
"
;
const
UpdateGroupChatModal
=
({
fetchAgain
,
setFetchAgain
})
=>
{
const
UpdateGroupChatModal
=
({
fetchAgain
,
setFetchAgain
,
fetchMessages
})
=>
{
const
{
isOpen
,
onOpen
,
onClose
}
=
useDisclosure
();
const
{
isOpen
,
onOpen
,
onClose
}
=
useDisclosure
();
const
[
groupChatName
,
setGroupChatName
]
=
useState
();
const
[
groupChatName
,
setGroupChatName
]
=
useState
();
...
@@ -113,6 +113,7 @@ const UpdateGroupChatModal = ({ fetchAgain, setFetchAgain }) => {
...
@@ -113,6 +113,7 @@ const UpdateGroupChatModal = ({ fetchAgain, setFetchAgain }) => {
user1
.
_id
===
user
.
_id
?
setSelectedChat
()
:
setSelectedChat
(
data
);
user1
.
_id
===
user
.
_id
?
setSelectedChat
()
:
setSelectedChat
(
data
);
setFetchAgain
(
!
fetchAgain
);
setFetchAgain
(
!
fetchAgain
);
fetchMessages
();
setLoading
(
false
);
setLoading
(
false
);
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
IT18021080/Telemedicine-Chat-App/frontend/src/components/styles.css
0 → 100644
View file @
012d0369
.messages
{
display
:
flex
;
flex-direction
:
column
;
overflow-y
:
scroll
;
scrollbar-width
:
none
;
}
\ No newline at end of file
IT18021080/Telemedicine-Chat-App/frontend/src/index.js
View file @
012d0369
...
@@ -10,15 +10,17 @@ import ChatProvider from "./Context/ChatProvider";
...
@@ -10,15 +10,17 @@ import ChatProvider from "./Context/ChatProvider";
ReactDOM
.
render
(
ReactDOM
.
render
(
<
ChatProvider
>
<
BrowserRouter
>
<
ChatProvider
>
<
BrowserRouter
>
<
ChakraProvider
>
<
ChakraProvider
>
<
App
/>
<
App
/>
<
/ChakraProvider
>
<
/ChakraProvider
>
<
/BrowserRouter
>
<
/ChatProvider>
,
<
/ChatProvider
>
<
/BrowserRouter>
,
document
.
getElementById
(
"
root
"
)
document
.
getElementById
(
"
root
"
)
);
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment