Skip to content

Commit

Permalink
Merge pull request #22 from advanced-computer-lab-2023/VCP-16
Browse files Browse the repository at this point in the history
Vcp 16 frontend
  • Loading branch information
YehiaFarghaly authored Oct 12, 2023
2 parents badaaf7 + 9e319c1 commit 3c94786
Show file tree
Hide file tree
Showing 11 changed files with 241 additions and 10,844 deletions.
Binary file added client/src/assets/images/icons/DoctorIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 28 additions & 10 deletions client/src/layout/MainLayout/Sidebar/MenuList/menu-items/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import {
IconVaccineBottle,
IconEmergencyBed,
IconStethoscope,
IconPrescription
} from '@tabler/icons';
import AdminPanelSettingsOutlinedIcon from '@mui/icons-material/AdminPanelSettingsOutlined';
import MedicationIcon from '@mui/icons-material/Medication';
import FamilyRestroomIcon from '@mui/icons-material/FamilyRestroom';
import IconPrescription from '@tabler/icons';
// constant
const icons = {
IconKey,
IconVaccineBottle,
AdminPanelSettingsOutlinedIcon,
IconEmergencyBed,
IconStethoscope,
MedicationIcon,
FamilyRestroomIcon,
IconPrescription
};
Expand Down Expand Up @@ -102,19 +104,35 @@ const pages = {
{
id: 'prescriptions',
title: 'Prescriptions',
type: 'item',
icon: icons.IconPrescription,
url: '/pages/prescriptions',
target: false
type: 'item',
icon: icons.IconPrescription,
url: '/pages/prescriptions',
target: false
},
{
id: 'Packages',
title: 'Health Packages',
type: 'item',
icon: icons.SubscriptionsIcon,
url: '/pages/packages',
target: false
}
type: 'item',
icon: icons.SubscriptionsIcon,
url: '/pages/packages',
target: false
},
{
id: 'clinic',
title: 'Clinic',
type: 'collapse',
icon: icons.MedicationIcon,
children: [
{
id: 'doctors',
title: 'Doctors',
type: 'item',
icon: icons.IconStethoscope,
url: '/pages/clinic/doctors',
target: false,
},
],
},
]
};

Expand Down
37 changes: 37 additions & 0 deletions client/src/pages/Doctors/DoctorCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ListItemButton, ListItemText, ListItemAvatar } from '@mui/material';
import DoctorIcon from '../../assets/images/icons/DoctorIcon.png';

const calcPrice = async (price) => {
const userDiscount = 0.2; // needs user to get the id to get the discount
const priceWithDiscount = price * (1 - userDiscount);
const final = 1.1 * priceWithDiscount;
return final;
};

const DoctorCard = ({ doctor, setSelectedDoctor }) => {
const price = calcPrice(doctor.hourlyRate);
return (
<ListItemButton onClick={() => setSelectedDoctor(doctor)}>
<ListItemAvatar sx={{ paddingRight: '2%' }}>
<img
src={DoctorIcon}
alt={doctor.name}
width='40'
height='40'
/>
</ListItemAvatar>
<ListItemText
primary={doctor.userData.name}
secondary={doctor.speciality}
sx={{
width: '60%',
lineHeight: '1.5em',
maxHeight: '3em',
}}
/>
<ListItemText sx={{ paddingLeft: '2%' }} primary={`$${price}`} />
</ListItemButton>
);
};

export default DoctorCard;
89 changes: 89 additions & 0 deletions client/src/pages/Doctors/DoctorDetails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React from 'react';
import {
Dialog,
DialogTitle,
DialogContent,
Typography,
DialogActions,
Button,
} from '@mui/material';
// import { DateField } from '@mui/x-date-pickers/DateField';
import DoctorIcon from '../../assets/images/icons/DoctorIcon.png';

