mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
fix: Correction URL
chore: Ajout de notifications
This commit is contained in:
@ -8,9 +8,11 @@ import { useEstablishment } from '@/context/EstablishmentContext';
|
|||||||
import { editRegisterForm } from '@/app/actions/subscriptionAction';
|
import { editRegisterForm } from '@/app/actions/subscriptionAction';
|
||||||
import logger from '@/utils/logger';
|
import logger from '@/utils/logger';
|
||||||
import Loader from '@/components/Loader';
|
import Loader from '@/components/Loader';
|
||||||
|
import { useNotification } from '@/context/NotificationContext';
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const { showNotification } = useNotification();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
const studentId = searchParams.get('studentId');
|
const studentId = searchParams.get('studentId');
|
||||||
const enable = searchParams.get('enabled') === 'true';
|
const enable = searchParams.get('enabled') === 'true';
|
||||||
@ -26,11 +28,21 @@ export default function Page() {
|
|||||||
.then((result) => {
|
.then((result) => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
logger.debug('Success:', result);
|
logger.debug('Success:', result);
|
||||||
|
showNotification(
|
||||||
|
"Dossier d'inscription soumis avec succès",
|
||||||
|
'success',
|
||||||
|
'Succès'
|
||||||
|
);
|
||||||
router.push(FE_ADMIN_SUBSCRIPTIONS_URL);
|
router.push(FE_ADMIN_SUBSCRIPTIONS_URL);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
logger.error('Error:', error.message);
|
logger.error('Error:', error.message);
|
||||||
|
showNotification(
|
||||||
|
"Erreur lors de la soumission du dossier d'inscription",
|
||||||
|
'error',
|
||||||
|
'Erreur'
|
||||||
|
);
|
||||||
if (error.details) {
|
if (error.details) {
|
||||||
logger.error('Form errors:', error.details);
|
logger.error('Form errors:', error.details);
|
||||||
setFormErrors(error.details);
|
setFormErrors(error.details);
|
||||||
|
|||||||
@ -7,25 +7,47 @@ import { useEstablishment } from '@/context/EstablishmentContext';
|
|||||||
import { FE_PARENTS_HOME_URL } from '@/utils/Url';
|
import { FE_PARENTS_HOME_URL } from '@/utils/Url';
|
||||||
import { editRegisterForm } from '@/app/actions/subscriptionAction';
|
import { editRegisterForm } from '@/app/actions/subscriptionAction';
|
||||||
import logger from '@/utils/logger';
|
import logger from '@/utils/logger';
|
||||||
|
import Loader from '@/components/Loader';
|
||||||
|
import { useNotification } from '@/context/NotificationContext';
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
|
const { showNotification } = useNotification();
|
||||||
const studentId = searchParams.get('studentId');
|
const studentId = searchParams.get('studentId');
|
||||||
const enable = searchParams.get('enabled') === 'true';
|
const enable = searchParams.get('enabled') === 'true';
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const csrfToken = useCsrfToken();
|
const csrfToken = useCsrfToken();
|
||||||
const { selectedEstablishmentId, apiDocuseal } = useEstablishment();
|
const { selectedEstablishmentId, apiDocuseal } = useEstablishment();
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = (data) => {
|
||||||
try {
|
setIsLoading(true);
|
||||||
const result = await editRegisterForm(studentId, data, csrfToken);
|
editRegisterForm(studentId, data, csrfToken)
|
||||||
|
.then((result) => {
|
||||||
|
setIsLoading(false);
|
||||||
logger.debug('Success:', result);
|
logger.debug('Success:', result);
|
||||||
|
showNotification(
|
||||||
|
"Dossier d'inscription soumis avec succès",
|
||||||
|
'success',
|
||||||
|
'Succès'
|
||||||
|
);
|
||||||
router.push(FE_PARENTS_HOME_URL);
|
router.push(FE_PARENTS_HOME_URL);
|
||||||
} catch (error) {
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
setIsLoading(false);
|
||||||
|
showNotification(
|
||||||
|
"Erreur lors de la soumission du dossier d'inscription",
|
||||||
|
'error',
|
||||||
|
'Erreur'
|
||||||
|
);
|
||||||
logger.error('Error:', error);
|
logger.error('Error:', error);
|
||||||
}
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (isLoading === true) {
|
||||||
|
return <Loader />; // Affichez le composant Loader
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InscriptionFormShared
|
<InscriptionFormShared
|
||||||
studentId={studentId}
|
studentId={studentId}
|
||||||
|
|||||||
@ -230,7 +230,7 @@ export default function FilesToUpload({
|
|||||||
<div className="mt-4">
|
<div className="mt-4">
|
||||||
{actionType === 'view' && selectedFile.fileName ? (
|
{actionType === 'view' && selectedFile.fileName ? (
|
||||||
<iframe
|
<iframe
|
||||||
src={`${BASE_URL}/${selectedFile.fileName}`}
|
src={`${BASE_URL}${selectedFile.fileName}`}
|
||||||
title="Document Viewer"
|
title="Document Viewer"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@ -112,8 +112,13 @@ export default function StudentInfoForm({
|
|||||||
(field === 'birth_place' &&
|
(field === 'birth_place' &&
|
||||||
(!formData.birth_place || formData.birth_place.trim() === '')) ||
|
(!formData.birth_place || formData.birth_place.trim() === '')) ||
|
||||||
(field === 'birth_postal_code' &&
|
(field === 'birth_postal_code' &&
|
||||||
(!formData.birth_postal_code ||
|
(
|
||||||
String(formData.birth_postal_code).trim() === '')) ||
|
!formData.birth_postal_code ||
|
||||||
|
String(formData.birth_postal_code).trim() === '' ||
|
||||||
|
isNaN(Number(formData.birth_postal_code)) ||
|
||||||
|
!Number.isInteger(Number(formData.birth_postal_code))
|
||||||
|
)
|
||||||
|
) ||
|
||||||
(field === 'address' &&
|
(field === 'address' &&
|
||||||
(!formData.address || formData.address.trim() === '')) ||
|
(!formData.address || formData.address.trim() === '')) ||
|
||||||
(field === 'attending_physician' &&
|
(field === 'attending_physician' &&
|
||||||
|
|||||||
Reference in New Issue
Block a user