Enforce capitalization of class / session status
This commit is contained in:
@@ -90,7 +90,7 @@ export function ClassDetail(props) {
|
||||
const [error, setError] = useState(false);
|
||||
const { token, user, refreshUser } = props;
|
||||
const { id } = useParams();
|
||||
const userTraining = user.training.find(x => x.session.id == id);
|
||||
const userTraining = clazz && clazz.students.find(x => x.user == user.id);
|
||||
|
||||
useEffect(() => {
|
||||
requester('/sessions/'+id+'/', 'GET', token)
|
||||
@@ -104,7 +104,7 @@ export function ClassDetail(props) {
|
||||
}, [refreshCount]);
|
||||
|
||||
const handleSignup = () => {
|
||||
const data = { attendance_status: 'waiting for payment', session: id };
|
||||
const data = { attendance_status: 'Waiting for payment', session: id };
|
||||
requester('/training/', 'POST', token, data)
|
||||
.then(res => {
|
||||
refreshClass();
|
||||
@@ -190,12 +190,12 @@ export function ClassDetail(props) {
|
||||
(userTraining ?
|
||||
<div>
|
||||
<p>Status: {userTraining.attendance_status}</p>
|
||||
{userTraining.attendance_status === 'withdrawn' ?
|
||||
<Button onClick={() => handleToggle('waiting for payment')}>
|
||||
{userTraining.attendance_status === 'Withdrawn' ?
|
||||
<Button onClick={() => handleToggle('Waiting for payment')}>
|
||||
Sign back up
|
||||
</Button>
|
||||
:
|
||||
<Button onClick={() => handleToggle('withdrawn')}>
|
||||
<Button onClick={() => handleToggle('Withdrawn')}>
|
||||
Withdraw from Class
|
||||
</Button>
|
||||
}
|
||||
|
@@ -9,14 +9,12 @@ import { BasicTable, staticUrl, requester } from './utils.js';
|
||||
|
||||
function AttendanceRow(props) {
|
||||
const { student, token, refreshClass } = props;
|
||||
const [training, setTraining] = useState(student);
|
||||
const [error, setError] = useState(false);
|
||||
|
||||
const handleMark = (newStatus) => {
|
||||
const data = { attendance_status: newStatus };
|
||||
requester('/training/'+training.id+'/', 'PATCH', token, data)
|
||||
const data = { ...student, attendance_status: newStatus };
|
||||
requester('/training/'+student.id+'/', 'PATCH', token, data)
|
||||
.then(res => {
|
||||
setTraining(res);
|
||||
refreshClass();
|
||||
setError(false);
|
||||
})
|
||||
@@ -26,35 +24,33 @@ function AttendanceRow(props) {
|
||||
});
|
||||
};
|
||||
|
||||
// 'withdrawn', 'rescheduled', 'no-show', 'attended', 'confirmed'
|
||||
|
||||
const makeProps = (name) => ({
|
||||
onClick: () => handleMark(name),
|
||||
toggle: true,
|
||||
active: training.attendance_status === name,
|
||||
active: student.attendance_status === name,
|
||||
});
|
||||
|
||||
return (
|
||||
<div className='attendance-row'>
|
||||
<p>{training.student_name}:</p>
|
||||
<p>{student.student_name}:</p>
|
||||
|
||||
<Button {...makeProps('withdrawn')}>
|
||||
<Button {...makeProps('Withdrawn')}>
|
||||
Withdrawn
|
||||
</Button>
|
||||
|
||||
<Button {...makeProps('confirmed')}>
|
||||
<Button {...makeProps('Confirmed')}>
|
||||
Confirmed
|
||||
</Button>
|
||||
|
||||
<Button {...makeProps('rescheduled')}>
|
||||
<Button {...makeProps('Rescheduled')}>
|
||||
Rescheduled
|
||||
</Button>
|
||||
|
||||
<Button {...makeProps('no-show')}>
|
||||
<Button {...makeProps('No-show')}>
|
||||
No-show
|
||||
</Button>
|
||||
|
||||
<Button {...makeProps('attended')}>
|
||||
<Button {...makeProps('Attended')}>
|
||||
Attended
|
||||
</Button>
|
||||
|
||||
@@ -104,7 +100,7 @@ function InstructorClassEditor(props) {
|
||||
return (
|
||||
<div className='class-editor'>
|
||||
<Form.Input
|
||||
label='Cost ($)'
|
||||
label='Cost ($) — 0 for free'
|
||||
{...makeProps('cost')}
|
||||
/>
|
||||
|
||||
|
Reference in New Issue
Block a user