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
ef8698b3
Commit
ef8698b3
authored
Jun 08, 2022
by
Balasuriya D.A.M.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send Messages Logic FrontEnd
parent
47d2ae3e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
4 deletions
+47
-4
IT18021080/Telemedicine-Chat-App/frontend/src/components/SingleChat.js
...lemedicine-Chat-App/frontend/src/components/SingleChat.js
+46
-3
IT18021080/Telemedicine-Chat-App/frontend/src/components/miscellaneous/GroupChatModal.js
...p/frontend/src/components/miscellaneous/GroupChatModal.js
+1
-1
No files found.
IT18021080/Telemedicine-Chat-App/frontend/src/components/SingleChat.js
View file @
ef8698b3
import
{
Box
,
FormControl
,
IconButton
,
Input
,
Spinner
,
Text
}
from
"
@chakra-ui/react
"
;
import
{
Box
,
FormControl
,
IconButton
,
Input
,
Spinner
,
Text
,
useToast
}
from
"
@chakra-ui/react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
ChatState
}
from
"
../Context/ChatProvider
"
;
import
{
ArrowBackIcon
}
from
"
@chakra-ui/icons
"
;
import
{
getSender
,
getSenderFull
}
from
"
../config/ChatLogics
"
;
import
ProfileModal
from
"
./miscellaneous/ProfileModal
"
;
import
UpdateGroupChatModal
from
"
./miscellaneous/UpdateGroupChatModal
"
;
import
axios
from
"
axios
"
;
const
SingleChat
=
({
fetchAgain
,
setFetchAgain
})
=>
{
...
...
@@ -13,10 +14,52 @@ const SingleChat = ({ fetchAgain, setFetchAgain }) => {
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
newMessage
,
setNewMessage
]
=
useState
();
const
toast
=
useToast
();
const
{
user
,
selectedChat
,
setSelectedChat
}
=
ChatState
();
const
sendMessage
=
()
=>
{
};
const
typingHandler
=
()
=>
{
};
const
sendMessage
=
async
(
event
)
=>
{
if
(
event
.
key
===
"
Enter
"
&&
newMessage
)
{
try
{
const
config
=
{
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
Authorization
:
`Bearer
${
user
.
token
}
`
,
},
};
setNewMessage
(
""
);
const
{
data
}
=
await
axios
.
post
(
"
/api/message
"
,
{
content
:
newMessage
,
chatId
:
selectedChat
.
_id
,
},
config
);
console
.
log
(
data
);
setMessages
([...
messages
,
data
]);
}
catch
(
error
)
{
toast
({
title
:
"
Error Occured!
"
,
description
:
"
Failed to send the Message
"
,
status
:
"
error
"
,
duration
:
5000
,
isClosable
:
true
,
position
:
"
bottom
"
,
});
}
}
};
const
typingHandler
=
(
e
)
=>
{
setNewMessage
(
e
.
target
.
value
);
//Typing Indicator Logic
};
return
(
<>
...
...
IT18021080/Telemedicine-Chat-App/frontend/src/components/miscellaneous/GroupChatModal.js
View file @
ef8698b3
...
...
@@ -36,7 +36,7 @@ const GroupChatModal = ({ children }) => {
};
const
{
data
}
=
await
axios
.
get
(
`/api/user?search=
${
search
}
`
,
config
);
console
.
log
(
data
);
setLoading
(
false
);
setSearchResult
(
data
);
}
catch
(
error
)
{
...
...
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