mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: Création de clones lors de la création de RF [#22]
This commit is contained in:
@ -119,12 +119,13 @@ const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, r
|
||||
setExistingGuardians(student.guardians);
|
||||
};
|
||||
|
||||
const handleResponsableSelection = (guardianId) => {
|
||||
const handleResponsableSelection = (guardianId, guardianEmail) => {
|
||||
setFormData((prevData) => {
|
||||
const selectedGuardians = prevData.selectedGuardians.includes(guardianId)
|
||||
? prevData.selectedGuardians.filter(id => id !== guardianId)
|
||||
: [...prevData.selectedGuardians, guardianId];
|
||||
return { ...prevData, selectedGuardians };
|
||||
const isSelected = prevData.selectedGuardians.includes(guardianId);
|
||||
const selectedGuardians = isSelected
|
||||
? prevData.selectedGuardians.filter(id => id !== guardianId)
|
||||
: [...prevData.selectedGuardians, guardianId];
|
||||
return { ...prevData, selectedGuardians, guardianEmail };
|
||||
});
|
||||
};
|
||||
|
||||
@ -345,7 +346,7 @@ const InscriptionForm = ( { students, registrationDiscounts, tuitionDiscounts, r
|
||||
type="checkbox"
|
||||
checked={formData.selectedGuardians.includes(guardian.id)}
|
||||
className="form-checkbox h-5 w-5 text-emerald-600"
|
||||
onChange={() => handleResponsableSelection(guardian.id)}
|
||||
onChange={() => handleResponsableSelection(guardian.id, guardian.email)}
|
||||
/>
|
||||
<span className="text-gray-900">
|
||||
{guardian.last_name && guardian.first_name ? `${guardian.last_name} ${guardian.first_name}` : `${guardian.email}`}
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import ToggleSwitch from '@/components/ToggleSwitch'; // Import du composant ToggleSwitch
|
||||
import { fetchRegistrationFileGroups } from '@/app/actions/registerFileGroupAction';
|
||||
import { fetchRegistrationFileGroups, createRegistrationTemplates, cloneTemplate } from '@/app/actions/registerFileGroupAction';
|
||||
import { DocusealBuilder } from '@docuseal/react';
|
||||
import logger from '@/utils/logger';
|
||||
import { BE_DOCUSEAL_GET_JWT, BASE_URL } from '@/utils/Url';
|
||||
import Button from '@/components/Button'; // Import du composant Button
|
||||
import MultiSelect from '@/components/MultiSelect'; // Import du composant MultiSelect
|
||||
import { createRegistrationTemplates } from '@/app/actions/registerFileGroupAction';
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
|
||||
export default function FileUpload({ handleCreateTemplateMaster, handleEditTemplateMaster, fileToEdit = null, onSuccess }) {
|
||||
@ -138,33 +137,6 @@ export default function FileUpload({ handleCreateTemplateMaster, handleEditTempl
|
||||
|
||||
};
|
||||
|
||||
const cloneTemplate = (templateId, email) => {
|
||||
return fetch('/api/docuseal/cloneTemplate', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
templateId,
|
||||
email
|
||||
})
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
return response.json().then(err => { throw new Error(err.message); });
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
logger.debug('Template cloned successfully:', data);
|
||||
return data;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error cloning template:', error);
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="h-full flex flex-col mt-4 space-y-4">
|
||||
<div className="grid grid-cols-10 gap-4 items-start">
|
||||
|
||||
@ -66,7 +66,6 @@ export default function FilesGroupsManagement({ csrfToken }) {
|
||||
|
||||
const deleteTemplateMaster = (templateMaster) => {
|
||||
// Supprimer les clones associés via l'API DocuSeal
|
||||
console.log(templates)
|
||||
const removeClonesPromises = templates
|
||||
.filter(template => template.master === templateMaster.template_id)
|
||||
.map(template => removeTemplate(template.template_id));
|
||||
|
||||
Reference in New Issue
Block a user