-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from advanced-computer-lab-2023/VCP-16
Vcp 16 frontend
- Loading branch information
Showing
11 changed files
with
241 additions
and
10,844 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.