feat: Ajout bouton de refus de dossier avec zone de saisie de motif [N3WTS-2]

This commit is contained in:
N3WT DE COMPET
2026-02-16 17:54:20 +01:00
parent 05c68ebfaa
commit 3779a47417
5 changed files with 223 additions and 44 deletions

View File

@ -12,6 +12,7 @@ import { FE_ADMIN_SUBSCRIPTIONS_URL } from '@/utils/Url';
import { useNotification } from '@/context/NotificationContext';
export default function Page() {
const [isLoadingRefuse, setIsLoadingRefuse] = useState(false);
const searchParams = useSearchParams();
const router = useRouter();
const [isLoading, setIsLoading] = useState(false);
@ -84,6 +85,29 @@ export default function Page() {
});
};
const handleRefuseRF = (reason) => {
setIsLoadingRefuse(true);
const data = {
status: 6, // STATUS_ARCHIVED
notes: reason,
};
const formData = new FormData();
formData.append('data', JSON.stringify(data));
editRegisterForm(studentId, formData, csrfToken)
.then((response) => {
logger.debug('RF refusé et archivé:', response);
showNotification('Le dossier a été refusé et archivé.', 'success', 'Succès');
router.push(FE_ADMIN_SUBSCRIPTIONS_URL);
setIsLoadingRefuse(false);
})
.catch((error) => {
showNotification('Erreur lors du refus du dossier.', 'error', 'Erreur');
setIsLoadingRefuse(false);
logger.error('Erreur lors du refus du RF:', error);
});
};
if (isLoading) {
return <Loader />;
}
@ -97,6 +121,8 @@ export default function Page() {
student_file={student_file}
onAccept={handleAcceptRF}
classes={classes}
onRefuse={handleRefuseRF}
isLoadingRefuse={isLoadingRefuse}
/>
);
}