Add filter by mode

This commit is contained in:
adam-skowronek 2022-06-11 15:06:17 +02:00
parent 19bf295e2d
commit 03a8e84e63
2 changed files with 15 additions and 3 deletions

View File

@ -22,6 +22,7 @@ export const getStudents = (
order_by_last_name: OrderType
page: number
per_page: number
mode: boolean
}> = {},
) =>
axiosInstance.get<StudentResponse>(

View File

@ -9,6 +9,8 @@ const Students = () => {
const [showGroupless, setShowGroupless] = useState(false)
const [page, setPage] = useState(1)
const [perPage, setPerPage] = useState(10)
const [mode, setMode] = useState(true)
const perPageOptions = [
{
value: 10,
@ -32,8 +34,8 @@ const Students = () => {
isLoading: isStudentsLoading,
data: students,
refetch: refetchStudents,
} = useQuery(['students', page, perPage], () =>
getStudents({ page, per_page: perPage }),
} = useQuery(['students', page, perPage, mode], () =>
getStudents({ page, per_page: perPage, mode }),
)
const { mutate: mutateUpload } = useMutation(
@ -53,7 +55,7 @@ const Students = () => {
useEffect(() => {
setPage(1)
}, [perPage])
}, [perPage, mode])
return (
<div>
@ -88,6 +90,15 @@ const Students = () => {
</option>
))}
</select>
<label className="label">
<span className="mr-2 text-xs md:text-base">Stacjonarni</span>
<input
type="checkbox"
className="checkbox checkbox-xs md:checkbox-md"
onChange={() => setMode(!mode)}
checked={mode}
/>
</label>
<label className="label">
<span className="mr-2 text-xs md:text-base">Tylko niezapisani</span>
<input