diff --git a/src/operations/attendance/create/CreateByScan.tsx b/src/operations/attendance/create/CreateByScan.tsx index 5a367969..a0a222b3 100644 --- a/src/operations/attendance/create/CreateByScan.tsx +++ b/src/operations/attendance/create/CreateByScan.tsx @@ -1,4 +1,4 @@ -import {useState, useEffect} from "react"; +import {useState, useEffect, FC} from "react"; import { Box, FormControl, @@ -26,18 +26,14 @@ import {LinkButton} from "../list"; export const CreateByScan = () => { const [openDialog, , toggleOpenDialog] = useToggle(); - const notify = useNotify(); const config = qrcode.getConfig(); const [currentConfig, setCurrentConfig] = useState({ type: config.type, open: false, }); const [scanner, setScanner] = useState(); - const [isSaving, setIsSaving] = useState(false); const [dialogData, setDialogData] = useState(); - const [attendanceType, setAttendanceType] = useState( - AttendanceMovementType.IN - ); + const navigate = useNavigate(); useEffect(() => { @@ -69,17 +65,6 @@ export const CreateByScan = () => { closeButton && closeButton.click(); navigate("/attendance"); }; - const handleConfirm = async () => { - setIsSaving(true); - await createAttendance({ - studentId: dialogData?.id!, - type: attendanceType, - place: "IVANDRY", - notify, - }); - setIsSaving(false); - toggleOpenDialog(); - }; return ( { /> - - - Confirmer la présence - - - Êtes-vous sûr de vouloir enregistrer la présence de : - -
    -
  • - Nom: {dialogData?.last_name} -
  • -
  • - Préom: {dialogData?.first_name} -
  • -
  • - Référence: {dialogData?.ref} -
  • -
- - - -
- - - - -
+ ); }; + +type ConfirmProps = { + openDialog: boolean; + toggleOpenDialog: () => void; + dialogData: UserIdentifier; +}; + +const ConfirmDialog: FC = ({ + openDialog, + toggleOpenDialog, + dialogData, +}) => { + const notify = useNotify(); + const [isSaving, setIsSaving] = useState(false); + const [attendanceType, setAttendanceType] = useState( + AttendanceMovementType.IN + ); + const handleConfirm = async () => { + setIsSaving(true); + await createAttendance({ + studentId: dialogData?.id!, + type: attendanceType, + place: "IVANDRY", + notify, + }); + setIsSaving(false); + toggleOpenDialog(); + }; + return ( + + Confirmer la présence + + + Êtes-vous sûr de vouloir enregistrer la présence de : + +
    +
  • + Nom: {dialogData?.last_name} +
  • +
  • + Préom: {dialogData?.first_name} +
  • +
  • + Référence: {dialogData?.ref} +
  • +
+ + + +
+ + + + +
+ ); +};