From f85be0b0236edabbf5fc7abf554cd345361ae5c3 Mon Sep 17 00:00:00 2001 From: MelissaOlas Date: Wed, 4 Oct 2023 14:28:25 +0200 Subject: [PATCH] fix: adding new label to put request --- src/contexts/classroomContext.tsx | 49 +++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/src/contexts/classroomContext.tsx b/src/contexts/classroomContext.tsx index 478069f46..9b7006909 100644 --- a/src/contexts/classroomContext.tsx +++ b/src/contexts/classroomContext.tsx @@ -1,7 +1,10 @@ +import { Card, CircularProgress } from '@mui/material'; import React, { useEffect } from 'react'; import { UserContext } from './userContext'; import { VillageContext } from './villageContext'; +import { Modal } from 'src/components/Modal'; +import { primaryColor } from 'src/styles/variables.const'; import { serializeToQueryUrl } from 'src/utils'; import { axiosRequest } from 'src/utils/axiosRequest'; import type { Classroom, ClassroomAsFamilly } from 'types/classroom.type'; @@ -46,6 +49,8 @@ export const ClassroomContextProvider = ({ children }: ClassroomContextProviderP const { village } = React.useContext(VillageContext); const [students, setStudents] = React.useState([]); const [classroom, setClassroom] = React.useState(null); + const [showModal, setShowModal] = React.useState(null); + const [testModaltStep, setTestModaltStep] = React.useState(0); const [parentClassroom, setParentClassroom] = React.useState(null); const fetchClassroom = React.useCallback(async (user: User) => { @@ -147,12 +152,18 @@ export const ClassroomContextProvider = ({ children }: ClassroomContextProviderP .then((response) => { return response.data.classroom; }) + .then((response) => { + if (response.data !== null) { + showModal; + } + }) .catch((err) => { return err.message; }); }, - [user], + [user, showModal], ); + console.log('seeModal'); /** * Add new students in the classrom */ @@ -318,7 +329,41 @@ export const ClassroomContextProvider = ({ children }: ClassroomContextProviderP setStudents, ], ); - return {children}; + return ( + + {children} + {testModaltStep > 0 && ( +
+ + {testModaltStep === 1 && } + {testModaltStep === 2 && Brouillon enregistré} + +
+ )} + { + setShowModal(null); + }} + noCloseOutsideModal + noCloseButton + ariaDescribedBy="brouillon-desc" + ariaLabelledBy="brouillon-title" + > +
+

Vous avez un brouillon en cours pour cette activité, souhaitez vous le reprendre ?

+

+ (Continuer sans ce brouillon en créera un nouveau qui va supprimer celui déjà existant.) +

+
+
+
+ ); }; export interface ClassroomUpdateData {