Add available supervisor filter
This commit is contained in:
parent
5a49e87a63
commit
1459df0c6a
@ -5,6 +5,7 @@ export const getEnrollmentList = (
|
|||||||
page: number
|
page: number
|
||||||
per_page: number
|
per_page: number
|
||||||
name: string
|
name: string
|
||||||
|
mode: boolean
|
||||||
}>,
|
}>,
|
||||||
) =>
|
) =>
|
||||||
axiosInstance.get<{
|
axiosInstance.get<{
|
||||||
|
@ -104,9 +104,9 @@ const Leaders = () => {
|
|||||||
<td>{limit_group}</td>
|
<td>{limit_group}</td>
|
||||||
<td>{count_groups}</td>
|
<td>{count_groups}</td>
|
||||||
<td>
|
<td>
|
||||||
{mode == 0
|
{mode === 0
|
||||||
? 'Stacjonarny'
|
? 'Stacjonarny'
|
||||||
: mode == 1
|
: mode === 1
|
||||||
? 'Niestacjonarny'
|
? 'Niestacjonarny'
|
||||||
: 'Nie/stacjonarny'}
|
: 'Nie/stacjonarny'}
|
||||||
</td>
|
</td>
|
||||||
|
@ -1,17 +1,43 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
import { useQuery } from 'react-query'
|
import { useQuery } from 'react-query'
|
||||||
import { getEnrollmentList } from '../../api/enrollment'
|
import { getEnrollmentList } from '../../api/enrollment'
|
||||||
|
|
||||||
const Enrollment = () => {
|
const Enrollment = () => {
|
||||||
const { isLoading, data: enrollmentData } = useQuery(['enrollment'], () =>
|
const [showAvailable, setShowAvailable] = useState(false)
|
||||||
getEnrollmentList({ per_page: 1000 }),
|
const [mode, setMode] = useState(true)
|
||||||
|
const { isLoading, data: enrollmentData } = useQuery(
|
||||||
|
['enrollment', mode],
|
||||||
|
() => getEnrollmentList({ per_page: 1000, mode }),
|
||||||
)
|
)
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return <div>Ładowanie</div>
|
return <div>Ładowanie</div>
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-center"></div>
|
<div className="flex items-center justify-between">
|
||||||
<h2>Opiekunowie</h2>
|
<h2 className="text-xl font-bold">Opiekunowie:</h2>
|
||||||
|
<div className="flex gap-3">
|
||||||
|
<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">
|
||||||
|
Pokaż wolne miejsca
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
className="checkbox checkbox-xs md:checkbox-md"
|
||||||
|
onChange={() => setShowAvailable(!showAvailable)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div className="flex mx-auto mt-5 overflow-hidden overflow-x-auto border border-gray-100 rounded">
|
<div className="flex mx-auto mt-5 overflow-hidden overflow-x-auto border border-gray-100 rounded">
|
||||||
<table className="min-w-full table table-compact">
|
<table className="min-w-full table table-compact">
|
||||||
<thead>
|
<thead>
|
||||||
@ -24,17 +50,21 @@ const Enrollment = () => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="divide-y divide-gray-100">
|
<tbody className="divide-y divide-gray-100">
|
||||||
{enrollmentData?.data?.project_supervisors?.map(
|
{enrollmentData?.data?.project_supervisors
|
||||||
({ first_name, last_name, email, mode, available_groups }) => (
|
?.filter(
|
||||||
<tr key={email}>
|
({ available_groups }) => available_groups || !showAvailable,
|
||||||
<td>{first_name}</td>
|
)
|
||||||
<td>{last_name}</td>
|
.map(
|
||||||
<td>{email}</td>
|
({ first_name, last_name, email, mode, available_groups }) => (
|
||||||
<td>{mode ? 'stacjonarny' : 'niestacjonarny'}</td>
|
<tr key={email}>
|
||||||
<td>{available_groups}</td>
|
<td>{first_name}</td>
|
||||||
</tr>
|
<td>{last_name}</td>
|
||||||
),
|
<td>{email}</td>
|
||||||
)}
|
<td>{mode ? 'stacjonarny' : 'niestacjonarny'}</td>
|
||||||
|
<td>{available_groups}</td>
|
||||||
|
</tr>
|
||||||
|
),
|
||||||
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user