From bdad456637cb52e88995987a0042b675c88c79e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Drzewi=C5=84ski?= Date: Sun, 12 Jun 2022 19:11:44 +0200 Subject: [PATCH] bug fix - wrong function angrument --- backend/app/coordinator/routes/students.py | 3 ++- frontend/src/api/students.ts | 3 +-- frontend/src/views/coordinator/Students.tsx | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/app/coordinator/routes/students.py b/backend/app/coordinator/routes/students.py index e80ed76..be392a4 100644 --- a/backend/app/coordinator/routes/students.py +++ b/backend/app/coordinator/routes/students.py @@ -100,8 +100,9 @@ def create_student(data: dict) -> dict: @bp.route("/upload/", methods=["POST"]) @bp.input(FileSchema, location='form_and_files') @bp.output(MessageSchema) -def upload_students(file: dict, mode: bool) -> dict: +def upload_students(file: dict) -> dict: uploaded_file = file.get('file') + mode = file.get('mode') == '0' if uploaded_file and is_allowed_extensions(uploaded_file.filename): try: diff --git a/frontend/src/api/students.ts b/frontend/src/api/students.ts index c518ee8..8e9d734 100644 --- a/frontend/src/api/students.ts +++ b/frontend/src/api/students.ts @@ -34,9 +34,8 @@ export const getStudents = ( export const createStudent = (payload: Student) => axiosInstance.post('http://127.0.0.1:5000/api/coordinator/students/', payload) -export const uploadStudents = (payload: FormData, mode: Boolean) => +export const uploadStudents = (payload: FormData) => axiosInstance.post( 'http://127.0.0.1:5000/api/coordinator/students/upload/', payload, - mode, ) diff --git a/frontend/src/views/coordinator/Students.tsx b/frontend/src/views/coordinator/Students.tsx index d4003ee..7d0acd8 100644 --- a/frontend/src/views/coordinator/Students.tsx +++ b/frontend/src/views/coordinator/Students.tsx @@ -40,7 +40,7 @@ const Students = () => { const { mutate: mutateUpload } = useMutation( 'uploadStudents', - (payload: FormData) => uploadStudents(payload, mode), + (payload: FormData) => uploadStudents(payload), { onSuccess: () => refetchStudents(), }, @@ -50,6 +50,7 @@ const Students = () => { const file = event.target.files[0] const payload = new FormData() payload.append('file', file, file.name) + payload.append('mode', mode ? '0' : '1') mutateUpload(payload) }