Status: {userTraining.attendance_status}
+ {userTraining.attendance_status === 'withdrawn' ? + + : + + } +The course is full.
+ : + + ) + ) + } :Loading...
diff --git a/webclient/src/InstructorClasses.js b/webclient/src/InstructorClasses.js index 36b1ff1..2701a89 100644 --- a/webclient/src/InstructorClasses.js +++ b/webclient/src/InstructorClasses.js @@ -7,6 +7,83 @@ import './light.css'; import { Button, Container, Checkbox, Divider, Dropdown, Form, Grid, Header, Icon, Image, Label, Menu, Message, Segment, Table } from 'semantic-ui-react'; import { BasicTable, staticUrl, requester } from './utils.js'; +function AttendanceRow(props) { + const { student, token } = 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) + .then(res => { + setTraining(res); + setError(false); + }) + .catch(err => { + console.log(err); + setError(true); + }); + }; + + // 'withdrawn', 'rescheduled', 'no-show', 'attended', 'confirmed' + + const makeProps = (name) => ({ + onClick: () => handleMark(name), + toggle: true, + active: training.attendance_status === name, + }); + + return ( +{training.student_name}:
+ + + + + + + + + + + + {error &&Error: something went wrong!
} + +No students yet.
+ } +