const DoctorDetails = ({ selectedDoctor, handleDialogClose }) => {
return (
<Dialog
open={selectedDoctor}
onClose={handleDialogClose}
PaperProps={{
sx: { minWidth: window.outerWidth > 800 ? 500 : 300 },
}}
>
{selectedDoctor && (
<>
<DialogTitle align='center' variant='h2'>
{selectedDoctor.name}
</DialogTitle>
<DialogContent>
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'column',
}}
>
<img
src={DoctorIcon}
alt={selectedDoctor.userData.name}
width='100'
height='100'
/>
</div>
<Typography variant='subtitle1'>Name:</Typography>
<Typography variant='body1'>
{selectedDoctor.userData.name}
</Typography>
<Typography variant='subtitle1'>Speciality:</Typography>
<Typography variant='body1'>
{selectedDoctor.speciality}
</Typography>
<Typography variant='subtitle1'>
Affiliation:
</Typography>
<Typography variant='body1'>
{selectedDoctor.affiliation}
</Typography>
<Typography variant='subtitle1'>
Educational Background:
</Typography>
<Typography variant='body1'>
{selectedDoctor.educationalBackground}
</Typography>
<Typography variant='subtitle1'>
Hourly Price:
</Typography>{' '}
{/* need user id to get discount */}
<Typography variant='body1'>
${selectedDoctor.hourlyRate}
</Typography>
<Typography variant='subtitle1'>
Available Slots:
</Typography>
{/* we need to view available slots properly */}
<Typography variant='body1'>
{selectedDoctor.availableSlots.toString()}
</Typography>
</DialogContent>
<DialogActions>
<Button onClick={handleDialogClose} color='primary'>
Close
</Button>
</DialogActions>
</>
)}
</Dialog>
);
};

export default DoctorDetails;
23 changes: 23 additions & 0 deletions client/src/pages/Doctors/DoctorList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { List } from '@mui/material';
import DoctorCard from './DoctorCard.js';

const DoctorList = ({ doctors, setSelectedDoctor }) => {
return (
<List>
{Array.isArray(doctors) &&
doctors.map((doctor, index) => (
<div key={index}>
<div key={index}>
<DoctorCard
doctor={doctor}
setSelectedDoctor={setSelectedDoctor}
></DoctorCard>
</div>
</div>
))}
</List>
);
};

export default DoctorList;
39 changes: 39 additions & 0 deletions client/src/pages/Doctors/Doctors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useState, useEffect } from 'react';
import { doctorAxios } from 'pages/utilities/AxiosConfig';
import MainCard from 'ui-component/cards/MainCard';
import DoctorList from './DoctorList.js';
import DoctorDetails from './DoctorDetails.js';

const Doctors = () => {
const [doctors, setDoctors] = useState([]);
const [selectedDoctor, setSelectedDoctor] = useState(null);
useEffect(() => {
doctorAxios
.get('/doctors')
.then((response) => {
setDoctors(response.data);
})
.catch((error) => {
console.log(error);
});
}, []);

const handleDialogClose = () => {
setSelectedDoctor(null);
};

return (
<MainCard title='Doctors'>
<DoctorList
doctors={doctors}
setSelectedDoctor={setSelectedDoctor}
/>
<DoctorDetails
selectedDoctor={selectedDoctor}
handleDialogClose={handleDialogClose}
/>
</MainCard>
);
};

export default Doctors;
10 changes: 10 additions & 0 deletions client/src/routes/MainRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const LazyAdmins = Loadable(lazy(() => import('pages/Admins')));
const LazyPatients = Loadable(lazy(() => import('pages/Patients')));
const LazyDoctors = Loadable(lazy(() => import('pages/Doctors')));
const LazyPackages = Loadable(lazy(() => import('pages/HealthPackages/HealthPackage')));
const LazyClinicDoctors = Loadable(lazy(() => import('pages/Doctors/Doctors')));

// utilities routing
const UtilsTypography = Loadable(
Expand Down Expand Up @@ -80,6 +81,15 @@ const MainRoutes = {
}
],
},
{
path: 'clinic',
children: [
{
path: 'doctors',
element: <LazyClinicDoctors />,
},
],
},
{
path: 'utils',
children: [
Expand Down
Loading

0 comments on commit 3c94786

Please sign in to comment.