diff --git a/src/components/table/Body.tsx b/src/components/table/Body.tsx deleted file mode 100644 index 569e94f..0000000 --- a/src/components/table/Body.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { Children, type FC, type ReactNode } from "react" - -import Row from "./Row" - -export interface BodyProps { - children: ReactNode -} - -const Body: FC = ({ children }) => ( - - {Children.map(children, child => ( - <>{child} - ))} - -) - -export default Body diff --git a/src/components/table/Cell.tsx b/src/components/table/Cell.tsx deleted file mode 100644 index b84c572..0000000 --- a/src/components/table/Cell.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { - Stack, - type StackProps, - TableCell, - type TableCellProps, - tableCellClasses, -} from "@mui/material" -import { type FC } from "react" - -export interface CellProps extends TableCellProps { - alignItems?: StackProps["alignItems"] - justifyContent?: StackProps["justifyContent"] - direction?: StackProps["direction"] -} - -const Cell: FC = ({ - children, - sx, - alignItems = "center", - justifyContent = "flex-start", - direction = "row", - ...otherTableCellProps -}) => { - return ( - ({ - outline: `1px solid ${theme.palette.common.white}`, - [`&.${tableCellClasses.head}`]: { - color: theme.palette.common.white, - }, - ...(typeof sx === "function" ? sx(theme) : sx), - })} - {...otherTableCellProps} - > - - {children} - - - ) -} - -export default Cell diff --git a/src/components/table/Row.tsx b/src/components/table/Row.tsx deleted file mode 100644 index 4e6a46e..0000000 --- a/src/components/table/Row.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { TableRow, type TableRowProps } from "@mui/material" -import { type FC } from "react" - -export interface RowProps extends TableRowProps {} - -const Row: FC = ({ sx, ...otherTableRowProps }) => ( - ({ - // hide last border - "&:last-child td, &:last-child th": { - border: 0, - }, - ...(typeof sx === "function" ? sx(theme) : sx), - })} - {...otherTableRowProps} - /> -) - -export default Row diff --git a/src/components/table/Table.tsx b/src/components/table/Table.tsx deleted file mode 100644 index 5882ca3..0000000 --- a/src/components/table/Table.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { - Table as MuiTable, - TableBody, - TableContainer, - type TableContainerProps, - TableHead, -} from "@mui/material" -import { type FC } from "react" - -import Cell from "./Cell" -import Row from "./Row" - -export interface TableProps { - titles: string[] - children: React.ReactNode - className?: string - containerProps?: TableContainerProps -} - -const Table: FC = ({ - titles, - children, - className, - containerProps, -}) => { - return ( - - - - - {titles.map((title, index) => ( - {title} - ))} - - - {children} - - - ) -} - -export default Table diff --git a/src/components/table/index.tsx b/src/components/table/index.tsx deleted file mode 100644 index d0c08cd..0000000 --- a/src/components/table/index.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import Body, { type BodyProps } from "./Body" -import Cell, { type CellProps } from "./Cell" -import Row, { type RowProps } from "./Row" -import Table, { type TableProps } from "./Table" - -export { - Table, - Body, - Cell, - Row, - type RowProps, - type TableProps, - type CellProps, - type BodyProps, -} diff --git a/src/pages/teacherDashboard/classes/ClassTable.tsx b/src/pages/teacherDashboard/classes/ClassTable.tsx index 3e1c659..b5dda35 100644 --- a/src/pages/teacherDashboard/classes/ClassTable.tsx +++ b/src/pages/teacherDashboard/classes/ClassTable.tsx @@ -1,3 +1,4 @@ +import * as tables from "codeforlife/components/table" import { CopyIconButton, TablePagination } from "codeforlife/components" import { Create as CreateIcon } from "@mui/icons-material" import { type FC } from "react" @@ -6,7 +7,6 @@ import { type SchoolTeacherUser } from "codeforlife/api" import { Typography } from "@mui/material" import { generatePath } from "react-router" -import * as tables from "../../../components/table" import { type RetrieveUserResult } from "../../../api/user" import { paths } from "../../../routes" import { useLazyListClassesQuery } from "../../../api/klass" @@ -31,19 +31,23 @@ const ClassTable: FC = ({ authUser }) => ( > {classes => ( {classes.map(klass => ( - + {klass.name} - + {klass.id} - + {authUser.teacher.is_admin && ( {klass.teacher.id === authUser.teacher.id @@ -51,7 +55,7 @@ const ClassTable: FC = ({ authUser }) => ( : `${klass.teacher.user.first_name} ${klass.teacher.user.last_name}`} )} - + = ({ authUser }) => ( > Edit details - - + + ))} )} diff --git a/src/pages/teacherDashboard/classes/JoinClassRequestTable.tsx b/src/pages/teacherDashboard/classes/JoinClassRequestTable.tsx index f6b3c3d..68d4607 100644 --- a/src/pages/teacherDashboard/classes/JoinClassRequestTable.tsx +++ b/src/pages/teacherDashboard/classes/JoinClassRequestTable.tsx @@ -1,3 +1,4 @@ +import * as tables from "codeforlife/components/table" import { Add as AddIcon, DoNotDisturb as DoNotDisturbIcon, @@ -10,7 +11,6 @@ import { TablePagination } from "codeforlife/components" import { generatePath } from "react-router" import { useNavigate } from "codeforlife/hooks" -import * as tables from "../../../components/table" import { useHandleJoinClassRequestMutation, useLazyListUsersQuery, @@ -47,10 +47,10 @@ const JoinClassRequestTable: FC = ({ users.length ? ( {users.map(user => ( - + {user.first_name} {user.last_name} @@ -66,7 +66,7 @@ const JoinClassRequestTable: FC = ({ ? "" : ` (${user.requesting_to_join_class!.teacher.user.first_name} ${user.requesting_to_join_class!.teacher.user.last_name})`} - + = ({ > Reject - - + + ))} ) : ( diff --git a/src/pages/teacherDashboard/classes/transferStudents/StudentTable.tsx b/src/pages/teacherDashboard/classes/transferStudents/StudentTable.tsx index c33f326..511ceca 100644 --- a/src/pages/teacherDashboard/classes/transferStudents/StudentTable.tsx +++ b/src/pages/teacherDashboard/classes/transferStudents/StudentTable.tsx @@ -1,8 +1,8 @@ +import * as tables from "codeforlife/components/table" import { type FC } from "react" import { TablePagination } from "codeforlife/components" import { Typography } from "@mui/material" -import * as tables from "../../../../components/table" import { type RetrieveClassResult } from "../../../../api/klass" import { useLazyListUsersQuery } from "../../../../api/user" @@ -27,7 +27,7 @@ const StudentTable: FC = ({ klass, newClass }) => ( > {users => ( = ({ klass, newClass }) => ( > {users.length ? ( users.map(user => ( - + {user.first_name} - + )) ) : ( - + (no students) - + )} )} diff --git a/src/pages/teacherDashboard/classes/transferStudents/TransferStudentsForm.tsx b/src/pages/teacherDashboard/classes/transferStudents/TransferStudentsForm.tsx index d6fa3e5..4d8df80 100644 --- a/src/pages/teacherDashboard/classes/transferStudents/TransferStudentsForm.tsx +++ b/src/pages/teacherDashboard/classes/transferStudents/TransferStudentsForm.tsx @@ -1,4 +1,5 @@ import * as forms from "codeforlife/components/form" +import * as tables from "codeforlife/components/table" import { Stack, Typography } from "@mui/material" import { type FC } from "react" import { LinkButton } from "codeforlife/components/router" @@ -6,7 +7,6 @@ import { type StudentUser } from "codeforlife/api" import { submitForm } from "codeforlife/utils/form" import { useNavigate } from "codeforlife/hooks" -import * as tables from "../../../../components/table" import { type TransferStudentsArg, useTransferStudentsMutation, @@ -81,9 +81,9 @@ const TransferStudentsForm: FC = ({ }, })} > - + {studentUsers.map(studentUser => ( - + {studentUser.first_name} = ({ placeholder={`Enter a name for ${studentUser.first_name}`} /> - + ))} diff --git a/src/pages/teacherDashboard/school/Leave.tsx b/src/pages/teacherDashboard/school/Leave.tsx index e7d57e9..1fa9960 100644 --- a/src/pages/teacherDashboard/school/Leave.tsx +++ b/src/pages/teacherDashboard/school/Leave.tsx @@ -1,5 +1,6 @@ import * as form from "codeforlife/components/form" import * as page from "codeforlife/components/page" +import * as tables from "codeforlife/components/table" import * as yup from "yup" import { CircularProgress, Stack, Typography } from "@mui/material" import { type FC, useEffect } from "react" @@ -9,7 +10,6 @@ import { TablePagination } from "codeforlife/components" import { type User } from "codeforlife/api" import { submitForm } from "codeforlife/utils/form" -import * as table from "../../../components/table" import { useLazyListClassesQuery, useUpdateClassesMutation, @@ -125,27 +125,27 @@ const Leave: FC = ({ authUserId }) => { )} onSubmit={submitForm(updateClasses)} > - {classes.map(klass => ( - - + + {klass.name} - - + + - - + + ))} - + = ({ preferCacheValue > {schoolTeacherInvitations => ( - = ({ invited_teacher_email, expires_at, }) => ( - - + + {invited_teacher_first_name} {invited_teacher_last_name}{" "} ({expires_at < new Date() ? "expired" : "pending"}) - - + @@ -106,9 +105,9 @@ const TeacherInvitationTable: FC = ({ ({invited_teacher_email}) - + {authUser.teacher.is_admin && ( - + {invited_teacher_is_admin ? ( - + )} - + ), )} - + )} ) diff --git a/src/pages/teacherDashboard/school/TeacherTable.tsx b/src/pages/teacherDashboard/school/TeacherTable.tsx index 6b2891c..9a8c34e 100644 --- a/src/pages/teacherDashboard/school/TeacherTable.tsx +++ b/src/pages/teacherDashboard/school/TeacherTable.tsx @@ -1,3 +1,4 @@ +import * as tables from "codeforlife/components/table" import { Add as AddIcon, Create as CreateIcon, @@ -12,7 +13,6 @@ import { TablePagination } from "codeforlife/components" import { generatePath } from "react-router" import { useNavigate } from "codeforlife/hooks" -import * as table from "../../../components/table" import { type RetrieveUserResult, useLazyListUsersQuery, @@ -61,24 +61,23 @@ const TeacherTable: FC = ({ authUser }) => { preferCacheValue > {users => ( - {users.map(user => ( - - + + {user.first_name} {user.last_name} {user.id === authUser.id ? (you) : ""} - - + @@ -88,9 +87,9 @@ const TeacherTable: FC = ({ authUser }) => { : "Standard Teacher"} ({user.email}) - + {authUser.teacher.is_admin && ( - + {authUser.id === user.id && ( )} - + )} - + ))} - + )} ) diff --git a/src/pages/teacherDashboard/school/TransferClasses.tsx b/src/pages/teacherDashboard/school/TransferClasses.tsx index 488ec00..2cc7f54 100644 --- a/src/pages/teacherDashboard/school/TransferClasses.tsx +++ b/src/pages/teacherDashboard/school/TransferClasses.tsx @@ -1,5 +1,6 @@ import * as form from "codeforlife/components/form" import * as page from "codeforlife/components/page" +import * as tables from "codeforlife/components/table" import { Link, LinkButton } from "codeforlife/components/router" import { type SchoolTeacher, type User } from "codeforlife/api" import { Stack, Typography } from "@mui/material" @@ -8,7 +9,6 @@ import { TablePagination } from "codeforlife/components" import { submitForm } from "codeforlife/utils/form" import { useNavigate } from "codeforlife/hooks" -import * as table from "../../../components/table" import { useLazyListClassesQuery, useUpdateClassesMutation, @@ -98,27 +98,27 @@ const TransferClasses: FC = ({ authUserId, user }) => { )} onSubmit={submitForm(updateClasses)} > - {classes.map(klass => ( - - + + {klass.name} - - + + - - + + ))} - +