diff --git a/client/package-lock.json b/client/package-lock.json index 49ddd19d..25a443c1 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -17,6 +17,7 @@ "@mui/system": "^5.8.6", "@mui/utils": "^5.8.6", "@mui/x-date-pickers": "^6.16.1", + "@reduxjs/toolkit": "^2.0.1", "@stripe/react-stripe-js": "^2.3.1", "@stripe/stripe-js": "^2.1.10", "@tabler/icons": "^1.72.0", @@ -43,7 +44,7 @@ "react-dnd-html5-backend": "^16.0.1", "react-dom": "^18.2.0", "react-perfect-scrollbar": "^1.5.8", - "react-redux": "^8.0.2", + "react-redux": "^8.1.3", "react-router": "6.3.0", "react-router-dom": "6.3.0", "react-scripts": "5.0.1", @@ -5123,6 +5124,51 @@ "resolved": "https://registry.npmjs.org/@react-dnd/shallowequal/-/shallowequal-4.0.2.tgz", "integrity": "sha512-/RVXdLvJxLg4QKvMoM5WlwNR9ViO9z8B/qPcc+C0Sa/teJY7QG7kJ441DwzOjMYEY7GmU4dj5EcGHIkKZiQZCA==" }, + "node_modules/@reduxjs/toolkit": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.0.1.tgz", + "integrity": "sha512-fxIjrR9934cmS8YXIGd9e7s1XRsEU++aFc9DVNMFMRTM5Vtsg2DCRMj21eslGtDt43IUf9bJL3h5bwUlZleibA==", + "dependencies": { + "immer": "^10.0.3", + "redux": "^5.0.0", + "redux-thunk": "^3.1.0", + "reselect": "^5.0.1" + }, + "peerDependencies": { + "react": "^16.9.0 || ^17.0.0 || ^18", + "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-redux": { + "optional": true + } + } + }, + "node_modules/@reduxjs/toolkit/node_modules/immer": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/immer/-/immer-10.0.3.tgz", + "integrity": "sha512-pwupu3eWfouuaowscykeckFmVTpqbzW+rXFCX8rQLkZzM9ftBmU/++Ra+o+L27mz03zJTlyV4UUr+fdKNffo4A==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/immer" + } + }, + "node_modules/@reduxjs/toolkit/node_modules/redux": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", + "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==" + }, + "node_modules/@reduxjs/toolkit/node_modules/redux-thunk": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz", + "integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==", + "peerDependencies": { + "redux": "^5.0.0" + } + }, "node_modules/@rollup/plugin-babel": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz", @@ -22902,9 +22948,9 @@ } }, "node_modules/react-redux": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.5.tgz", - "integrity": "sha512-Q2f6fCKxPFpkXt1qNRZdEDLlScsDWyrgSj0mliK59qU6W5gvBiKkdMEG2lJzhd1rCctf0hb6EtePPLZ2e0m1uw==", + "version": "8.1.3", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.1.3.tgz", + "integrity": "sha512-n0ZrutD7DaX/j9VscF+uTALI3oUPa/pO4Z3soOBIjuRn/FzVu6aehhysxZCLi6y7duMf52WNZGMl7CtuK5EnRw==", "dependencies": { "@babel/runtime": "^7.12.1", "@types/hoist-non-react-statics": "^3.3.1", @@ -22919,7 +22965,7 @@ "react": "^16.8 || ^17.0 || ^18.0", "react-dom": "^16.8 || ^17.0 || ^18.0", "react-native": ">=0.59", - "redux": "^4" + "redux": "^4 || ^5.0.0-beta.0" }, "peerDependenciesMeta": { "@types/react": { @@ -24673,6 +24719,11 @@ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" }, + "node_modules/reselect": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.0.1.tgz", + "integrity": "sha512-D72j2ubjgHpvuCiORWkOUxndHJrxDaSolheiz5CO+roz8ka97/4msh2E8F5qay4GawR5vzBt5MkbDHT+Rdy/Wg==" + }, "node_modules/resolve": { "version": "1.22.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", @@ -31082,6 +31133,35 @@ "resolved": "https://registry.npmjs.org/@react-dnd/shallowequal/-/shallowequal-4.0.2.tgz", "integrity": "sha512-/RVXdLvJxLg4QKvMoM5WlwNR9ViO9z8B/qPcc+C0Sa/teJY7QG7kJ441DwzOjMYEY7GmU4dj5EcGHIkKZiQZCA==" }, + "@reduxjs/toolkit": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.0.1.tgz", + "integrity": "sha512-fxIjrR9934cmS8YXIGd9e7s1XRsEU++aFc9DVNMFMRTM5Vtsg2DCRMj21eslGtDt43IUf9bJL3h5bwUlZleibA==", + "requires": { + "immer": "^10.0.3", + "redux": "^5.0.0", + "redux-thunk": "^3.1.0", + "reselect": "^5.0.1" + }, + "dependencies": { + "immer": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/immer/-/immer-10.0.3.tgz", + "integrity": "sha512-pwupu3eWfouuaowscykeckFmVTpqbzW+rXFCX8rQLkZzM9ftBmU/++Ra+o+L27mz03zJTlyV4UUr+fdKNffo4A==" + }, + "redux": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", + "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==" + }, + "redux-thunk": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz", + "integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==", + "requires": {} + } + } + }, "@rollup/plugin-babel": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz", @@ -43770,9 +43850,9 @@ } }, "react-redux": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.5.tgz", - "integrity": "sha512-Q2f6fCKxPFpkXt1qNRZdEDLlScsDWyrgSj0mliK59qU6W5gvBiKkdMEG2lJzhd1rCctf0hb6EtePPLZ2e0m1uw==", + "version": "8.1.3", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.1.3.tgz", + "integrity": "sha512-n0ZrutD7DaX/j9VscF+uTALI3oUPa/pO4Z3soOBIjuRn/FzVu6aehhysxZCLi6y7duMf52WNZGMl7CtuK5EnRw==", "requires": { "@babel/runtime": "^7.12.1", "@types/hoist-non-react-statics": "^3.3.1", @@ -45102,6 +45182,11 @@ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" }, + "reselect": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.0.1.tgz", + "integrity": "sha512-D72j2ubjgHpvuCiORWkOUxndHJrxDaSolheiz5CO+roz8ka97/4msh2E8F5qay4GawR5vzBt5MkbDHT+Rdy/Wg==" + }, "resolve": { "version": "1.22.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", diff --git a/client/package.json b/client/package.json index aa76f3ad..18849a15 100644 --- a/client/package.json +++ b/client/package.json @@ -13,6 +13,7 @@ "@mui/system": "^5.8.6", "@mui/utils": "^5.8.6", "@mui/x-date-pickers": "^6.16.1", + "@reduxjs/toolkit": "^2.0.1", "@stripe/react-stripe-js": "^2.3.1", "@stripe/stripe-js": "^2.1.10", "@tabler/icons": "^1.72.0", @@ -39,7 +40,7 @@ "react-dnd-html5-backend": "^16.0.1", "react-dom": "^18.2.0", "react-perfect-scrollbar": "^1.5.8", - "react-redux": "^8.0.2", + "react-redux": "^8.1.3", "react-router": "6.3.0", "react-router-dom": "6.3.0", "react-scripts": "5.0.1", diff --git a/client/src/App.js b/client/src/App.js index 46ca9a98..54fa9a1f 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -1,4 +1,4 @@ -import { useSelector } from 'react-redux'; +import { useDispatch, useSelector } from 'react-redux'; import { ThemeProvider } from '@mui/material/styles'; import { CssBaseline } from '@mui/material'; @@ -9,7 +9,6 @@ import Routes from 'routes'; // defaultTheme import themes from 'themes'; import { useEffect, useState } from 'react'; -import { useUserContext } from 'hooks/useUserContext'; import { useNavigate, useLocation } from 'react-router-dom'; import { LocalizationProvider } from '@mui/x-date-pickers'; import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'; @@ -18,13 +17,15 @@ import { authenticationAxios } from './utils/AxiosConfig'; import { DndProvider } from 'react-dnd'; import { HTML5Backend } from 'react-dnd-html5-backend'; import { showFailureAlert } from './utils/swal'; +import { dispatchUser } from 'store/user/configUserStore'; // ==============================|| APP ||============================== // const App = () => { const customization = useSelector((state) => state.customization); - const { dispatch, user } = useUserContext(); + const { user } = useSelector(state => state.user); + const dispatch = useDispatch(); const navigate = useNavigate(); const [isLoading, setIsLoading] = useState(true); const location = useLocation(); @@ -34,10 +35,11 @@ const App = () => { console.log({ ckeckData: userCheck.data }); if(!user) { - await dispatch({ auth: true, payload: userCheck.data }); + await dispatch(dispatchUser({ user: userCheck.data })); setIsLoading(false); } if(location.pathname == '/login/login3' || location.pathname == '/login/register/register3'){ + console.log('formward ',{ user }); navigate(`/${userCheck.data.type}`); setIsLoading(false); } @@ -48,7 +50,7 @@ const App = () => { navigate('/login/login3'); setIsLoading(false); } - await dispatch({ auth: false, payload: null }); + await dispatch(dispatchUser({ user: null })); setIsLoading(false); }); @@ -60,7 +62,7 @@ const App = () => { {isLoading && } - {!isLoading && } + {!isLoading &&} diff --git a/client/src/contexts/ChatContext.js b/client/src/contexts/ChatContext.js index 6923cba7..b56a6952 100644 --- a/client/src/contexts/ChatContext.js +++ b/client/src/contexts/ChatContext.js @@ -7,9 +7,9 @@ import { PHARMACIST_TYPE_ENUM, PHARMACY_MONGO_ID, } from '../utils/Constants.js'; -import { useUserContext } from 'hooks/useUserContext.js'; import { chatExist } from 'utils/ChatUtils.js'; import { isEqual } from 'lodash'; +import { useSelector } from 'react-redux'; const ChatContext = createContext(); var socket; @@ -21,20 +21,18 @@ export const ChatContextProvider = ({ children }) => { const [chatMessages, setChatMessages] = useState([]); const [newMessage, setNewMessage] = useState(''); - const { user } = useUserContext(); - const userId = user.id, - userType = user.type; + const { user } = useSelector(state => state.user); const updateChat = (updatedChat, messageId, type) => { if(type === 0) { - if(updatedChat.users[0].id === userId) { + if(updatedChat.users[0].id === user.id) { updatedChat.users[0].unseen++; } else { updatedChat.users[1].unseen++; } } if(type === 1) { - if(updatedChat.users[0].id === userId) { + if(updatedChat.users[0].id === user.id) { updatedChat.users[1].unseen++; } else { updatedChat.users[0].unseen++; @@ -65,7 +63,7 @@ export const ChatContextProvider = ({ children }) => { socket = io.connect(COMMUNICATION_BASE_URL); socket.emit( 'setup', - userType === PHARMACIST_TYPE_ENUM ? PHARMACY_MONGO_ID : userId + user.type === PHARMACIST_TYPE_ENUM ? PHARMACY_MONGO_ID : user.id ); }, []); @@ -73,12 +71,12 @@ export const ChatContextProvider = ({ children }) => { const fetchData = async () => { try { const response = await communicationAxios.get( - `/chat/${userId}` + `/chat/${user.id}` ); if ( - userType === PATIENT_TYPE_ENUM && - !chatExist(response.data, userId, PHARMACY_MONGO_ID) && - !chatExist(response.data, PHARMACY_MONGO_ID, userId) + user.type === PATIENT_TYPE_ENUM && + !chatExist(response.data, user.id, PHARMACY_MONGO_ID) && + !chatExist(response.data, PHARMACY_MONGO_ID, user.id) ) { const res = await communicationAxios.post('/chat', { chat: { @@ -88,7 +86,7 @@ export const ChatContextProvider = ({ children }) => { id: PHARMACY_MONGO_ID, userType: PHARMACIST_TYPE_ENUM, }, - { id: userId, userType: PATIENT_TYPE_ENUM }, + { id: user.id, userType: PATIENT_TYPE_ENUM }, ], }, }); @@ -109,7 +107,7 @@ export const ChatContextProvider = ({ children }) => { chats.map(chat => { if(chat && chat.users) { chat.users.map(user => { - if(user.id === userId) { + if(user.id === user.id) { tot += user.unseen; } }); @@ -128,13 +126,13 @@ export const ChatContextProvider = ({ children }) => { updateChat(data.selectedChat, data.message._id, 0); if (selectedChat && selectedChat._id === data.room) { selectedChat.users.map(user => { - if(user.id === userId) { + if(user.id === user.id) { user.unseen = 0; } return user; }); socket.emit('message_seen', { - sender: userId, + sender: user.id, chat: selectedChat, }); setChatMessages((prevMessages) => [ diff --git a/client/src/contexts/VideoChatContext.js b/client/src/contexts/VideoChatContext.js index c8cd306e..92a0b47d 100644 --- a/client/src/contexts/VideoChatContext.js +++ b/client/src/contexts/VideoChatContext.js @@ -2,14 +2,14 @@ import React, { createContext, useState, useRef, useEffect } from 'react'; import { io } from 'socket.io-client'; import Peer from 'simple-peer'; import { COMMUNICATION_BASE_URL } from '../utils/Constants'; -import { useUserContext } from '../hooks/useUserContext'; +import { useSelector } from 'react-redux'; const SocketContext = createContext(); const socket = io(COMMUNICATION_BASE_URL); const ContextProvider = ({ children }) => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const [callAccepted, setCallAccepted] = useState(false); const [callEnded, setCallEnded] = useState(false); const [stream, setStream] = useState(); diff --git a/client/src/hooks/AuthGuard.js b/client/src/hooks/AuthGuard.js index 85e32d83..f7b3f74f 100644 --- a/client/src/hooks/AuthGuard.js +++ b/client/src/hooks/AuthGuard.js @@ -1,11 +1,11 @@ import { Route, useHistory } from 'react-router-dom'; -import { useUserContext } from '../hooks/useUserContext'; import Loading from '../components/Loading'; import { useEffect, Suspense } from 'react'; import { GUEST_ACCESS } from './Constants'; +import useSelector from 'react-redux'; const AuthGuard = ({ component: Component, Auth, isLazy, ...rest }) => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const history = useHistory(); const isRoute = true; // Dummy data diff --git a/client/src/index.js b/client/src/index.js index c02df42d..da806955 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -3,7 +3,6 @@ import { Provider } from 'react-redux'; import App from 'App'; import { store } from 'store'; import 'assets/scss/style.scss'; -import { UserContextProvider } from './contexts/UserContext'; import { PaymentProvider } from './contexts/PaymentContext'; import { BrowserRouter } from 'react-router-dom'; @@ -14,11 +13,9 @@ const root = createRoot(container); // createRoot(container!) if you use TypeScr root.render( - - - - - + + + ); diff --git a/client/src/layout/MainLayout/Header/NotificationSection/index.js b/client/src/layout/MainLayout/Header/NotificationSection/index.js index eeeaad63..dc03c5c7 100644 --- a/client/src/layout/MainLayout/Header/NotificationSection/index.js +++ b/client/src/layout/MainLayout/Header/NotificationSection/index.js @@ -29,11 +29,11 @@ import NotificationList from './NotificationList'; // assets import { IconBell } from '@tabler/icons'; -import { useUserContext } from 'hooks/useUserContext'; import { communicationAxios } from 'utils/AxiosConfig'; import { COMMUNICATION_BASE_URL } from 'utils/Constants'; import { io } from 'socket.io-client'; import { showFailureAlert } from 'utils/swal'; +import { useSelector } from 'react-redux'; // ==============================|| NOTIFICATION ||============================== // @@ -43,7 +43,7 @@ const NotificationSection = () => { const matchesXs = useMediaQuery(theme.breakpoints.down('md')); const [open, setOpen] = useState(false); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const [notifications, setNotifications] = useState([]); const [numberOfUnseenNotification, setNumberOfUnseenNotification] = useState(0); const [dataChange, setDataChange] = useState(false); diff --git a/client/src/layout/MainLayout/Header/NotificationSection/notificationComponents/BasicNotification.js b/client/src/layout/MainLayout/Header/NotificationSection/notificationComponents/BasicNotification.js index de8865c8..88903804 100644 --- a/client/src/layout/MainLayout/Header/NotificationSection/notificationComponents/BasicNotification.js +++ b/client/src/layout/MainLayout/Header/NotificationSection/notificationComponents/BasicNotification.js @@ -12,11 +12,11 @@ import { Typography } from '@mui/material'; import { useNavigate } from 'react-router'; -import { useUserContext } from 'hooks/useUserContext'; // assets import { IconCalendarTime } from '@tabler/icons'; import { APPOINTMENT_NOTIFICATION_TYPE_ENUM } from 'utils/Constants'; +import { useSelector } from 'react-redux'; const ListItemWrapper = styled('div')(({ theme }) => ({ @@ -38,7 +38,7 @@ const chipSX = { const BasicNotification = ({ header, body, date, notificationType, senderName, senderImage, chipLabel, chipType, key }) => { const theme = useTheme(); const navigate = useNavigate(); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const chipStyles = { error:{ diff --git a/client/src/layout/MainLayout/Header/ProfileSection/UpgradePlanCard.js b/client/src/layout/MainLayout/Header/ProfileSection/UpgradePlanCard.js index f3837a13..127f925f 100644 --- a/client/src/layout/MainLayout/Header/ProfileSection/UpgradePlanCard.js +++ b/client/src/layout/MainLayout/Header/ProfileSection/UpgradePlanCard.js @@ -2,12 +2,12 @@ import { styled } from '@mui/material/styles'; import { useState, useEffect } from 'react'; import { Button, Card, CardContent, Grid, Stack, Typography } from '@mui/material'; -import { useUserContext } from 'hooks/useUserContext'; // project imports import AnimateButton from 'ui-component/extended/AnimateButton'; import { HEALTH_PACKAGE_STATUS } from 'utils/Constants'; import { useNavigate } from 'react-router-dom'; import { getPatientHealthPackage } from 'api/PatientAPI'; +import { useSelector } from 'react-redux'; // styles const CardStyle = styled(Card)(({ theme }) => ({ background: theme.palette.warning.light, @@ -43,7 +43,8 @@ const CardStyle = styled(Card)(({ theme }) => ({ const UpgradePlanCard = () => { const [healthPackages, setHealthPackages] = useState([]); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); + const renewalDate = healthPackages[0] ? new Date(healthPackages[0].renewalDate) : new Date(); const options = { day: 'numeric', month: 'long' }; const formattedRenewalDate = renewalDate.toLocaleString('en-US', options); diff --git a/client/src/layout/MainLayout/Header/ProfileSection/index.js b/client/src/layout/MainLayout/Header/ProfileSection/index.js index 0e4cc5c3..f6438770 100644 --- a/client/src/layout/MainLayout/Header/ProfileSection/index.js +++ b/client/src/layout/MainLayout/Header/ProfileSection/index.js @@ -1,7 +1,7 @@ import { useState, useRef, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; -import { useSelector } from 'react-redux'; +import { useDispatch, useSelector } from 'react-redux'; // material-ui import { useTheme } from '@mui/material/styles'; @@ -33,9 +33,9 @@ import UpgradePlanCard from './UpgradePlanCard'; // assets import { IconLogout, IconSettings, IconUser } from '@tabler/icons'; -import { useUserContext } from 'hooks/useUserContext'; import { authenticationAxios } from 'utils/AxiosConfig'; import { showFailureAlert } from 'utils/swal'; +import { dispatchUser } from 'store/user/configUserStore'; // ==============================|| PROFILE MENU ||============================== // const ProfileSection = () => { @@ -44,17 +44,18 @@ const ProfileSection = () => { const navigate = useNavigate(); const [selectedIndex] = useState(-1); const [open, setOpen] = useState(false); - const { dispatch, user } = useUserContext(); + const { user } = useSelector(state => state.user); + const dispatch = useDispatch(); /** * anchorRef is used on different componets and specifying one type leads to other components throwing an error * */ const anchorRef = useRef(null); - const handleLogout = async () => { - await authenticationAxios + const handleLogout = () => { + authenticationAxios .get('/remove-cookie') - .then(() => { - dispatch({ auth: false, payload: null }); + .then(async () => { navigate('/login/login3'); + dispatch(dispatchUser({ user: null })); }) .catch(() => { showFailureAlert('Oops...', 'failed to logout'); diff --git a/client/src/layout/MainLayout/Sidebar/LogoSection/index.js b/client/src/layout/MainLayout/Sidebar/LogoSection/index.js index f4814c7e..f024377c 100644 --- a/client/src/layout/MainLayout/Sidebar/LogoSection/index.js +++ b/client/src/layout/MainLayout/Sidebar/LogoSection/index.js @@ -7,11 +7,10 @@ import { ButtonBase } from '@mui/material'; // project imports import Logo from 'ui-component/Logo'; import { MENU_OPEN } from 'store/actions'; -import { useUserContext } from 'hooks/useUserContext.js'; // ==============================|| MAIN LOGO ||============================== // const LogoSection = () => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const userType = user.type; const defaultId = useSelector((state) => state.customization.defaultId); const dispatch = useDispatch(); diff --git a/client/src/layout/MainLayout/Sidebar/MenuList/index.js b/client/src/layout/MainLayout/Sidebar/MenuList/index.js index 12db5f14..154d2e2c 100644 --- a/client/src/layout/MainLayout/Sidebar/MenuList/index.js +++ b/client/src/layout/MainLayout/Sidebar/MenuList/index.js @@ -6,13 +6,13 @@ import NavGroup from './NavGroup'; import patientMenuItem from 'layout/MainLayout/Sidebar/MenuList/patient-menu-items'; import doctortMenuItem from 'layout/MainLayout/Sidebar/MenuList/doctor-menu-items'; import admintMenuItem from 'layout/MainLayout/Sidebar/MenuList/admin-menu-items'; -import { useUserContext } from 'hooks/useUserContext'; import { ADMIN_TYPE_ENUM, PATIENT_TYPE_ENUM } from 'utils/Constants'; +import { useSelector } from 'react-redux'; // ==============================|| SIDEBAR MENU LIST ||============================== // const MenuList = () => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const menuItem = user.type == PATIENT_TYPE_ENUM? patientMenuItem: user.type == ADMIN_TYPE_ENUM? admintMenuItem: doctortMenuItem; const navItems = menuItem.items.map((item) => { diff --git a/client/src/layout/MainLayout/Sidebar/index.js b/client/src/layout/MainLayout/Sidebar/index.js index 588f0f36..81feb2ee 100644 --- a/client/src/layout/MainLayout/Sidebar/index.js +++ b/client/src/layout/MainLayout/Sidebar/index.js @@ -3,7 +3,6 @@ import TotalIncomeDarkCard from 'ui-component/cards/TotalIncomeDarkCard'; // material-ui import { useTheme } from '@mui/material/styles'; import { Box, Chip, Drawer, Stack, useMediaQuery, List } from '@mui/material'; -import { useUserContext } from 'hooks/useUserContext'; import { usePayment } from 'contexts/PaymentContext'; // third-party import PerfectScrollbar from 'react-perfect-scrollbar'; @@ -16,6 +15,7 @@ import { drawerWidth } from 'store/constant'; import { useState, useEffect } from 'react'; import { patientAxios, clinicAxios } from 'utils/AxiosConfig'; +import { useSelector } from 'react-redux'; // ==============================|| SIDEBAR DRAWER ||============================== // @@ -23,7 +23,7 @@ const Sidebar = ({ drawerOpen, drawerToggle, window }) => { const theme = useTheme(); const matchUpMd = useMediaQuery(theme.breakpoints.up('md')); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const userType = user.type; const userId = user.id; diff --git a/client/src/layout/MainLayout/index.js b/client/src/layout/MainLayout/index.js index b7a512c4..431df92e 100644 --- a/client/src/layout/MainLayout/index.js +++ b/client/src/layout/MainLayout/index.js @@ -23,7 +23,6 @@ import { SET_MENU } from 'store/actions'; import { ChatContextProvider } from 'contexts/ChatContext'; import { SearchProvider } from 'contexts/SearchContext'; import { FilterProvider } from 'contexts/FilterContext'; -import { useUserContext } from 'hooks/useUserContext'; import { useEffect } from 'react'; import { ContextProvider } from 'contexts/VideoChatContext'; import { getDoctorStatus } from 'api/DoctorAPI'; @@ -71,9 +70,7 @@ const MainLayout = ({ userType }) => { const matchDownMd = useMediaQuery(theme.breakpoints.down('md')); const navigate = useNavigate(); const leftDrawerOpened = useSelector((state) => state.customization.opened); - - const { user } = useUserContext(); - const id = user.id; + const { user } = useSelector(state => state.user); const location = useLocation(); useEffect(() => { const isDoctor = user.type === DOCTOR_TYPE_ENUM; @@ -81,7 +78,7 @@ const MainLayout = ({ userType }) => { navigate(`/${user.type}/dashboard/home`); } if (isDoctor) { - getDoctorStatus(id) + getDoctorStatus(user.id) .then((res) => { const status = res.status; if (user && isDoctor && !status) { @@ -100,66 +97,67 @@ const MainLayout = ({ userType }) => { }; return ( + user && - - - - - - {/* header */} - - -
- - - - {/* drawer */} - {user && user.type == userType && ( - + + + + + {/* header */} + + +
- )} + + - {/* main content */} -
- {(!user || user.type != userType) && ( -

not autherized!!

- )} - {user && user.type == userType && - user.type === 'admin' ? : - -
- -
-
+ {/* drawer */} + {user && user.type == userType && ( + + drawerToggle={handleLeftDrawerToggle} + /> + )} + + {/* main content */} +
+ {(!user || user.type != userType) && ( +

not autherized!!

+ )} + {user && user.type == userType && + user.type === 'admin' ? : + +
+ +
+
+ } +
- {/* */} - - - - - + {/* */} + + + + + ); }; diff --git a/client/src/pages/Appointment/Appointment.js b/client/src/pages/Appointment/Appointment.js index 5574ec73..8d8a28db 100644 --- a/client/src/pages/Appointment/Appointment.js +++ b/client/src/pages/Appointment/Appointment.js @@ -3,7 +3,6 @@ import { clinicAxios } from 'pages/utilities/AxiosConfig'; import MainCard from 'ui-component/cards/MainCard'; import AppointmentList from './AppointmentList.js'; import AppointmentOptions from './appointment-options/AppointmentOptions.js'; -import { useUserContext } from 'hooks/useUserContext.js'; import { useFilter } from 'contexts/FilterContext.js'; import { APPOINTMENT_FILTER_ARRAY, @@ -14,6 +13,7 @@ import { filterAppointmentByChronology } from 'utils/AppointmentUtils.js'; import Pagination from '@mui/material/Pagination'; +import { useSelector } from 'react-redux'; const Appointment = () => { @@ -25,7 +25,7 @@ const Appointment = () => { const [currentPage, setCurrentPage] = useState(0); // 0-indexed const isNormalRender = useRef(true); const { filterData, updateFilter } = useFilter(); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const userId = user.id; const paginate = (allAppointments, requiredPage) => { diff --git a/client/src/pages/Appointment/appointment-options/AppointmentDetails.js b/client/src/pages/Appointment/appointment-options/AppointmentDetails.js index 460e0411..aa3abc44 100644 --- a/client/src/pages/Appointment/appointment-options/AppointmentDetails.js +++ b/client/src/pages/Appointment/appointment-options/AppointmentDetails.js @@ -14,13 +14,13 @@ import { clinicAxios, communicationAxios } from 'pages/utilities/AxiosConfig'; import { useChat } from 'contexts/ChatContext.js'; import { DOCTOR_TYPE_ENUM, PATIENT_TYPE_ENUM } from 'utils/Constants.js'; import { chatExist } from 'utils/ChatUtils.js'; -import { useUserContext } from 'hooks/useUserContext.js'; import { getDay, getTime } from '../../../utils/DateFormatter.js'; import { patientCanRefund } from '../../../utils/AppointmentUtils.js'; import AppointmentStatus from '../AppointmentStatus.js'; import { useNavigate } from 'react-router-dom'; import { usePayment } from 'contexts/PaymentContext'; import { showSuccessAlert } from 'utils/swal'; +import { useSelector } from 'react-redux'; const AppointmentDetails = ({ @@ -29,7 +29,7 @@ const AppointmentDetails = ({ handleAppoinmentUpdate }) => { const { chats, setChats } = useChat(); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const navigate = useNavigate(); const [cannotCompleteOrCancel, setCannotCompleteOrCancel] = useState(false); diff --git a/client/src/pages/Appointment/appointment-options/AppointmentOptions.js b/client/src/pages/Appointment/appointment-options/AppointmentOptions.js index 752afd93..81c366ca 100644 --- a/client/src/pages/Appointment/appointment-options/AppointmentOptions.js +++ b/client/src/pages/Appointment/appointment-options/AppointmentOptions.js @@ -11,11 +11,11 @@ import { import TabContext from '@mui/lab/TabContext'; import TabList from '@mui/lab/TabList'; import TabPanel from '@mui/lab/TabPanel'; -import { useUserContext } from 'hooks/useUserContext.js'; import { PATIENT_TYPE_ENUM } from 'utils/Constants'; import AppointmentDetails from './AppointmentDetails'; import AppointmentReschedule from './AppointmentReschedule'; import FollowUp from './FollowUp'; +import { useSelector } from 'react-redux'; const AppointmentOptions = ({ @@ -24,7 +24,7 @@ const AppointmentOptions = ({ handleDialogClose, handleAppoinmentUpdate }) => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const [tabValue, setTabValue] = useState('1'); const [cannotReschedule, setCannotReschedule] = useState(false); const handleTabChange = (event, newTabValue) => { diff --git a/client/src/pages/Appointment/appointment-options/AppointmentReschedule.js b/client/src/pages/Appointment/appointment-options/AppointmentReschedule.js index 31b99808..f03e5276 100644 --- a/client/src/pages/Appointment/appointment-options/AppointmentReschedule.js +++ b/client/src/pages/Appointment/appointment-options/AppointmentReschedule.js @@ -5,17 +5,17 @@ import AvailableSlotsList from '../../../ui-component/AvailableSlotsList.js'; import Swal from 'sweetalert2'; import '../../../assets/css/swalStyle.css'; import { communicationAxios } from 'utils/AxiosConfig.js'; -import { useUserContext } from 'hooks/useUserContext'; import { PATIENT_TYPE_ENUM } from 'utils/Constants.js'; import { getDay, getTime } from '../../../utils/DateFormatter.js'; import { showSuccessAlert } from 'utils/swal.js'; +import { useSelector } from 'react-redux'; const AppointmentReschedule = ({ selectedAppointment, setSelectedAppointment, setTabValue, handleAppoinmentUpdate }) => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const [doctorAvailableSlots, setDoctorAvailableSlots] = useState(null); const [isLoading, setIsLoading] = useState(true); diff --git a/client/src/pages/admin/admin-control/Admins.js b/client/src/pages/admin/admin-control/Admins.js index 444f74cf..796dc5a6 100644 --- a/client/src/pages/admin/admin-control/Admins.js +++ b/client/src/pages/admin/admin-control/Admins.js @@ -1,5 +1,4 @@ import React, { useEffect } from 'react'; -import { useUserContext } from 'hooks/useUserContext.js'; import { useAdminContext } from 'hooks/useAdminContext.js'; import { Fab } from '@mui/material'; import AddIcon from '@mui/icons-material/Add'; @@ -12,8 +11,9 @@ import { getAdmins } from 'api/AdminAPI'; import Message from 'ui-component/Message'; import { TWO_SECONDS } from 'utils/Constants'; import Loader from 'ui-component/Loader'; +import { useSelector } from 'react-redux'; const Admins = () => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const { setAdmins, setIsLoading, admins, setErrorMessage, isLoading, removeAdmin, addAdmin, setOpenAddDialog } = useAdminContext(); useEffect(() => { diff --git a/client/src/pages/authentication/AuthRoutesWrapper.js b/client/src/pages/authentication/AuthRoutesWrapper.js index 0a3413c7..cade4353 100644 --- a/client/src/pages/authentication/AuthRoutesWrapper.js +++ b/client/src/pages/authentication/AuthRoutesWrapper.js @@ -1,15 +1,16 @@ -import { useUserContext } from 'hooks/useUserContext'; import { useEffect, useState } from 'react'; import { Outlet, useNavigate } from 'react-router-dom'; import Loader from 'ui-component/Loader'; import { authenticationAxios } from '../../utils/AxiosConfig'; - +import { dispatchUser } from 'store/user/configUserStore'; +import { useDispatch, useSelector } from 'react-redux'; const AuthRoutesWrapper = () => { const [isLoading, setIsLoading] = useState(true); const navigate = useNavigate(); - const { user, dispatch } = useUserContext(); + const { user } = useSelector(state => state.user); + const dispatch = useDispatch(); useEffect(() => { setIsLoading(true); @@ -17,7 +18,7 @@ const AuthRoutesWrapper = () => { navigate(`/${user.type}/dashboard/home`); }else { authenticationAxios.get('/check-user', { withCredentials: true }).then(async userData => { - await dispatch({ auth: true, payload: userData.data }); + await dispatch(dispatchUser({ user: userData.data })); navigate(`/${userData.data.type}`); }).catch( () => { setIsLoading(false); diff --git a/client/src/pages/authentication/auth-forms/AuthLogin.js b/client/src/pages/authentication/auth-forms/AuthLogin.js index ae4afd2c..560bd578 100644 --- a/client/src/pages/authentication/auth-forms/AuthLogin.js +++ b/client/src/pages/authentication/auth-forms/AuthLogin.js @@ -9,12 +9,13 @@ import { TextField, Typography, } from '@mui/material'; -import { useUserContext } from 'hooks/useUserContext'; import { useNavigate } from 'react-router-dom'; // project imports import AnimateButton from 'ui-component/extended/AnimateButton'; import { authenticationAxios } from 'utils/AxiosConfig'; import { showFailureAlert } from 'utils/swal'; +import { dispatchUser } from 'store/user/configUserStore'; +import { useDispatch } from 'react-redux'; // ============================|| FIREBASE - LOGIN ||============================ // @@ -24,7 +25,7 @@ const FirebaseLogin = () => { const [isSubmitting, setIsSubmitting] = useState(false); const [password, setPassword] = useState(''); const [userName, setUserName] = useState(''); - const { dispatch } = useUserContext(); + const dispatch = useDispatch(); const navigate = useNavigate(); const handleSubmit = async (e) => { @@ -34,7 +35,7 @@ const FirebaseLogin = () => { try { const response = await authenticationAxios.post('/login/clinic', postData); const data = response.data; - dispatch({ auth: true, payload: data }); + dispatch(dispatchUser({ user: data })); if (data.reset) navigate(`/${data.type}/pages/profile`); else diff --git a/client/src/pages/chat/ChatBox.js b/client/src/pages/chat/ChatBox.js index fa3a6198..e584f203 100644 --- a/client/src/pages/chat/ChatBox.js +++ b/client/src/pages/chat/ChatBox.js @@ -1,15 +1,15 @@ import { useEffect } from 'react'; import { communicationAxios } from 'pages/utilities/AxiosConfig'; import { Paper, InputBase, List, ListItem, Typography, Card, CardActions, CardContent, CardHeader, IconButton } from '@mui/material'; -import { useUserContext } from 'hooks/useUserContext'; import { isSender, getReceiverId } from '../../utils/ChatUtils.js'; import { useChat } from 'contexts/ChatContext.js'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; import CloseIcon from '@mui/icons-material/Close'; +import { useSelector } from 'react-redux'; const ChatBox = ({ setChatOpen }) => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const userId = user.id; const { socket, selectedChat, updateChat, setSelectedChat, chatMessages, setChatMessages, newMessage, setNewMessage, } = useChat(); diff --git a/client/src/pages/chat/ChatList.js b/client/src/pages/chat/ChatList.js index edfecbb9..3518b41f 100644 --- a/client/src/pages/chat/ChatList.js +++ b/client/src/pages/chat/ChatList.js @@ -7,7 +7,6 @@ import { IconButton, CardHeader, } from '@mui/material'; -import { useUserContext } from 'hooks/useUserContext'; import ChatListCard from './ChatListCard'; import { useChat } from 'contexts/ChatContext'; import { @@ -16,9 +15,10 @@ import { } from 'utils/Constants'; import CloseIcon from '@mui/icons-material/Close'; import PerfectScrollbar from 'react-perfect-scrollbar'; +import { useSelector } from 'react-redux'; const ChatList = ({ setChatOpen }) => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const userId = user.id, userType = user.type; const { socket, setSelectedChat, chats, updateChat } = useChat(); diff --git a/client/src/pages/chat/ChatListCard.js b/client/src/pages/chat/ChatListCard.js index fc164ac4..fdaea5e3 100644 --- a/client/src/pages/chat/ChatListCard.js +++ b/client/src/pages/chat/ChatListCard.js @@ -1,10 +1,10 @@ import { CardHeader, Avatar, Badge } from '@mui/material'; import { getReceiver, getUserName } from 'utils/ChatUtils'; -import { useUserContext } from 'hooks/useUserContext'; import { useState, useEffect } from 'react'; +import { useSelector } from 'react-redux'; const ChatListCard = ({ chat }) => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const [unseen, setUnseen] = useState(0); const [name, setName] = useState(''); diff --git a/client/src/pages/chat/VideoChat.js b/client/src/pages/chat/VideoChat.js index 092e4f72..bf43ffc2 100644 --- a/client/src/pages/chat/VideoChat.js +++ b/client/src/pages/chat/VideoChat.js @@ -3,11 +3,11 @@ import { Mic, MicOff, Videocam, VideocamOff, Call, CallEnd, RingVolume } from '@ import { SocketContext } from '../../contexts/VideoChatContext'; import { useContext, useState } from 'react'; import { useParams } from 'react-router-dom'; -import { useUserContext } from 'hooks/useUserContext'; import { DOCTOR_TYPE_ENUM } from 'utils/Constants'; +import { useSelector } from 'react-redux'; const VideoChat = () => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const { name, callAccepted, answerCall, myVideo, userVideo, callEnded, stream, leaveCall, callUser, call, muteMicrophone, unmuteMicrophone, openCamera, closeCamera } = useContext(SocketContext); const ongoingCall = callAccepted && !callEnded; const { idToCall } = useParams(); diff --git a/client/src/pages/doctor/DoctorContract.js b/client/src/pages/doctor/DoctorContract.js index 23d4755a..65d5cd3b 100644 --- a/client/src/pages/doctor/DoctorContract.js +++ b/client/src/pages/doctor/DoctorContract.js @@ -3,13 +3,13 @@ import { Handshake, CloudDownload } from '@mui/icons-material'; import Swal from 'sweetalert2'; import { useEffect, useState } from 'react'; import { displayOfferText } from '../../utils/DoctorUtils'; -import { useUserContext } from 'hooks/useUserContext'; import { clinicAxios } from 'utils/AxiosConfig'; import contract from '../../utils/contract.pdf'; import { getDoctorStatus, updateDoctorStatus } from 'api/DoctorAPI'; +import { useSelector } from 'react-redux'; const DoctorContract = () => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const id = user.id; const [active, setActive] = useState(true); const [name, setName] = useState(''); diff --git a/client/src/pages/doctor/available-slots/AddAvailableSlots.js b/client/src/pages/doctor/available-slots/AddAvailableSlots.js index b90312bb..9d682fa9 100644 --- a/client/src/pages/doctor/available-slots/AddAvailableSlots.js +++ b/client/src/pages/doctor/available-slots/AddAvailableSlots.js @@ -1,7 +1,6 @@ import React, { useEffect } from 'react'; import { Typography, Button } from '@mui/material'; -import { useUserContext } from 'hooks/useUserContext'; import { isIntersect, getTodayDate } from '../../../utils/DoctorUtils'; import Swal from 'sweetalert2'; import TimeSelector from '../../../ui-component/pickers/TimeSelector'; @@ -9,12 +8,13 @@ import DateSelector from '../../../ui-component/pickers/DateSelector'; import AvailableSlotsTable from './AvailableSlotsTable'; import { addDoctorSlot, getDoctorSlots } from 'api/DoctorAPI'; import { useDoctorContext } from 'hooks/useDoctorContext'; +import { useSelector } from 'react-redux'; const DoctorAddAvailableSlots = () => { const { availableSlots, setAvailableSlots, selectedDate, setSelectedDate, selectedTime, setSelectedTime } = useDoctorContext(); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const isButtonDisabled = !selectedDate || !selectedTime || selectedDate < getTodayDate(); diff --git a/client/src/pages/doctor/doctor-patients/DoctorListofPatients.js b/client/src/pages/doctor/doctor-patients/DoctorListofPatients.js index afcd8bab..d7f02888 100644 --- a/client/src/pages/doctor/doctor-patients/DoctorListofPatients.js +++ b/client/src/pages/doctor/doctor-patients/DoctorListofPatients.js @@ -3,7 +3,6 @@ import { List } from '@mui/material'; import MainCard from 'ui-component/cards/MainCard'; import DoctorPatientCard from './DoctorPatientCard'; import DoctorPatientDialog from './DoctorPatientDialog'; -import { useUserContext } from 'hooks/useUserContext'; import { useSearch } from 'contexts/SearchContext'; import { useFilter } from 'contexts/FilterContext'; import { useLocation } from 'react-router-dom'; @@ -12,6 +11,7 @@ import { usePatientContext } from 'hooks/usePatientContext'; import { isUpcomingAppointment } from 'utils/DoctorUtils'; import { getAppointments, getDoctorPatients, getDoctor } from 'api/DoctorAPI'; import Loader from 'ui-component/Loader'; +import { useSelector } from 'react-redux'; const Patients = () => { const location = useLocation(); @@ -26,7 +26,7 @@ const Patients = () => { const { searchQuery } = useSearch(); const { filterData, updateFilter } = useFilter(); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const id = user.id; useEffect(() => { diff --git a/client/src/pages/follow-up-requests/FollowUpRequestCard.js b/client/src/pages/follow-up-requests/FollowUpRequestCard.js index e6b145ad..9895151b 100644 --- a/client/src/pages/follow-up-requests/FollowUpRequestCard.js +++ b/client/src/pages/follow-up-requests/FollowUpRequestCard.js @@ -14,7 +14,6 @@ import ClearIcon from '@mui/icons-material/Clear'; import CheckCircleIcon from '@mui/icons-material/CheckCircle'; import CancelIcon from '@mui/icons-material/Cancel'; import PendingIcon from '@mui/icons-material/Pending'; -import { useUserContext } from 'hooks/useUserContext'; import { useTheme } from '@mui/material/styles'; import AccountCircleIcon from '@mui/icons-material/AccountCircle'; import { getDay, getTime } from '../../utils/DateFormatter.js'; @@ -22,6 +21,7 @@ import { PATIENT_TYPE_ENUM } from 'utils/Constants'; import { clinicAxios } from 'utils/AxiosConfig.js'; import Swal from 'sweetalert2'; import '../../assets/css/swalStyle.css'; +import { useSelector } from 'react-redux'; const FollowUpRequestCard = ({ @@ -29,7 +29,7 @@ const FollowUpRequestCard = ({ handleUpdateFollowUpRequest }) => { const theme = useTheme(); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const titleName = user.type=='patient' ? `Dr. ${followUpRequest.doctorName}` : `Mr/Miss ${followUpRequest.patientName}`; let followUpStatus = ''; if(followUpRequest.followUpData.handled){ diff --git a/client/src/pages/follow-up-requests/FollowUpRequests.js b/client/src/pages/follow-up-requests/FollowUpRequests.js index c0ad595c..fc5f7161 100644 --- a/client/src/pages/follow-up-requests/FollowUpRequests.js +++ b/client/src/pages/follow-up-requests/FollowUpRequests.js @@ -1,15 +1,15 @@ import { useState, useEffect } from 'react'; import { clinicAxios } from 'pages/utilities/AxiosConfig'; -import { useUserContext } from 'hooks/useUserContext'; import CircularProgress from '@mui/material/CircularProgress'; import { List } from '@mui/material'; import FollowUpRequestCard from './FollowUpRequestCard.js'; import NoDataFound from '../NoDataFound.js'; +import { useSelector } from 'react-redux'; const FollowUpRequests = () => { const [followUpRequests, setFollowUpRequests] = useState([]); const [isLoading, setIsLoading] = useState(true); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); useEffect(() => { clinicAxios .get(`/appointments/follow-up-requests/${user.id}`) diff --git a/client/src/pages/health-packages/HealthPackage.js b/client/src/pages/health-packages/HealthPackage.js index 893fd89c..b6fba523 100644 --- a/client/src/pages/health-packages/HealthPackage.js +++ b/client/src/pages/health-packages/HealthPackage.js @@ -5,21 +5,20 @@ import HealthPackagesList from './HealthPackagesList'; import { Add } from '@mui/icons-material'; import AddHealthPackages from './AddHealthPackages'; import EditHealthPackages from './EditHealthPackage'; -import { useUserContext } from 'hooks/useUserContext'; import Loader from 'ui-component/Loader'; import { ADMIN_TYPE_ENUM, PATIENT_TYPE_ENUM } from 'utils/Constants'; import { getHealthPackages } from 'api/AdminAPI'; import { getPatientHealthPackage, getPatientDiscount } from 'api/PatientAPI'; import { useAdminContext } from 'hooks/useAdminContext'; import { usePatientContext } from 'hooks/usePatientContext'; +import { useSelector } from 'react-redux'; const HealthPackages = () => { const { setPackages, setSubscribedPackage, isLoading: loading, setIsLoading: setLoading, setDiscount, isPaymentOpen } = usePatientContext(); const { setOpenAddDialog: setIsAddDialogOpen } = useAdminContext(); - const { user } = useUserContext(); - + const { user } = useSelector(state => state.user); useEffect(() => { getHealthPackages().then((response) => { diff --git a/client/src/pages/health-packages/HealthPackagesList.js b/client/src/pages/health-packages/HealthPackagesList.js index e21f5505..bb77819f 100644 --- a/client/src/pages/health-packages/HealthPackagesList.js +++ b/client/src/pages/health-packages/HealthPackagesList.js @@ -2,7 +2,6 @@ import { Typography, Grid, Card, CardHeader, Box, CardActions, Button, CardConte import EditIcon from '@mui/icons-material/Edit'; import DeleteIcon from '@mui/icons-material/Delete'; import Stack from '@mui/material/Stack'; -import { useUserContext } from 'hooks/useUserContext'; import Swal from 'sweetalert2'; import { useState } from 'react'; import { ADMIN_TYPE_ENUM, PATIENT_TYPE_ENUM, PAYMENT_ITEM_TYPES } from 'utils/Constants'; @@ -12,11 +11,12 @@ import { usePatientContext } from 'hooks/usePatientContext'; import { useAdminContext } from 'hooks/useAdminContext'; import { deleteHealthPackage } from 'api/AdminAPI'; import { updateHealthPackageStatus } from 'api/PatientAPI'; +import { useSelector } from 'react-redux'; const HealthPackagesList = () => { const { packages, isPaymentOpen, setIsPaymentOpen, subscribedPackage, setSubscribedPackage, discount, setPackages } = usePatientContext(); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const [totalPrice, setTotalPrice] = useState(0); const [data, setData] = useState(null); const { setIsEditDialogOpen, setSelectedEditPackages } = useAdminContext(); diff --git a/client/src/pages/patient/family-members/AddFamilyMember.js b/client/src/pages/patient/family-members/AddFamilyMember.js index 801ca130..4a42948d 100644 --- a/client/src/pages/patient/family-members/AddFamilyMember.js +++ b/client/src/pages/patient/family-members/AddFamilyMember.js @@ -6,17 +6,17 @@ import { Button, } from '@mui/material'; import { useState } from 'react'; -import { useUserContext } from 'hooks/useUserContext'; import { updateFamilyMembers } from 'api/PatientAPI'; import FamilyMemberOptions from './FamilyMemeberOptions'; import { REGISTERED_MEMBER, UNREGISTERED_MEMBER } from 'utils/Constants'; import UnregisteredForm from './UnregisteredForm'; import RegisteredForm from './RegisteredForm'; import { usePatientContext } from 'hooks/usePatientContext'; +import { useSelector } from 'react-redux'; const AddFamilyMember = ({ isOpen, setIsOpen }) => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const { setFamilyMembers, newMember, setError } = usePatientContext(); const [value, setValue] = useState(REGISTERED_MEMBER); diff --git a/client/src/pages/patient/family-members/FamilyMembers.js b/client/src/pages/patient/family-members/FamilyMembers.js index 32d4ef23..f62424dc 100644 --- a/client/src/pages/patient/family-members/FamilyMembers.js +++ b/client/src/pages/patient/family-members/FamilyMembers.js @@ -15,11 +15,11 @@ import { import { Add, Subscriptions } from '@mui/icons-material'; import AddFamilyMember from './AddFamilyMember'; -import { useUserContext } from 'hooks/useUserContext'; import { getFamilyMembers } from 'api/PatientAPI'; import Loader from 'ui-component/Loader'; import { HealthPackageSubscription } from './HealthPackageSubscription'; import { usePatientContext } from 'hooks/usePatientContext'; +import { useSelector } from 'react-redux'; const FamilyMembers = () => { const [isAddingMember, setIsAddingMember] = useState(false); @@ -27,7 +27,7 @@ const FamilyMembers = () => { const { FamilyMembers, setFamilyMembers, isLoading, setIsLoading, setOpenPackages, setError, setNewMember, setMemberId } = usePatientContext(); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const userId = user.id; useEffect(() => { const fetch = async () => { diff --git a/client/src/pages/patient/patient-doctors/Doctors.js b/client/src/pages/patient/patient-doctors/Doctors.js index 09ed3b4f..5012da72 100644 --- a/client/src/pages/patient/patient-doctors/Doctors.js +++ b/client/src/pages/patient/patient-doctors/Doctors.js @@ -2,7 +2,6 @@ import { useState, useEffect } from 'react'; import MainCard from 'ui-component/cards/MainCard'; import DoctorList from './DoctorList.js'; import DoctorDetails from './DoctorDetails.js'; -import { useUserContext } from 'hooks/useUserContext'; import { useFilter } from 'contexts/FilterContext.js'; import { useSearch } from 'contexts/SearchContext.js'; import { isDateInAvailableSlots } from 'utils/AppointmentUtils.js'; @@ -11,8 +10,9 @@ import { useDoctorContext } from 'hooks/useDoctorContext.js'; import { usePatientContext } from 'hooks/usePatientContext.js'; import { getDoctors } from 'api/DoctorAPI.js'; import { getPatient, getPatientHealthPackage } from 'api/PatientAPI.js'; +import { useSelector } from 'react-redux'; const Doctors = () => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const patientID = user.id; const { setDoctors, originalDoctors, setOriginalDoctors, setSelectedDoctor } = useDoctorContext(); const { setLoggedInPatient, setLoggedInPatientHealthPackage } = usePatientContext(); diff --git a/client/src/pages/payment/Checkout.js b/client/src/pages/payment/Checkout.js index dcbe3c40..cee8b02e 100644 --- a/client/src/pages/payment/Checkout.js +++ b/client/src/pages/payment/Checkout.js @@ -7,9 +7,9 @@ import { import { paymentElementOptions, paymentStatus } from '../../utils/PaymentUtils'; import { Button } from '@mui/material'; import { useNavigate, useLocation } from 'react-router-dom'; -import { useUserContext } from 'hooks/useUserContext'; import { PAYMENT_ITEM_TYPES } from '../../utils/Constants'; import { showFailureAlert } from 'utils/swal'; +import { useSelector } from 'react-redux'; export default function CheckoutForm({ item, type, selectedDoctor }) { const stripe = useStripe(); @@ -18,7 +18,7 @@ export default function CheckoutForm({ item, type, selectedDoctor }) { const [isLoading, setIsLoading] = useState(false); const location = useLocation(); const queryParams = new URLSearchParams(location.search); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const navigate = useNavigate(); diff --git a/client/src/pages/prescriptions/PrescriptionDetails.js b/client/src/pages/prescriptions/PrescriptionDetails.js index 175a3fce..9a0e4322 100644 --- a/client/src/pages/prescriptions/PrescriptionDetails.js +++ b/client/src/pages/prescriptions/PrescriptionDetails.js @@ -10,7 +10,6 @@ import { Divider, Tooltip } from '@mui/material'; -import { useUserContext } from 'hooks/useUserContext'; import dayjs from 'dayjs'; import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; @@ -20,6 +19,7 @@ import { formatMedicines } from '../../utils/PrescriptionUtils'; import { OK_STATUS_CODE } from 'utils/Constants'; import { patientAxios } from 'utils/AxiosConfig'; import { AddMedicine } from './AddMedicine'; +import { useSelector } from 'react-redux'; const PrescriptionDetails = ({ selectedPrescription, setSelectedPrescription, @@ -27,7 +27,7 @@ const PrescriptionDetails = ({ handleDialogClose, medicines, }) => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const [addMode, setAddMode] = useState(false); const [selectedMedicine, setSelectedMedicine] = useState(null); const formattedMedicines = formatMedicines(medicines, selectedPrescription); diff --git a/client/src/pages/prescriptions/PrescriptionItem.js b/client/src/pages/prescriptions/PrescriptionItem.js index a796443d..23e74b87 100644 --- a/client/src/pages/prescriptions/PrescriptionItem.js +++ b/client/src/pages/prescriptions/PrescriptionItem.js @@ -16,15 +16,15 @@ import dayjs from 'dayjs'; import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import prescrptionImage from '../utilities/prescription.png'; -import { useUserContext } from 'hooks/useUserContext'; import { PATIENT_BASE_URL } from 'utils/Constants'; +import { useSelector } from 'react-redux'; const PrescriptionItem = ({ prescription, handleClicking, handleEditButtonClick, }) => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const [doctor, setDoctor] = useState({}); const [Loading, setLoading] = useState(true); useEffect(() => { diff --git a/client/src/pages/prescriptions/Prescriptions.js b/client/src/pages/prescriptions/Prescriptions.js index 6be03a5e..919127a6 100644 --- a/client/src/pages/prescriptions/Prescriptions.js +++ b/client/src/pages/prescriptions/Prescriptions.js @@ -7,7 +7,6 @@ import MainCard from '../../ui-component/cards/MainCard'; import { updatePrescription, createPrescription } from 'api/DoctorAPI'; import { getPatientPrescription, getPatient } from 'api/PatientAPI'; import PrescriptionDetails from './PrescriptionDetails'; -import { useUserContext } from 'hooks/useUserContext'; import { useFilter } from 'contexts/FilterContext'; import { DATE_FILTER_ARRAY, @@ -21,11 +20,12 @@ import { Fab, Button } from '@mui/material'; import AddIcon from '@mui/icons-material/Add'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; import { useLocation, useNavigate } from 'react-router-dom'; +import { useSelector } from 'react-redux'; const Prescriptions = () => { const navigate = useNavigate(); const location = useLocation(); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const patientID = user.type === PATIENT_TYPE_ENUM ? user.id : useParams().patientId; const { filterData, updateFilter } = useFilter(); diff --git a/client/src/pages/profile/Account.js b/client/src/pages/profile/Account.js index ac2a92ed..7cafc319 100644 --- a/client/src/pages/profile/Account.js +++ b/client/src/pages/profile/Account.js @@ -16,7 +16,6 @@ import { import ArrowBackIcon from '@mui/icons-material/ArrowBack'; import DcotorAccountProfileDetails from './account-data/DoctorAccountProfileDetails'; import PatientAccountProfileDetails from './account-data/PatientAccountProfileDetails'; -import { useUserContext } from 'hooks/useUserContext'; import { DOCTOR_TYPE_ENUM, PATIENT_TYPE_ENUM } from 'utils/Constants'; import { useState } from 'react'; import MedicalHistory from './MedicalHistory'; @@ -27,11 +26,12 @@ import { useParams } from 'react-router'; import DoctorContract from '../doctor/DoctorContract'; import { showFailureAlert, showSuccessAlert } from 'utils/swal'; +import { useSelector } from 'react-redux'; const Page = () => { const navigate = useNavigate(); const location = useLocation(); const { patientId } = useParams(); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const [password, setPassword] = useState(''); const [strength, setStrength] = useState(0); const [level, setLevel] = useState(); diff --git a/client/src/pages/profile/AccountProfile.js b/client/src/pages/profile/AccountProfile.js index 3d95ae7f..42fcb526 100644 --- a/client/src/pages/profile/AccountProfile.js +++ b/client/src/pages/profile/AccountProfile.js @@ -8,12 +8,12 @@ import { Divider, Typography } from '@mui/material'; -import { useUserContext } from 'hooks/useUserContext'; +import { useSelector } from 'react-redux'; const AccountProfile = () => { - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); return ( diff --git a/client/src/pages/profile/MedicalHistory.js b/client/src/pages/profile/MedicalHistory.js index 15368e4f..621f8bd8 100644 --- a/client/src/pages/profile/MedicalHistory.js +++ b/client/src/pages/profile/MedicalHistory.js @@ -2,17 +2,17 @@ import { Stack, Unstable_Grid2 as Grid, List, ListItemButton, ListItemText, List import { useState, useEffect } from 'react'; import Delete from '@mui/icons-material/Delete'; import { patientAxios } from 'utils/AxiosConfig'; -import { useUserContext } from 'hooks/useUserContext'; import Loader from 'ui-component/Loader'; import { Attachment } from '@mui/icons-material'; import Swal from 'sweetalert2'; import { PATIENT_BASE_URL } from 'utils/Constants'; import { showFailureAlert, showSuccessAlert } from 'utils/swal'; +import { useSelector } from 'react-redux'; const MedicalHistory = ({ patientId }) => { const [documents, setDocuments] = useState(); const [loading, setLoading] = useState(true); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const userId = patientId ? patientId : user.id; const [title, setTitle] = useState(''); const [selectedFile, setSelectedFile] = useState(null); diff --git a/client/src/pages/profile/account-data/DoctorAccountProfileDetails.js b/client/src/pages/profile/account-data/DoctorAccountProfileDetails.js index f6cf8fd0..26c86041 100644 --- a/client/src/pages/profile/account-data/DoctorAccountProfileDetails.js +++ b/client/src/pages/profile/account-data/DoctorAccountProfileDetails.js @@ -10,11 +10,11 @@ import { TextField, Unstable_Grid2 as Grid, } from '@mui/material'; -import { useUserContext } from 'hooks/useUserContext'; import format from 'date-fns/format'; import { clinicAxios } from '../../../utils/AxiosConfig'; import Loader from 'ui-component/Loader'; import { showFailureAlert, showSuccessAlert } from 'utils/swal'; +import { useSelector } from 'react-redux'; export const DoctorAccountProfileDetails = () => { const [values, setValues] = useState({ @@ -29,7 +29,7 @@ export const DoctorAccountProfileDetails = () => { walletAmount: '', }); const [loading, setLoading] = useState(true); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); useEffect(() => { const getPatientsURL = '/doctor/' + user.id; // let user; diff --git a/client/src/pages/profile/account-data/PatientAccountProfileDetails.js b/client/src/pages/profile/account-data/PatientAccountProfileDetails.js index 648b3d7e..057afbe8 100644 --- a/client/src/pages/profile/account-data/PatientAccountProfileDetails.js +++ b/client/src/pages/profile/account-data/PatientAccountProfileDetails.js @@ -8,12 +8,12 @@ import { TextField, Unstable_Grid2 as Grid, } from '@mui/material'; -import { useUserContext } from 'hooks/useUserContext'; import format from 'date-fns/format'; import { patientAxios } from 'utils/AxiosConfig'; import Loader from 'ui-component/Loader'; import { PATIENT_TYPE_ENUM } from 'utils/Constants'; import { useParams } from 'react-router'; +import { useSelector } from 'react-redux'; export const PatientAccountProfileDetails = () => { const [values, setValues] = useState({ name: '', @@ -28,7 +28,7 @@ export const PatientAccountProfileDetails = () => { walletAmount: '', }); const [loading, setLoading] = useState(true); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const isPatient = user.type === PATIENT_TYPE_ENUM; const { patientId } = useParams(); const userId = isPatient ? user.id : patientId; diff --git a/client/src/routes/AdminRoutes.js b/client/src/routes/AdminRoutes.js index 6ebb80f3..5d88c77a 100644 --- a/client/src/routes/AdminRoutes.js +++ b/client/src/routes/AdminRoutes.js @@ -16,7 +16,7 @@ const Account = Loadable(lazy(() => import('pages/profile/Account'))); const LazyPackages = Loadable( lazy(() => import('pages/health-packages/HealthPackage')), ); -const LazyHome = Loadable(lazy(() => import('pages/home/Home'))); +const LazyHome = Loadable(lazy(() => import('pages/Home/Home'))); // utilities routing const UtilsTypography = Loadable( lazy(() => import('pages/utilities/Typography')), diff --git a/client/src/routes/DoctorRoutes.js b/client/src/routes/DoctorRoutes.js index ee79be58..58428b6d 100644 --- a/client/src/routes/DoctorRoutes.js +++ b/client/src/routes/DoctorRoutes.js @@ -12,7 +12,7 @@ const LazyDoctorListofPatients = Loadable( lazy(() => import('pages/doctor/doctor-patients/DoctorListofPatients')) ); const LazyAppointments = Loadable( - lazy(() => import('pages/appointment/Appointment')) + lazy(() => import('pages/Appointment/Appointment')) ); const LazyFollowUpRequests = Loadable( lazy(() => import('pages/follow-up-requests/FollowUpRequests')), @@ -27,7 +27,7 @@ const LazyPrescriptions = Loadable( const LazyChat = Loadable(lazy(() => import('pages/chat/Chat'))); -const LazyHome = Loadable(lazy(() => import('pages/home/Home'))); +const LazyHome = Loadable(lazy(() => import('pages/Home/Home'))); const Account = Loadable(lazy(() => import('pages/profile/Account'))); const LazyVideoChat = Loadable(lazy(() => import('pages/chat/VideoChat.js'))); diff --git a/client/src/routes/PatientRoutes.js b/client/src/routes/PatientRoutes.js index 4f950074..6bce5368 100644 --- a/client/src/routes/PatientRoutes.js +++ b/client/src/routes/PatientRoutes.js @@ -17,7 +17,7 @@ import PatientProvider from 'contexts/PatientContext'; import AdminProvider from 'contexts/AdminContext'; const LazyClinicDoctors = Loadable(lazy(() => import('pages/patient/patient-doctors/Doctors'))); const LazyAppointments = Loadable( - lazy(() => import('pages/appointment/Appointment')), + lazy(() => import('pages/Appointment/Appointment')), ); const LazyFollowUpRequests = Loadable( lazy(() => import('pages/follow-up-requests/FollowUpRequests')), @@ -28,7 +28,7 @@ const LazyAccount = Loadable(lazy(() => import('pages/profile/Account'))); //TOD const LazyFamilyMembers = Loadable(lazy(() => import('pages/patient/family-members/FamilyMembers.js'))); const LazyVideoChat = Loadable(lazy(() => import('pages/chat/VideoChat.js'))); const LazyChat = Loadable(lazy(() => import('pages/chat/Chat'))); -const LazyHome = Loadable(lazy(() => import('pages/home/Home'))); +const LazyHome = Loadable(lazy(() => import('pages/Home/Home'))); // utilities routing const UtilsTypography = Loadable( diff --git a/client/src/store/index.js b/client/src/store/index.js index 0fcffa80..e8416f6b 100644 --- a/client/src/store/index.js +++ b/client/src/store/index.js @@ -1,9 +1,8 @@ -import { createStore } from 'redux'; import reducer from './reducer'; +import { configureStore } from '@reduxjs/toolkit'; -// ==============================|| REDUX - MAIN STORE ||============================== // +// // ==============================|| REDUX - MAIN STORE ||============================== // -const store = createStore(reducer); -const persister = ''; - -export { store, persister }; +export const store = configureStore({ + reducer +}); diff --git a/client/src/store/reducer.js b/client/src/store/reducer.js index 585fbb2e..210f23e5 100644 --- a/client/src/store/reducer.js +++ b/client/src/store/reducer.js @@ -2,11 +2,13 @@ import { combineReducers } from 'redux'; // reducer import import customizationReducer from './customizationReducer'; +import userReducer from './user/configUserStore'; // ==============================|| COMBINE REDUCER ||============================== // const reducer = combineReducers({ - customization: customizationReducer + customization: customizationReducer, + user: userReducer }); export default reducer; diff --git a/client/src/store/user/configUserStore.js b/client/src/store/user/configUserStore.js new file mode 100644 index 00000000..4ffdc25c --- /dev/null +++ b/client/src/store/user/configUserStore.js @@ -0,0 +1,22 @@ +import { createSlice } from '@reduxjs/toolkit'; +//store +const initUser = { + user: null +}; + +// actions +function userReducer (state = initUser, action) { + state.user = action.payload.user; +} + +const userSlice = createSlice({ + name: 'userData', + initialState:initUser, + reducers: { + dispatchUser: userReducer + } +}); + + +export const { dispatchUser } = userSlice.actions; +export default userSlice.reducer; \ No newline at end of file diff --git a/client/src/utils/PaymentOptions.js b/client/src/utils/PaymentOptions.js index 6c925a36..e218eaf1 100644 --- a/client/src/utils/PaymentOptions.js +++ b/client/src/utils/PaymentOptions.js @@ -3,7 +3,6 @@ import Swal from 'sweetalert2'; import { useNavigate } from 'react-router-dom'; import { successfulPayment } from './PaymentUtils'; import { React, useState, useEffect } from 'react'; -import { useUserContext } from 'hooks/useUserContext'; import { Dialog, DialogTitle, @@ -26,11 +25,12 @@ import CreditCardIcon from '@mui/icons-material/CreditCard'; import AccountBalanceWalletIcon from '@mui/icons-material/AccountBalanceWallet'; import { usePayment } from 'contexts/PaymentContext'; import { showSuccessAlert } from './swal'; +import { useSelector } from 'react-redux'; export const ChoosePayment = ({ isAddDialogOpen, setIsAddDialogOpen, items, amountToPay, type, selectedDoctor }) => { const [amountInWallet, setAmountInWallet] = useState(0); const navigate = useNavigate(); - const { user } = useUserContext(); + const { user } = useSelector(state => state.user); const userId = user.id; const { setPaymentDone } = usePayment(); diff --git a/client/yarn.lock b/client/yarn.lock index 77b34c5c..e2951b8c 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -2368,6 +2368,16 @@ resolved "https://registry.npmjs.org/@react-dnd/shallowequal/-/shallowequal-4.0.2.tgz" integrity sha512-/RVXdLvJxLg4QKvMoM5WlwNR9ViO9z8B/qPcc+C0Sa/teJY7QG7kJ441DwzOjMYEY7GmU4dj5EcGHIkKZiQZCA== +"@reduxjs/toolkit@^2.0.1": + version "2.0.1" + resolved "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.0.1.tgz" + integrity sha512-fxIjrR9934cmS8YXIGd9e7s1XRsEU++aFc9DVNMFMRTM5Vtsg2DCRMj21eslGtDt43IUf9bJL3h5bwUlZleibA== + dependencies: + immer "^10.0.3" + redux "^5.0.0" + redux-thunk "^3.1.0" + reselect "^5.0.1" + "@rollup/plugin-babel@^5.2.0": version "5.3.1" resolved "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz" @@ -6723,6 +6733,11 @@ ignore@^5.2.0: resolved "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz" integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== +immer@^10.0.3: + version "10.0.3" + resolved "https://registry.npmjs.org/immer/-/immer-10.0.3.tgz" + integrity sha512-pwupu3eWfouuaowscykeckFmVTpqbzW+rXFCX8rQLkZzM9ftBmU/++Ra+o+L27mz03zJTlyV4UUr+fdKNffo4A== + immer@^9.0.7: version "9.0.18" resolved "https://registry.npmjs.org/immer/-/immer-9.0.18.tgz" @@ -10344,10 +10359,10 @@ react-perfect-scrollbar@^1.5.8: perfect-scrollbar "^1.5.0" prop-types "^15.6.1" -react-redux@^8.0.2: - version "8.0.5" - resolved "https://registry.npmjs.org/react-redux/-/react-redux-8.0.5.tgz" - integrity sha512-Q2f6fCKxPFpkXt1qNRZdEDLlScsDWyrgSj0mliK59qU6W5gvBiKkdMEG2lJzhd1rCctf0hb6EtePPLZ2e0m1uw== +"react-redux@^7.2.1 || ^8.1.3 || ^9.0.0", react-redux@^8.1.3: + version "8.1.3" + resolved "https://registry.npmjs.org/react-redux/-/react-redux-8.1.3.tgz" + integrity sha512-n0ZrutD7DaX/j9VscF+uTALI3oUPa/pO4Z3soOBIjuRn/FzVu6aehhysxZCLi6y7duMf52WNZGMl7CtuK5EnRw== dependencies: "@babel/runtime" "^7.12.1" "@types/hoist-non-react-statics" "^3.3.1" @@ -10441,7 +10456,7 @@ react-transition-group@^4.4.5: loose-envify "^1.4.0" prop-types "^15.6.2" -"react@^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^15.3.0 || 16 || 17 || 18", "react@^16.8 || ^17.0 || ^18.0", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^16.x || 17.x || 18.x", "react@^17.0.0 || ^18.0.0", react@^18.0.0, react@^18.2.0, "react@>= 0.14.0", "react@>= 16", "react@>= 16.14", react@>=0.13, react@>=16.3.3, react@>=16.6.0, react@>=16.8, "react@>=16.8 || ^17.0.0 || ^18.0.0", react@>=16.8.0: +"react@^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^15.3.0 || 16 || 17 || 18", "react@^16.8 || ^17.0 || ^18.0", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^16.9.0 || ^17.0.0 || ^18", "react@^16.x || 17.x || 18.x", "react@^17.0.0 || ^18.0.0", react@^18.0.0, react@^18.2.0, "react@>= 0.14.0", "react@>= 16", "react@>= 16.14", react@>=0.13, react@>=16.3.3, react@>=16.6.0, react@>=16.8, "react@>=16.8 || ^17.0.0 || ^18.0.0", react@>=16.8.0: version "18.2.0" resolved "https://registry.npmjs.org/react/-/react-18.2.0.tgz" integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ== @@ -10529,13 +10544,23 @@ redent@^3.0.0: indent-string "^4.0.0" strip-indent "^3.0.0" -redux@^4, redux@^4.2.0: +redux-thunk@^3.1.0: + version "3.1.0" + resolved "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz" + integrity sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw== + +"redux@^4 || ^5.0.0-beta.0", redux@^4.2.0: version "4.2.0" resolved "https://registry.npmjs.org/redux/-/redux-4.2.0.tgz" integrity sha512-oSBmcKKIuIR4ME29/AeNUnl5L+hvBq7OaJWzaptTQJAntaPvxIJqfnjbaEiCzzaIz+XmVILfqAM3Ob0aXLPfjA== dependencies: "@babel/runtime" "^7.9.2" +redux@^5.0.0: + version "5.0.1" + resolved "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz" + integrity sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w== + reflect.getprototypeof@^1.0.4: version "1.0.4" resolved "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.4.tgz" @@ -10641,6 +10666,11 @@ requires-port@^1.0.0: resolved "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz" integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ== +reselect@^5.0.1: + version "5.0.1" + resolved "https://registry.npmjs.org/reselect/-/reselect-5.0.1.tgz" + integrity sha512-D72j2ubjgHpvuCiORWkOUxndHJrxDaSolheiz5CO+roz8ka97/4msh2E8F5qay4GawR5vzBt5MkbDHT+Rdy/Wg== + resolve-cwd@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz"