add delete button

This commit is contained in:
Patryk Drzewiński 2022-06-12 20:11:01 +02:00
parent bdad456637
commit 9902e382e1
3 changed files with 8 additions and 2 deletions

View File

@ -51,7 +51,6 @@ class MessageSchema(ma.Schema):
class FileSchema(ma.Schema): class FileSchema(ma.Schema):
file = fields.Raw(type='file', required=True) file = fields.Raw(type='file', required=True)
mode = fields.Bool(required=True)
class StudentQuerySchema(ma.Schema): class StudentQuerySchema(ma.Schema):

View File

@ -39,3 +39,8 @@ export const uploadStudents = (payload: FormData) =>
'http://127.0.0.1:5000/api/coordinator/students/upload/', 'http://127.0.0.1:5000/api/coordinator/students/upload/',
payload, payload,
) )
export const deleteStudent = (payload: Number) =>
axiosInstance.delete(
'http://127.0.0.1:5000/api/coordinator/students/'+payload.toString()+'/',
)

View File

@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import { useMutation, useQuery } from 'react-query' import { useMutation, useQuery } from 'react-query'
import { useNavigate } from 'react-router-dom' import { useNavigate } from 'react-router-dom'
import { getStudents, uploadStudents } from '../../api/students' import { getStudents, uploadStudents, deleteStudent } from '../../api/students'
import classNames from 'classnames' import classNames from 'classnames'
const Students = () => { const Students = () => {
@ -123,6 +123,7 @@ const Students = () => {
<th>Indeks</th> <th>Indeks</th>
<th>Zapisany</th> <th>Zapisany</th>
<th>Tryb</th> <th>Tryb</th>
<th></th>
</tr> </tr>
</thead> </thead>
<tbody className="divide-y divide-gray-100"> <tbody className="divide-y divide-gray-100">
@ -135,6 +136,7 @@ const Students = () => {
<td>{index}</td> <td>{index}</td>
<td>{group === null ? 'Nie' : 'Tak'}</td> <td>{group === null ? 'Nie' : 'Tak'}</td>
<td>{mode ? 'stacjonarny' : 'niestacjonarny'}</td> <td>{mode ? 'stacjonarny' : 'niestacjonarny'}</td>
<td><button onClick={() => deleteStudent(index).then(() => refetchStudents())}>X</button></td>
</tr> </tr>
))} ))}
</tbody> </tbody>