Skip to content

Commit

Permalink
Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
joezbub committed Dec 19, 2023
1 parent 56dcf0b commit 4012222
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 81 deletions.
70 changes: 54 additions & 16 deletions client/src/Admin/AddDateNotesDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import AlertType from '../util/types/alert';
interface IAdminNotesRow {
key: string;
date: string;
studentObservations: string;
studentNextSteps: string;
privateStudentObservations: string;
privateStudentNextSteps: string;
publicStudentObservations: string;
publicStudentNextSteps: string;
coachObservations: string;
coachNextSteps: string;
}
Expand All @@ -31,8 +33,10 @@ interface AddDateProps {
setOpen: (newOpen: boolean) => void;
addDate: (
date: number,
studentObservations: string,
studentNextSteps: string,
privateStudentObservations: string,
privateStudentNextSteps: string,
publicStudentObservations: string,
publicStudentNextSteps: string,
coachObservations: string,
coachNextSteps: string,
) => void;
Expand All @@ -41,8 +45,12 @@ interface AddDateProps {

function AddDateNotesDialog({ open, setOpen, addDate, table }: AddDateProps) {
const [date, setDate] = useState<Dayjs | null>(null);
const [studentObservations, setStudentObservations] = useState('');
const [studentNextSteps, setStudentNextSteps] = useState('');
const [privateStudentObservations, setPrivateStudentObservations] =
useState('');
const [privateStudentNextSteps, setPrivateStudentNextSteps] = useState('');
const [publicStudentObservations, setPublicStudentObservations] =
useState('');
const [publicStudentNextSteps, setPublicStudentNextSteps] = useState('');
const [coachObservations, setCoachObservations] = useState('');
const [coachNextSteps, setCoachNextSteps] = useState('');
const [error, setError] = useState<boolean>(false);
Expand Down Expand Up @@ -73,14 +81,18 @@ function AddDateNotesDialog({ open, setOpen, addDate, table }: AddDateProps) {

addDate(
Number(date),
studentObservations,
studentNextSteps,
privateStudentObservations,
privateStudentNextSteps,
publicStudentObservations,
publicStudentNextSteps,
coachObservations,
coachNextSteps,
);
setDate(null);
setStudentObservations('');
setStudentNextSteps('');
setPrivateStudentObservations('');
setPrivateStudentNextSteps('');
setPublicStudentObservations('');
setPublicStudentNextSteps('');
setCoachObservations('');
setCoachNextSteps('');
setOpen(false);
Expand Down Expand Up @@ -121,18 +133,44 @@ function AddDateNotesDialog({ open, setOpen, addDate, table }: AddDateProps) {
<TextField
fullWidth
multiline
label="Student Observations"
value={studentObservations}
onChange={(event) => setStudentObservations(event.target.value)}
label="Private Student Observations"
value={privateStudentObservations}
onChange={(event) =>
setPrivateStudentObservations(event.target.value)
}
/>
</Grid>
<Grid item width="1">
<TextField
fullWidth
multiline
label="Student Next Steps"
value={studentNextSteps}
onChange={(event) => setStudentNextSteps(event.target.value)}
label="Private Student Next Steps"
value={privateStudentNextSteps}
onChange={(event) =>
setPrivateStudentNextSteps(event.target.value)
}
/>
</Grid>
<Grid item width="1">
<TextField
fullWidth
multiline
label="Public Student Observations"
value={publicStudentObservations}
onChange={(event) =>
setPublicStudentObservations(event.target.value)
}
/>
</Grid>
<Grid item width="1">
<TextField
fullWidth
multiline
label="Public Student Next Steps"
value={publicStudentNextSteps}
onChange={(event) =>
setPublicStudentNextSteps(event.target.value)
}
/>
</Grid>
<Grid item width="1">
Expand Down
68 changes: 45 additions & 23 deletions client/src/Admin/AdminNotesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ interface IAdminNotesTable {
interface IAdminNotesRow {
key: string;
date: string;
studentObservations: string;
studentNextSteps: string;
privateStudentObservations: string;
privateStudentNextSteps: string;
publicStudentObservations: string;
publicStudentNextSteps: string;
coachObservations: string;
coachNextSteps: string;
}
Expand All @@ -45,10 +47,12 @@ function AdminSessionsPage() {

const columns: TColumn[] = [
{ id: 'date', label: 'Date' },
{ id: 'studentObservations', label: 'Student Observations' },
{ id: 'studentNextSteps', label: 'Student Next Steps' },
{ id: 'coachObservations', label: 'Coach Observations' },
{ id: 'coachNextSteps', label: 'Coach Next Steps' },
{ id: 'privateStudentObservations', label: 'Private Student Notes' },
{ id: 'privateStudentNextSteps', label: 'Private Student Next Steps' },
{ id: 'publicStudentObservations', label: 'Public Student Notes' },
{ id: 'publicStudentNextSteps', label: 'Public Student Next Steps' },
{ id: 'coachObservations', label: 'Private Coach Notes' },
{ id: 'coachNextSteps', label: 'Private Coach Next Steps' },
];

async function getCoach(id: string) {
Expand All @@ -72,9 +76,14 @@ function AdminSessionsPage() {
useEffect(() => {
const bigMap = new Map();
if (student) {
console.log(student.progress_stats);
const goodKeys = [
'private_student_next_steps',
'private_student_observations',
'public_student_next_steps',
'public_student_observations',
];
Object.entries(student.progress_stats).forEach(([key, innerMap]) => {
if (key === 'student_next_steps' || key === 'student_observations') {
if (goodKeys.includes(key)) {
Object.entries(innerMap).forEach(([date, comments]) => {
if (!bigMap.has(date)) {
bigMap.set(date, {});
Expand Down Expand Up @@ -103,8 +112,10 @@ function AdminSessionsPage() {
bigTable.push({
key: date.toString(),
date: new Date(parseInt(date, 10)).toLocaleDateString(),
studentObservations: obj.student_observations || '',
studentNextSteps: obj.student_next_steps || '',
privateStudentObservations: obj.private_student_observations || '',
privateStudentNextSteps: obj.private_student_next_steps || '',
publicStudentObservations: obj.public_student_observations || '',
publicStudentNextSteps: obj.public_student_next_steps || '',
coachObservations: obj.coach_observations || '',
coachNextSteps: obj.coach_next_steps || '',
});
Expand All @@ -116,16 +127,20 @@ function AdminSessionsPage() {
function createAdminNotesRow(
key: string,
date: string,
studentObservations: string,
studentNextSteps: string,
privateStudentObservations: string,
privateStudentNextSteps: string,
publicStudentObservations: string,
publicStudentNextSteps: string,
coachObservations: string,
coachNextSteps: string,
): IAdminNotesRow {
return {
key,
date,
studentObservations,
studentNextSteps,
privateStudentObservations,
privateStudentNextSteps,
publicStudentObservations,
publicStudentNextSteps,
coachObservations,
coachNextSteps,
};
Expand Down Expand Up @@ -156,22 +171,25 @@ function AdminSessionsPage() {

const addDate = async (
date: number,
studentObservations: string,
studentNextSteps: string,
privateStudentObservations: string,
privateStudentNextSteps: string,
publicStudentObservations: string,
publicStudentNextSteps: string,
coachObservations: string,
coachNextSteps: string,
) => {
try {
const studentComments = {
date,
observations: studentObservations,
next_steps: studentNextSteps,
private_observations: privateStudentObservations,
private_next_steps: privateStudentNextSteps,
public_observations: publicStudentObservations,
public_next_steps: publicStudentNextSteps,
};
putData(
`student/progress/${student?._id}`,
studentComments,
); /* eslint no-underscore-dangle: 0 */

if (coach) {
const coachComments = {
date,
Expand All @@ -187,8 +205,10 @@ function AdminSessionsPage() {
const newData = {
key: date.toString(),
date: new Date(date).toLocaleDateString('en-US'),
studentObservations,
studentNextSteps,
privateStudentObservations,
privateStudentNextSteps,
publicStudentObservations,
publicStudentNextSteps,
coachObservations,
coachNextSteps,
};
Expand Down Expand Up @@ -328,8 +348,10 @@ function AdminSessionsPage() {
createAdminNotesRow(
rowData.key,
rowData.date,
rowData.studentObservations,
rowData.studentNextSteps,
rowData.privateStudentObservations,
rowData.privateStudentNextSteps,
rowData.publicStudentObservations,
rowData.publicStudentNextSteps,
rowData.coachObservations,
rowData.coachNextSteps,
),
Expand Down
76 changes: 58 additions & 18 deletions client/src/Admin/EditDateNotesDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import AlertType from '../util/types/alert';
interface IAdminNotesRow {
key: string;
date: string;
studentObservations: string;
studentNextSteps: string;
privateStudentObservations: string;
privateStudentNextSteps: string;
publicStudentObservations: string;
publicStudentNextSteps: string;
coachObservations: string;
coachNextSteps: string;
}
Expand All @@ -29,8 +31,10 @@ interface EditDateDialogProps {
options: number[];
editDate: (
date: number,
studentObservations: string,
studentNextSteps: string,
privateStudentObservations: string,
privateStudentNextSteps: string,
publicStudentObservations: string,
publicStudentNextSteps: string,
coachObservations: string,
coachNextSteps: string,
) => void;
Expand All @@ -45,8 +49,12 @@ function EditDateDialog({
table,
}: EditDateDialogProps) {
const [date, setDate] = useState<number | null>(null);
const [studentObservations, setStudentObservations] = useState('');
const [studentNextSteps, setStudentNextSteps] = useState('');
const [privateStudentObservations, setPrivateStudentObservations] =
useState('');
const [privateStudentNextSteps, setPrivateStudentNextSteps] = useState('');
const [publicStudentObservations, setPublicStudentObservations] =
useState('');
const [publicStudentNextSteps, setPublicStudentNextSteps] = useState('');
const [coachObservations, setCoachObservations] = useState('');
const [coachNextSteps, setCoachNextSteps] = useState('');
const { setAlert } = useAlert();
Expand All @@ -56,8 +64,10 @@ function EditDateDialog({
const numberDate = Number(date).toString();
const row = table.find((r: IAdminNotesRow) => r.key === numberDate);
if (row) {
setStudentObservations(row.studentObservations);
setStudentNextSteps(row.studentNextSteps);
setPrivateStudentObservations(row.privateStudentObservations);
setPrivateStudentNextSteps(row.privateStudentNextSteps);
setPublicStudentObservations(row.publicStudentObservations);
setPublicStudentNextSteps(row.publicStudentNextSteps);
setCoachObservations(row.coachObservations);
setCoachNextSteps(row.coachNextSteps);
}
Expand All @@ -70,14 +80,18 @@ function EditDateDialog({
}
editDate(
date,
studentObservations,
studentNextSteps,
privateStudentObservations,
privateStudentNextSteps,
publicStudentObservations,
publicStudentNextSteps,
coachObservations,
coachNextSteps,
);
setDate(null);
setStudentObservations('');
setStudentNextSteps('');
setPrivateStudentObservations('');
setPrivateStudentNextSteps('');
setPublicStudentObservations('');
setPublicStudentNextSteps('');
setCoachObservations('');
setCoachNextSteps('');
setOpen(false);
Expand Down Expand Up @@ -120,18 +134,44 @@ function EditDateDialog({
<TextField
fullWidth
multiline
label="Student Observations"
value={studentObservations}
onChange={(event) => setStudentObservations(event.target.value)}
label="Private Student Observations"
value={privateStudentObservations}
onChange={(event) =>
setPrivateStudentObservations(event.target.value)
}
/>
</Grid>
<Grid item width="1">
<TextField
fullWidth
multiline
label="Student Next Steps"
value={studentNextSteps}
onChange={(event) => setStudentNextSteps(event.target.value)}
label="Private Student Next Steps"
value={privateStudentNextSteps}
onChange={(event) =>
setPrivateStudentNextSteps(event.target.value)
}
/>
</Grid>
<Grid item width="1">
<TextField
fullWidth
multiline
label="Public Student Observations"
value={publicStudentObservations}
onChange={(event) =>
setPublicStudentObservations(event.target.value)
}
/>
</Grid>
<Grid item width="1">
<TextField
fullWidth
multiline
label="Public Student Next Steps"
value={publicStudentNextSteps}
onChange={(event) =>
setPublicStudentNextSteps(event.target.value)
}
/>
</Grid>
<Grid item width="1">
Expand Down
Loading

0 comments on commit 4012222

Please sign in to comment.