Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot fixes #137

Merged
merged 2 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions client/src/api/AdminAPI.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { authenticationAxios, clinicAxios } from 'utils/AxiosConfig';

export const getAdmins = async () => {
const response = await clinicAxios.get('/admins');
return response.data;
};

export const addAdmin = async (newAdmin) => {

const response = await authenticationAxios.post('/admins/clinic', JSON.stringify(newAdmin), {
Expand Down
46 changes: 45 additions & 1 deletion client/src/api/DoctorAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import {
PHARMACY_MONGO_ID,
} from 'utils/Constants';


export const getDoctor = async (id) => {
const response = await clinicAxios.get(`/doctor/${id}`);
return response.data;
};

export const getDoctors = async () => {
const response = await clinicAxios.get('/doctors');
return response.data;
Expand All @@ -22,8 +28,46 @@ export const addDoctor = async (doctorReq) => {
return response.data;
};

export const getDoctorSlots = async (user) => {
const response = await clinicAxios.get(`/doctors/${user.id}/slots`);
return response.data;
};

export const addDoctorSlot = async (from, user) => {
const response = await clinicAxios.post(`/doctors/${user.id}/slots`, { from });
return response.data;
};

export const getAppointments = async (id) => {
const response = await clinicAxios.get(`/appointments/${id}`);
return response.data;
};

export const addAppointment = async (appointment) => {
const response = await clinicAxios
.post('/appointments', { items: appointment });
return response.data;
};

export const getDoctorPatients = async (id) => {
const response = await clinicAxios
.get('/doctors/' + id + '/patients');
return response.data;
};

export const getDoctorStatus = async (id) => {
const response = await clinicAxios.get('doctors/' + id + '/status');
return response.data;
};

export const updateDoctorStatus = async (id) => {
const response = await clinicAxios.post('doctors/' + id + '/status');
return response.data;

};

export const addDoctorChat = async (doctor) => {
communicationAxios.post('/chat', {
await communicationAxios.post('/chat', {
chat: {
chatName: 'Pharmacy',
users: [
Expand Down
11 changes: 11 additions & 0 deletions client/src/api/PatientAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { patientAxios, clinicAxios } from 'utils/AxiosConfig';

export const getPatients = async () => {
const response = await patientAxios.get('/patients');
return response.data;
};

export const deletePatient = async (patientToDelete) => {
const response = await clinicAxios.delete(`/patients/${patientToDelete}`);
return response.data;
};
18 changes: 14 additions & 4 deletions client/src/contexts/DoctorContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,21 @@ const DoctorProvider = ({ children }) => {
const [doctorIsBeingDeleted, setDoctorIsBeingDeleted] = useState(false);
const [doctorDeleted, setDoctorDeleted] = useState(false);
const [errorMessage, setErrorMessage] = useState('');

const [availableSlots, setAvailableSlots] = useState([]);
const [selectedDate, setSelectedDate] = useState(null);
const [selectedTime, setSelectedTime] = useState(null);
const [patients, setPatients] = useState([]);
const [originalPatients, setOriginalPatients] = useState([]);
const [appointments, setAppointments] = useState([]);
const [loggedInDoctor, setLoggedInDoctor] = useState(null);
const [selectedPatient, setSelectedPatient] = useState(null);

const contextValue = {
doctors, setDoctors, isLoading, setIsLoading, confirmDeleteDialogOpen, setConfirmDeleteDialogOpen,
doctorToDelete, setDoctorToDelete, doctorIsBeingDeleted, setDoctorIsBeingDeleted, doctorDeleted,
setDoctorDeleted, errorMessage, setErrorMessage
doctors, setDoctors, isLoading, setIsLoading, confirmDeleteDialogOpen, setConfirmDeleteDialogOpen, setSelectedTime,
doctorToDelete, setDoctorToDelete, doctorIsBeingDeleted, setDoctorIsBeingDeleted, doctorDeleted, selectedTime,
setDoctorDeleted, errorMessage, setErrorMessage, availableSlots, setAvailableSlots, selectedDate, setSelectedDate,
patients, setPatients, originalPatients, setOriginalPatients, appointments, setAppointments, loggedInDoctor, setLoggedInDoctor,
selectedPatient, setSelectedPatient
};

return (
Expand Down
29 changes: 29 additions & 0 deletions client/src/contexts/PatientContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { createContext, useState } from 'react';

export const PatientContext = createContext();

const PatientProvider = ({ children }) => {

const [patients, setPatients] = useState([]);
const [isLoading, setIsLoading] = useState(true);
const [confirmDeleteDialogOpen, setConfirmDeleteDialogOpen] = useState(false);
const [patientToDelete, setPatientToDelete] = useState(null);
const [patientIsBeingDeleted, setPatientIsBeingDeleted] = useState(false);
const [patientDeleted, setPatientDeleted] = useState(false);
const [errorMessage, setErrorMessage] = useState('');
const [selectedPatient, setSelectedPatient] = useState(null);

const contextValue = {
patients, setPatients, isLoading, setIsLoading, confirmDeleteDialogOpen, setConfirmDeleteDialogOpen, patientToDelete, setPatientToDelete,
patientIsBeingDeleted, setPatientIsBeingDeleted, patientDeleted, setPatientDeleted, errorMessage, setErrorMessage, selectedPatient,
setSelectedPatient
};

return (
<PatientContext.Provider value={contextValue}>
{children}
</PatientContext.Provider>
);
};

export default PatientProvider;
8 changes: 8 additions & 0 deletions client/src/hooks/usePatientContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

import { PatientContext } from '../contexts/PatientContext';
import { useContext } from 'react';

export const usePatientContext = () => {
const context = useContext(PatientContext);
return context;
};
35 changes: 17 additions & 18 deletions client/src/layout/MainLayout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import { SearchProvider } from 'contexts/SearchContext';
import { FilterProvider } from 'contexts/FilterContext';
import { useUserContext } from 'hooks/useUserContext';
import { useEffect } from 'react';
import { clinicAxios } from 'utils/AxiosConfig';
import { ContextProvider } from 'contexts/VideoChatContext';
import { getDoctorStatus } from 'api/DoctorAPI';
// styles
const Main = styled('main', { shouldForwardProp: (prop) => prop !== 'open' })(
({ theme, open }) => ({
Expand Down Expand Up @@ -81,10 +81,9 @@ const MainLayout = ({ userType }) => {
navigate(`/${user.type}/dashboard/home`);
}
if (isDoctor) {
clinicAxios
.get('/doctors/' + id + '/status')
getDoctorStatus(id)
.then((res) => {
const status = res.data.status;
const status = res.status;
if (user && isDoctor && !status) {
navigate('/doctor/pages/profile');
Swal.fire({ title: 'Pending Offer', icon: 'info', text: 'Please Accept the offer first' });
Expand Down Expand Up @@ -140,20 +139,20 @@ const MainLayout = ({ userType }) => {
/>
)}

{/* main content */}
<Main theme={theme} open={leftDrawerOpened} sx={{ position: 'relative' }}>
{(!user || user.type != userType) && (
<h1>not autherized!!</h1>
)}
{user && user.type == userType &&
user.type === 'admin' ? <Outlet /> :
<Chat>
<div>
<Outlet />
</div>
</Chat>
}
</Main>
{/* main content */}
<Main theme={theme} open={leftDrawerOpened} sx={{ position: 'relative' }}>
{(!user || user.type != userType) && (
<h1>not autherized!!</h1>
)}
{user && user.type == userType &&
user.type === 'admin' ? <Outlet /> :
<Chat>
<div>
<Outlet />
</div>
</Chat>
}
</Main>

{/* <Customization /> */}
</Box>
Expand Down
62 changes: 0 additions & 62 deletions client/src/pages/DoctorAddAvailableSlots/AvailableSlotsTable.js

This file was deleted.

55 changes: 0 additions & 55 deletions client/src/pages/Wallet/WalletAmount.js

This file was deleted.

25 changes: 2 additions & 23 deletions client/src/pages/admin/admin-control/AdminDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,8 @@ import {
} from '@mui/material';
import { styled } from '@mui/system';
import { useAdminContext } from 'hooks/useAdminContext';

const useStyles = styled(() => ({
container: {
display: 'flex',
justifyContent: 'space-around',
alignItems: 'center',
flexDirection: 'row',
marginBottom: '5em',
},
infoContainer: {
display: 'flex',
flexDirection: 'column',
gap: '0.7em',
},
emailContainer: {
display: 'flex',
alignItems: 'center',
flexDirection: 'row',
},
iconMargin: {
marginRight: '0.4em',
},
}));
import { commonStyles } from 'ui-component/CommonStyles';
const useStyles = styled(() => commonStyles);

const AdminDetails = () => {
const classes = useStyles();
Expand Down
Loading
Loading