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
53384998
Commit
53384998
authored
May 09, 2022
by
Balasuriya D.A.M.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Frontend Search User Side Drawer
parent
db76585a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
203 additions
and
5 deletions
+203
-5
IT18021080/Telemedicine-Chat-App/frontend/src/Context/ChatProvider.js
...elemedicine-Chat-App/frontend/src/Context/ChatProvider.js
+4
-1
IT18021080/Telemedicine-Chat-App/frontend/src/components/ChatLoading.js
...emedicine-Chat-App/frontend/src/components/ChatLoading.js
+24
-0
IT18021080/Telemedicine-Chat-App/frontend/src/components/UserAvatar/UserListItem.js
...at-App/frontend/src/components/UserAvatar/UserListItem.js
+50
-0
IT18021080/Telemedicine-Chat-App/frontend/src/components/miscellaneous/SideDrawer.js
...t-App/frontend/src/components/miscellaneous/SideDrawer.js
+125
-4
No files found.
IT18021080/Telemedicine-Chat-App/frontend/src/Context/ChatProvider.js
View file @
53384998
...
@@ -5,6 +5,8 @@ const ChatContext = createContext();
...
@@ -5,6 +5,8 @@ const ChatContext = createContext();
const
ChatProvider
=
({
children
})
=>
{
const
ChatProvider
=
({
children
})
=>
{
const
[
user
,
setUser
]
=
useState
();
const
[
user
,
setUser
]
=
useState
();
const
[
selectedChat
,
setSelectedChat
]
=
useState
();
const
[
chats
,
setChats
]
=
useState
();
const
history
=
useHistory
();
const
history
=
useHistory
();
...
@@ -20,7 +22,8 @@ const ChatProvider = ({ children }) => {
...
@@ -20,7 +22,8 @@ const ChatProvider = ({ children }) => {
},
[
history
]);
},
[
history
]);
return
(
return
(
<
ChatContext
.
Provider
value
=
{{
user
,
setUser
}}
>
<
ChatContext
.
Provider
value
=
{{
user
,
setUser
,
selectedChat
,
setSelectedChat
,
chats
,
setChats
}}
>
{
children
}
{
children
}
<
/ChatContext.Provider
>
<
/ChatContext.Provider
>
);
);
...
...
IT18021080/Telemedicine-Chat-App/frontend/src/components/ChatLoading.js
0 → 100644
View file @
53384998
import
{
Stack
}
from
"
@chakra-ui/layout
"
;
import
{
Skeleton
}
from
"
@chakra-ui/react
"
;
import
React
from
"
react
"
;
const
ChatLoading
=
()
=>
{
return
(
<
Stack
>
<
Skeleton
height
=
"
45px
"
/>
<
Skeleton
height
=
"
45px
"
/>
<
Skeleton
height
=
"
45px
"
/>
<
Skeleton
height
=
"
45px
"
/>
<
Skeleton
height
=
"
45px
"
/>
<
Skeleton
height
=
"
45px
"
/>
<
Skeleton
height
=
"
45px
"
/>
<
Skeleton
height
=
"
45px
"
/>
<
Skeleton
height
=
"
45px
"
/>
<
Skeleton
height
=
"
45px
"
/>
<
Skeleton
height
=
"
45px
"
/>
<
Skeleton
height
=
"
45px
"
/>
<
/Stack
>
);
};
export
default
ChatLoading
;
\ No newline at end of file
IT18021080/Telemedicine-Chat-App/frontend/src/components/UserAvatar/UserListItem.js
0 → 100644
View file @
53384998
import
{
Box
,
Text
}
from
"
@chakra-ui/layout
"
;
import
{
Avatar
}
from
"
@chakra-ui/react
"
;
import
React
from
"
react
"
;
const
UserListItem
=
({
user
,
handleFunction
})
=>
{
return
(
<
Box
onClick
=
{
handleFunction
}
cursor
=
"
pointer
"
bg
=
"
#E8E8E8
"
_hover
=
{{
background
:
"
#38BAC
"
,
color
:
"
white
"
,
}}
w
=
"
100%
"
d
=
"
flex
"
alignItems
=
"
center
"
color
=
"
black
"
px
=
{
3
}
py
=
{
2
}
mb
=
{
2
}
borderRadius
=
"
lg
"
>
<
Avatar
mr
=
{
2
}
size
=
"
sm
"
cursor
=
"
pointer
"
name
=
{
user
.
name
}
src
=
{
user
.
pic
}
/
>
<
Box
>
<
Text
>
{
user
.
name
}
<
/Text
>
<
Text
fontSize
=
"
xs
"
>
<
b
>
Email
:
<
/b
>
{
user
.
email
}
<
/Text
>
<
/Box
>
<
/Box
>
);
};
export
default
UserListItem
;
\ No newline at end of file
IT18021080/Telemedicine-Chat-App/frontend/src/components/miscellaneous/SideDrawer.js
View file @
53384998
import
{
Tooltip
,
Menu
,
MenuButton
,
MenuList
,
Avatar
,
MenuItem
,
MenuDivider
}
from
"
@chakra-ui/react
"
;
import
{
Tooltip
,
Menu
,
MenuButton
,
MenuList
,
Avatar
,
MenuItem
,
MenuDivider
,
Drawer
,
useDisclosure
,
DrawerOverlay
,
DrawerContent
,
DrawerHeader
,
DrawerBody
,
Input
,
useToast
,
}
from
"
@chakra-ui/react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
BellIcon
,
ChevronDownIcon
}
from
"
@chakra-ui/icons
"
;
import
{
BellIcon
,
ChevronDownIcon
}
from
"
@chakra-ui/icons
"
;
import
{
Box
,
Text
}
from
"
@chakra-ui/layout
"
;
import
{
Box
,
Text
}
from
"
@chakra-ui/layout
"
;
...
@@ -6,6 +22,10 @@ import { Button } from "@chakra-ui/button";
...
@@ -6,6 +22,10 @@ import { Button } from "@chakra-ui/button";
import
{
ChatState
}
from
"
../../Context/ChatProvider
"
;
import
{
ChatState
}
from
"
../../Context/ChatProvider
"
;
import
ProfileModal
from
"
./ProfileModal
"
;
import
ProfileModal
from
"
./ProfileModal
"
;
import
{
useHistory
}
from
"
react-router-dom
"
;
import
{
useHistory
}
from
"
react-router-dom
"
;
import
axios
from
"
axios
"
;
import
ChatLoading
from
"
../ChatLoading
"
;
import
UserListItem
from
"
../UserAvatar/UserListItem
"
;
const
SideDrawer
=
()
=>
{
const
SideDrawer
=
()
=>
{
...
@@ -14,14 +34,81 @@ const SideDrawer = () => {
...
@@ -14,14 +34,81 @@ const SideDrawer = () => {
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
loadingChat
,
setLoadingChat
]
=
useState
();
const
[
loadingChat
,
setLoadingChat
]
=
useState
();
const
{
user
}
=
ChatState
();
const
{
user
,
setSelectedChat
,
chats
,
setChats
}
=
ChatState
();
const
history
=
useHistory
();
const
history
=
useHistory
();
const
{
isOpen
,
onOpen
,
onClose
}
=
useDisclosure
();
const
logoutHandler
=
()
=>
{
const
logoutHandler
=
()
=>
{
localStorage
.
removeItem
(
"
userInfo
"
);
localStorage
.
removeItem
(
"
userInfo
"
);
history
.
push
(
"
/
"
);
history
.
push
(
"
/
"
);
};
};
const
toast
=
useToast
();
const
handleSearch
=
async
()
=>
{
if
(
!
search
)
{
toast
({
title
:
"
Please Enter something in search
"
,
status
:
"
warning
"
,
duration
:
5000
,
isClosable
:
true
,
position
:
"
top-left
"
,
});
return
;
}
try
{
setLoading
(
true
)
const
config
=
{
headers
:
{
Authorization
:
`Bearer
${
user
.
token
}
`
,
},
};
const
{
data
}
=
await
axios
.
get
(
`/api/user?search=
${
search
}
`
,
config
);
setLoading
(
false
);
setSearchResult
(
data
);
}
catch
(
error
)
{
toast
({
title
:
"
Error Occured!
"
,
description
:
"
Failed to Load the Search Results
"
,
status
:
"
error
"
,
duration
:
5000
,
isClosable
:
true
,
position
:
"
bottom-left
"
,
});
}
};
const
accessChat
=
async
(
userId
)
=>
{
try
{
setLoadingChat
(
true
);
const
config
=
{
headers
:
{
"
Content-type
"
:
"
application/json
"
,
Authorization
:
`Bearer
${
user
.
token
}
`
,
},
};
const
{
data
}
=
await
axios
.
post
(
"
/api/chat
"
,
{
userId
},
config
);
setSelectedChat
(
data
);
setLoadingChat
(
false
);
onClose
();
}
catch
(
error
)
{
toast
({
title
:
"
Error fetching the chat
"
,
description
:
error
.
message
,
status
:
"
error
"
,
duration
:
5000
,
isClosable
:
true
,
position
:
"
bottom-left
"
,
});
}
};
return
(
return
(
<>
<>
...
@@ -39,7 +126,7 @@ const SideDrawer = () => {
...
@@ -39,7 +126,7 @@ const SideDrawer = () => {
hasArrow
hasArrow
placement
=
"
bottom-end
"
placement
=
"
bottom-end
"
>
>
<
Button
variant
=
"
ghost
"
>
<
Button
variant
=
"
ghost
"
onClick
=
{
onOpen
}
>
<
i
class
=
"
fas fa-search
"
><
/i
>
<
i
class
=
"
fas fa-search
"
><
/i
>
<
Text
d
=
{{
base
:
"
none
"
,
md
:
"
flex
"
}}
px
=
"
4
"
>
<
Text
d
=
{{
base
:
"
none
"
,
md
:
"
flex
"
}}
px
=
"
4
"
>
Search
User
Search
User
...
@@ -78,7 +165,41 @@ const SideDrawer = () => {
...
@@ -78,7 +165,41 @@ const SideDrawer = () => {
<
/MenuList
>
<
/MenuList
>
<
/Menu
>
<
/Menu
>
<
/div
>
<
/div
>
<
/Box
>
<
/Box
>
<
Drawer
placement
=
"
left
"
onClose
=
{
onClose
}
isOpen
=
{
isOpen
}
>
<
DrawerOverlay
/>
<
DrawerContent
>
<
DrawerHeader
borderBottomWidth
=
"
1px
"
>
Search
User
<
/DrawerHeader
>
<
DrawerBody
>
<
Box
d
=
"
flex
"
pb
=
{
2
}
>
<
Input
placeholder
=
"
Search by name or email
"
mr
=
{
2
}
value
=
{
search
}
onChange
=
{(
e
)
=>
setSearch
(
e
.
target
.
value
)}
/
>
<
Button
onClick
=
{
handleSearch
}
>
Go
<
/Button
>
<
/Box
>
{
loading
?
<
ChatLoading
/>
:
(
searchResult
?.
map
(
user
=>
(
<
UserListItem
key
=
{
user
.
_id
}
user
=
{
user
}
handleFunction
=
{()
=>
accessChat
(
user
.
_id
)}
/
>
))
)
}
<
/DrawerBody
>
<
/DrawerContent
>
<
/Drawer
>
<
/
>
<
/
>
);
);
};
};
...
...
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