Refactor leaders view
This commit is contained in:
parent
a3dddd3751
commit
6779c66f86
@ -36,6 +36,14 @@ const Leaders = () => {
|
|||||||
getLeaders({ page, per_page: perPage }),
|
getLeaders({ page, per_page: perPage }),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const { mutate: mutateDelete } = useMutation(
|
||||||
|
'deleteLeader',
|
||||||
|
(index: number) => deleteLeader(index),
|
||||||
|
{
|
||||||
|
onSuccess: () => refetchLeaders(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPage(1)
|
setPage(1)
|
||||||
}, [perPage])
|
}, [perPage])
|
||||||
@ -79,18 +87,35 @@ const Leaders = () => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="divide-y divide-gray-100">
|
<tbody className="divide-y divide-gray-100">
|
||||||
{leaders?.data?.project_supervisors
|
{leaders?.data?.project_supervisors.map(
|
||||||
.map(({ id, first_name, last_name, email, limit_group, count_group, mode }) => (
|
({
|
||||||
|
id,
|
||||||
|
first_name,
|
||||||
|
last_name,
|
||||||
|
email,
|
||||||
|
limit_group,
|
||||||
|
count_groups,
|
||||||
|
mode,
|
||||||
|
}) => (
|
||||||
<tr key={id}>
|
<tr key={id}>
|
||||||
<td>{first_name}</td>
|
<td>{first_name}</td>
|
||||||
<td>{last_name}</td>
|
<td>{last_name}</td>
|
||||||
<td>{email}</td>
|
<td>{email}</td>
|
||||||
<td>{limit_group}</td>
|
<td>{limit_group}</td>
|
||||||
<td>{count_group}</td>
|
<td>{count_groups}</td>
|
||||||
<td>{mode==0 ? "Stacjonarny" : mode==1 ? "Niestacjonarny" : "Nie/stacjonarny"}</td>
|
<td>
|
||||||
<td><button onClick={() => deleteLeader(id).then(() => refetchLeaders())}>X</button></td>
|
{mode == 0
|
||||||
|
? 'Stacjonarny'
|
||||||
|
: mode == 1
|
||||||
|
? 'Niestacjonarny'
|
||||||
|
: 'Nie/stacjonarny'}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button onClick={() => mutateDelete(id)}>X</button>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
),
|
||||||
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -105,7 +130,7 @@ const Leaders = () => {
|
|||||||
</button>
|
</button>
|
||||||
{[
|
{[
|
||||||
...Array(
|
...Array(
|
||||||
leaders?.data?.max_pages && leaders?.data?.max_pages + 1,
|
leaders?.data?.max_pages && leaders?.data?.max_pages + 1,
|
||||||
).keys(),
|
).keys(),
|
||||||
]
|
]
|
||||||
.slice(1)
|
.slice(1)
|
||||||
@ -135,4 +160,4 @@ const Leaders = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Leaders;
|
export default Leaders
|
||||||
|
Loading…
Reference in New Issue
Block a user