diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 455b18d..6cae9a0 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -7,7 +7,8 @@ import AddGroup from './views/coordinator/AddGroup' import AddStudent from './views/coordinator/AddStudent' import AddLeader from './views/coordinator/AddLeader' import Coordinator from './views/coordinator/Coordinator' -import Groups from './views/coordinator/Groups' +import CoordinatorGroups from './views/coordinator/CoordinatorGroups' +import SupervisorGroups from './views/supervisor/SupervisorGroups' import Leaders from './views/coordinator/Leaders' import Students from './views/coordinator/Students' import Login from './views/Login' @@ -42,7 +43,7 @@ function App() { } /> }> } /> - } /> + } /> } /> } /> } /> @@ -69,7 +70,7 @@ function App() { }> } /> - } /> + } /> } /> } /> diff --git a/frontend/src/components/TopBar.tsx b/frontend/src/components/TopBar.tsx index d992936..1dfc535 100644 --- a/frontend/src/components/TopBar.tsx +++ b/frontend/src/components/TopBar.tsx @@ -1,10 +1,10 @@ import { NavLink } from 'react-router-dom' -const TopBar = ({ routes }: { routes: { name: string; path: string }[] }) => { +const TopBar = ({ routes, color }: { routes: { name: string; path: string }[]; color: string}, ) => { const linkClass = ({ isActive }: { isActive: boolean }) => isActive ? 'underline font-bold' : '' return ( -
+

System PRI

{routes.map(({ path, name }) => ( diff --git a/frontend/src/views/coordinator/AddLeader.tsx b/frontend/src/views/coordinator/AddLeader.tsx index 005705c..5e0c83a 100644 --- a/frontend/src/views/coordinator/AddLeader.tsx +++ b/frontend/src/views/coordinator/AddLeader.tsx @@ -83,7 +83,23 @@ const AddLeader = () => { Email jest wymagany )}
- {/*
+
+ + + {errors.email?.type === 'required' && ( + Email jest wymagany + )} +
+
@@ -99,7 +115,7 @@ const AddLeader = () => { {errors.limit_group?.type === 'pattern' && ( Limit grup musi być liczbą dodatnią )} -
*/} +
) diff --git a/frontend/src/views/coordinator/Coordinator.tsx b/frontend/src/views/coordinator/Coordinator.tsx index e98344d..3e2cb1f 100644 --- a/frontend/src/views/coordinator/Coordinator.tsx +++ b/frontend/src/views/coordinator/Coordinator.tsx @@ -4,7 +4,7 @@ import TopBar from '../../components/TopBar' const Coordinator = () => { return ( <> - { { name: 'Harmonogram', path: '/coordinator/schedule' }, { name: 'Dostępność', path: '/coordinator/supervisors_availability' }, ]} + color="bg-violet-400" />
diff --git a/frontend/src/views/coordinator/Groups.tsx b/frontend/src/views/coordinator/CoordinatorGroups.tsx similarity index 100% rename from frontend/src/views/coordinator/Groups.tsx rename to frontend/src/views/coordinator/CoordinatorGroups.tsx diff --git a/frontend/src/views/student/Student.tsx b/frontend/src/views/student/Student.tsx index c5ff6a5..0ad0c66 100644 --- a/frontend/src/views/student/Student.tsx +++ b/frontend/src/views/student/Student.tsx @@ -9,6 +9,7 @@ const Student = () => { { name: 'Zapisy', path: '/student/enrollment' }, { name: 'Harmonogram', path: '/student/schedule' }, ]} + color="bg-gray-300" />
diff --git a/frontend/src/views/supervisor/Supervisor.tsx b/frontend/src/views/supervisor/Supervisor.tsx index 6540b2b..b0f89bd 100644 --- a/frontend/src/views/supervisor/Supervisor.tsx +++ b/frontend/src/views/supervisor/Supervisor.tsx @@ -9,6 +9,7 @@ const Supervisor = () => { { name: 'Grupy', path: '/supervisor/groups' }, { name: 'Harmonogram', path: '/supervisor/schedule' }, ]} + color="bg-amber-300" />
diff --git a/frontend/src/views/supervisor/SupervisorGroups.tsx b/frontend/src/views/supervisor/SupervisorGroups.tsx new file mode 100644 index 0000000..b8aa9e5 --- /dev/null +++ b/frontend/src/views/supervisor/SupervisorGroups.tsx @@ -0,0 +1,161 @@ +import classNames from 'classnames' +import { useEffect, useState } from 'react' +import { useMutation, useQuery } from 'react-query' +import { useNavigate } from 'react-router-dom' +import useLocalStorageState from 'use-local-storage-state' +import { deleteGroup, getGroups } from '../../api/groups' +import { ReactComponent as IconRemove } from '../../assets/svg/icon-remove.svg' +import { Link } from 'react-router-dom' + +const SupervisorGroups = () => { + let navigate = useNavigate() + const [page, setPage] = useState(1) + const [perPage, setPerPage] = useState(10) + const [yearGroupId] = useLocalStorageState('yearGroupId') + + const perPageOptions = [ + { + value: 10, + label: '10 rekordów', + }, + { + value: 20, + label: '20 rekordów', + }, + { + value: 50, + label: '50 rekordów', + }, + { + value: 1000, + label: 'Pokaż wszystkie', + }, + ] + + const { + isLoading: areGroupsLoading, + data: groups, + refetch: refetchGroups, + } = useQuery(['groups', page, perPage], () => + getGroups({ year_group_id: Number(yearGroupId), page, per_page: perPage }), + ) + + const { mutate: mutateDelete } = useMutation( + 'deleteGroup', + (index: number) => deleteGroup(index), + { + onSuccess: () => refetchGroups(), + }, + ) + + useEffect(() => { + setPage(1) + }, [perPage]) + + if (areGroupsLoading) { + return
Ładowanie
+ } + return ( +
+
+ +
+ +
+
+
+ + + + + + + + + + + + {groups?.data?.groups?.map( + ({ + id, + name, + project_supervisor, + points_for_first_term, + points_for_second_term, + }) => ( + + + + + + + + ), + )} + +
NazwaOpiekunSemestr 1Semestr 2
+ + {name} + + + {`${project_supervisor.first_name} ${project_supervisor.last_name}`} + {points_for_first_term}{points_for_second_term} + +
+
+
+
+ + {[ + ...Array( + groups?.data?.max_pages && groups?.data?.max_pages + 1, + ).keys(), + ] + .slice(1) + .map((p) => ( + + ))} + +
+
+
+ ) +} + +export default SupervisorGroups