-
Notifications
You must be signed in to change notification settings - Fork 4
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 #32 from advanced-computer-lab-2023/task-10,16,17,…
…51_FrontAndBack Task 10,16,17,51 front and back
- Loading branch information
Showing
55 changed files
with
31,228 additions
and
47,034 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,17 @@ | ||
import { Helmet } from 'react-helmet-async'; | ||
|
||
import { AddView } from 'src/sections/addSlotsOrAppointment/view'; | ||
|
||
// ---------------------------------------------------------------------- | ||
|
||
export default function AddSlotsPage() { | ||
return ( | ||
<> | ||
<Helmet> | ||
<title> Add Slots Or Appointment </title> | ||
</Helmet> | ||
|
||
<AddView /> | ||
</> | ||
); | ||
} |
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,17 @@ | ||
import { Helmet } from 'react-helmet-async'; | ||
|
||
import { DoctorContract } from 'src/sections/contract'; | ||
|
||
// ---------------------------------------------------------------------- | ||
|
||
export default function ContarctPage() { | ||
return ( | ||
<> | ||
<Helmet> | ||
<title> Contract </title> | ||
</Helmet> | ||
|
||
<DoctorContract /> | ||
</> | ||
); | ||
} |
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,145 @@ | ||
import React, { useState } from 'react'; | ||
import { useForm } from 'react-hook-form'; | ||
import { Box, Container, Card, Stack, TextField, Typography, Button, MenuItem, Snackbar, IconButton } from '@mui/material'; | ||
import CloseIcon from '@mui/icons-material/Close'; | ||
import { axiosInstance } from '../../utils/axiosInstance'; | ||
|
||
const AddSlotsForm = () => { | ||
const { register, handleSubmit, reset, formState: { errors } } = useForm(); | ||
const [loading, setLoading] = useState(false); | ||
const [message, setMessage] = useState(''); | ||
const [open, setOpen] = useState(false); | ||
|
||
|
||
const onSubmit = async (data) => { | ||
|
||
const timeStringToObject = (timeString) => { | ||
const [hours, minutes] = timeString.split(':'); | ||
return { hours: parseInt(hours, 10), minutes: parseInt(minutes, 10) }; | ||
}; | ||
|
||
const slotData = { | ||
day: data.day, | ||
slots: [{ | ||
from: timeStringToObject(data.startTime), | ||
to: timeStringToObject(data.endTime), | ||
maxPatients: data.maxPatients | ||
}] | ||
}; | ||
|
||
setLoading(true); | ||
setMessage(''); | ||
|
||
try { | ||
const response = await axiosInstance.put('/me/weeklyslots', slotData); | ||
|
||
if (response.status === 200) { | ||
setMessage(response.data.message); | ||
reset(); | ||
} else { | ||
setMessage(response.data.message || 'An error occurred'); | ||
} | ||
} catch (error) { | ||
setMessage(error.response?.data?.message || error.message); | ||
} finally { | ||
setLoading(false); | ||
setOpen(true); | ||
} | ||
}; | ||
|
||
const handleClose = (event, reason) => { | ||
if (reason === 'clickaway') { | ||
return; | ||
} | ||
setOpen(false); | ||
}; | ||
|
||
const daysOfWeek = ['Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']; | ||
|
||
return ( | ||
<Container maxWidth="sm"> | ||
<Box sx={{ mt: 4, mb: 4 }}> | ||
<Card variant="outlined" sx={{ p: 3, width: '100%', maxWidth: 500 }}> | ||
<Typography variant="h6" gutterBottom sx={{ fontWeight: 'bold', color: '#333' }}> | ||
Add Slots | ||
</Typography> | ||
|
||
<form onSubmit={handleSubmit(onSubmit)}> | ||
<Stack spacing={2}> | ||
<TextField | ||
select | ||
label="Day of the Week" | ||
{...register('day', { required: 'Day is required' })} | ||
error={Boolean(errors.day)} | ||
helperText={errors.day?.message} | ||
fullWidth | ||
margin="normal" | ||
> | ||
{daysOfWeek.map(day => ( | ||
<MenuItem key={day} value={day}> | ||
{day} | ||
</MenuItem> | ||
))} | ||
</TextField> | ||
<TextField | ||
label="Start Time" | ||
type="time" | ||
InputLabelProps={{ shrink: true }} | ||
{...register('startTime', { required: 'Start time is required' })} | ||
error={Boolean(errors.startTime)} | ||
helperText={errors.startTime?.message} | ||
fullWidth | ||
margin="normal" | ||
/> | ||
<TextField | ||
label="End Time" | ||
type="time" | ||
InputLabelProps={{ shrink: true }} | ||
{...register('endTime', { required: 'End time is required' })} | ||
error={Boolean(errors.endTime)} | ||
helperText={errors.endTime?.message} | ||
fullWidth | ||
margin="normal" | ||
/> | ||
<TextField | ||
label="Max Patients" | ||
type="number" | ||
{...register('maxPatients', { required: 'Max patients is required' })} | ||
error={Boolean(errors.maxPatients)} | ||
helperText={errors.maxPatients?.message} | ||
fullWidth | ||
margin="normal" | ||
/> | ||
|
||
|
||
<Button | ||
type="submit" | ||
variant="contained" | ||
color="inherit" | ||
disabled={loading} | ||
fullWidth | ||
sx={{ mt: 2 }} | ||
> | ||
{loading ? 'Adding...' : 'Add Slots'} | ||
</Button> | ||
</Stack> | ||
</form> | ||
|
||
<Snackbar | ||
open={open} | ||
autoHideDuration={6000} | ||
onClose={handleClose} | ||
message={message} | ||
action={ | ||
<IconButton size="small" aria-label="close" color="inherit" onClick={handleClose}> | ||
<CloseIcon fontSize="small" /> | ||
</IconButton> | ||
} | ||
/> | ||
</Card> | ||
</Box> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default AddSlotsForm; |
112 changes: 112 additions & 0 deletions
112
client/src/sections/addSlotsOrAppointment/ScheduleApp.jsx
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,112 @@ | ||
import React, { useState } from 'react'; | ||
import { useForm } from 'react-hook-form'; | ||
import { Box, Container, Card, Stack, TextField, Typography, Button, Snackbar, IconButton } from '@mui/material'; | ||
import CloseIcon from '@mui/icons-material/Close'; | ||
import { axiosInstance } from '../../utils/axiosInstance'; | ||
|
||
const ScheduleFollowUpForm = () => { | ||
const { register, handleSubmit, reset, formState: { errors } } = useForm(); | ||
const [loading, setLoading] = useState(false); | ||
const [message, setMessage] = useState(''); | ||
const [open, setOpen] = useState(false); | ||
|
||
const onSubmit = async (data) => { | ||
setLoading(true); | ||
setMessage(''); | ||
|
||
try { | ||
const response = await axiosInstance.post('/me/appointments', { | ||
...data | ||
}); | ||
|
||
if (response.status === 200) { | ||
setMessage(response.data.message); | ||
reset(); | ||
} else { | ||
setMessage(response.data.message || 'An error occurred'); | ||
} | ||
} catch (error) { | ||
setMessage(error.response?.data?.message || error.message); | ||
} finally { | ||
setLoading(false); | ||
setOpen(true); | ||
} | ||
}; | ||
|
||
const handleClose = (event, reason) => { | ||
if (reason === 'clickaway') { | ||
return; | ||
} | ||
setOpen(false); | ||
}; | ||
|
||
return ( | ||
<Container maxWidth="sm"> | ||
<Box sx={{ mt: 4, mb: 4 }}> | ||
<Card variant="outlined" sx={{ p: 3, width: '100%', maxWidth: 500 }}> | ||
<Typography variant="h6" gutterBottom sx={{ fontWeight: 'bold', color: '#333' }}> | ||
Schedule Follow-Up Appointment | ||
</Typography> | ||
|
||
<form onSubmit={handleSubmit(onSubmit)}> | ||
<Stack spacing={2}> | ||
<TextField | ||
label="Patient's Email" | ||
type="email" | ||
{...register('email', { required: 'Patient email is required' })} | ||
error={Boolean(errors.email)} | ||
helperText={errors.email?.message} | ||
fullWidth | ||
margin="normal" | ||
/> | ||
<TextField | ||
label="Start Date" | ||
type="datetime-local" | ||
InputLabelProps={{ shrink: true }} | ||
{...register('startDate', { required: 'Start date is required' })} | ||
error={Boolean(errors.startDate)} | ||
helperText={errors.startDate?.message} | ||
fullWidth | ||
margin="normal" | ||
/> | ||
<TextField | ||
label="End Date" | ||
type="datetime-local" | ||
InputLabelProps={{ shrink: true }} | ||
{...register('endDate', { required: 'End date is required' })} | ||
error={Boolean(errors.endDate)} | ||
helperText={errors.endDate?.message} | ||
fullWidth | ||
margin="normal" | ||
/> | ||
<Button | ||
type="submit" | ||
variant="contained" | ||
color="inherit" | ||
disabled={loading} | ||
fullWidth | ||
sx={{ mt: 2 }} | ||
> | ||
{loading ? 'Scheduling...' : 'Schedule Appointment'} | ||
</Button> | ||
</Stack> | ||
</form> | ||
|
||
<Snackbar | ||
open={open} | ||
autoHideDuration={6000} | ||
onClose={handleClose} | ||
message={message} | ||
action={ | ||
<IconButton size="small" aria-label="close" color="inherit" onClick={handleClose}> | ||
<CloseIcon fontSize="small" /> | ||
</IconButton> | ||
} | ||
/> | ||
</Card> | ||
</Box> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default ScheduleFollowUpForm; |
Oops, something went wrong.