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:
@ -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