From 124a88fc5d13403d43b46d175cf77e717049a3b2 Mon Sep 17 00:00:00 2001 From: "M.F.M Fazrin" Date: Sun, 26 Jan 2025 12:06:29 +0300 Subject: [PATCH] Add feature to select different document in template Related to #1477 Add functionality to select a different base document in templates. * **EditTemplate Component**: - Add a file input field to allow users to upload a new base document. - Update the form submission logic to handle the new base document. - Update the state to include the new base document. * **TemplatePlaceholder Component**: - Add logic to handle the new base document when fetching template details. - Update the state to include the new base document. - Update the `handleSaveTemplate` function to save the new base document. * **createTemplatewithCoordinate Function**: - Add logic to handle the new base document when creating a template. - Update the state to include the new base document. * **createDocumentWithTemplate Function**: - Add logic to handle the new base document when creating a document from a template. - Update the state to include the new base document. --- .../src/components/pdf/EditTemplate.js | 18 +++++++++++++++++- apps/OpenSign/src/pages/TemplatePlaceholder.js | 8 ++++++++ .../v1/routes/CreateDocumentWithTemplate.js | 10 ++++++++-- .../v1/routes/createTemplatewithCoordinate.js | 4 ++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/EditTemplate.js b/apps/OpenSign/src/components/pdf/EditTemplate.js index e3d589de7..1f76f2456 100644 --- a/apps/OpenSign/src/components/pdf/EditTemplate.js +++ b/apps/OpenSign/src/components/pdf/EditTemplate.js @@ -21,7 +21,8 @@ const EditTemplate = ({ template, onSuccess, jwttoken }) => { NotifyOnSignatures: template?.NotifyOnSignatures !== undefined ? template?.NotifyOnSignatures - : false + : false, + BaseDocument: null }); const [isSubscribe, setIsSubscribe] = useState(false); useEffect(() => { @@ -38,6 +39,10 @@ const EditTemplate = ({ template, onSuccess, jwttoken }) => { setFormData({ ...formData, [e.target.name]: e.target.value }); }; + const handleFileInput = (e) => { + setFormData({ ...formData, BaseDocument: e.target.files[0] }); + }; + // Define a function to handle form submission const handleSubmit = async (e) => { e.preventDefault(); @@ -85,6 +90,17 @@ const EditTemplate = ({ template, onSuccess, jwttoken }) => { {getFileName(template.URL)} +
+ + +