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 order_by_last_name: OrderType
page: number page: number
per_page: number per_page: number
mode: boolean
}> = {}, }> = {},
) => ) =>
axiosInstance.get<StudentResponse>( axiosInstance.get<StudentResponse>(

View File

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