diff --git a/src/front/Components/DesignSystem/Form/index.tsx b/src/front/Components/DesignSystem/Form/index.tsx index 94a9f082..78c00e4e 100644 --- a/src/front/Components/DesignSystem/Form/index.tsx +++ b/src/front/Components/DesignSystem/Form/index.tsx @@ -44,7 +44,7 @@ export const FormContext = React.createContext({ export default class Form extends React.Component { protected fields: IFields = {}; - private formRef: React.RefObject; + public formRef: React.RefObject; constructor(props: IProps) { super(props); diff --git a/src/front/Components/Layouts/ClientDashboard/DepositDocumentComponent/index.tsx b/src/front/Components/Layouts/ClientDashboard/DepositDocumentComponent/index.tsx index a9d3c824..3856673e 100644 --- a/src/front/Components/Layouts/ClientDashboard/DepositDocumentComponent/index.tsx +++ b/src/front/Components/Layouts/ClientDashboard/DepositDocumentComponent/index.tsx @@ -59,7 +59,7 @@ export default function DepositDocumentComponent(props: IProps) { if (!refused_reason) return; setRefusedReason(refused_reason); setIsModalOpen(true); - }, []); + }, [document.document_history]); const closeModal = useCallback(() => { setIsModalOpen(false); diff --git a/src/front/Components/Layouts/ClientDashboard/ReceivedDocuments/index.tsx b/src/front/Components/Layouts/ClientDashboard/ReceivedDocuments/index.tsx index 7f000e22..08eaf07c 100644 --- a/src/front/Components/Layouts/ClientDashboard/ReceivedDocuments/index.tsx +++ b/src/front/Components/Layouts/ClientDashboard/ReceivedDocuments/index.tsx @@ -85,7 +85,7 @@ export default function ReceivedDocuments() { DocumentsNotary.getInstance() .get({ where: { folder: { uid: folderUid }, customer: { uid: customerUid } }, include: { files: true } }) .then((documentsNotary) => setDocumentsNotary(documentsNotary)); - }, [folderUid, customer]); + }, [folderUid, customer, fetchFolderAndCustomer]); const onDownload = useCallback((doc: DocumentNotary) => { const file = doc.files?.[0]; diff --git a/src/front/Components/Layouts/ClientDashboard/index.tsx b/src/front/Components/Layouts/ClientDashboard/index.tsx index 578bd6d3..9d6761de 100644 --- a/src/front/Components/Layouts/ClientDashboard/index.tsx +++ b/src/front/Components/Layouts/ClientDashboard/index.tsx @@ -144,7 +144,7 @@ export default function ClientDashboard(props: IProps) { })} /> ); - }, [customer, folderUid, isAddDocumentModalVisible, onCloseModalAddDocument]); + }, [customer, folderUid, isAddDocumentModalVisible, onCloseModalAddDocument, folder]); return ( diff --git a/src/front/Components/Layouts/Folder/AskDocuments/index.tsx b/src/front/Components/Layouts/Folder/AskDocuments/index.tsx index 7b1503ae..62844701 100644 --- a/src/front/Components/Layouts/Folder/AskDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/AskDocuments/index.tsx @@ -36,16 +36,15 @@ export default function AskDocuments() { const getSelectedDocumentTypes = () => { // Get all checked checkboxes if (!formRef.current) return []; - + const formElement = formRef.current.formRef.current; if (!formElement) return []; - - const checkboxes = Array.from(formElement.elements) - .filter(elem => elem.getAttribute("type") === "checkbox" && elem.getAttribute("name") === "document_types") as HTMLInputElement[]; - - return checkboxes - .filter(checkbox => checkbox.checked) - .map(checkbox => checkbox.value); + + const checkboxes = Array.from(formElement.elements).filter( + (elem) => elem.getAttribute("type") === "checkbox" && elem.getAttribute("name") === "document_types", + ) as HTMLInputElement[]; + + return checkboxes.filter((checkbox) => checkbox.checked).map((checkbox) => checkbox.value); }; const onFormSubmit = useCallback( @@ -147,19 +146,20 @@ export default function AskDocuments() { // Update checkboxes after data has been refreshed const updateCheckedState = useCallback(() => { if (!formRef.current || selectedDocumentTypes.length === 0) return; - + const formElement = formRef.current.formRef.current; if (!formElement) return; - + // Check all checkboxes that were previously selected - const checkboxes = Array.from(formElement.elements) - .filter(elem => elem.getAttribute("type") === "checkbox" && elem.getAttribute("name") === "document_types") as HTMLInputElement[]; - - checkboxes.forEach(checkbox => { + const checkboxes = Array.from(formElement.elements).filter( + (elem) => elem.getAttribute("type") === "checkbox" && elem.getAttribute("name") === "document_types", + ) as HTMLInputElement[]; + + checkboxes.forEach((checkbox) => { if (selectedDocumentTypes.includes(checkbox.value)) { checkbox.checked = true; // Trigger change to update the internal state of CheckBox component - const event = new Event('change', { bubbles: true }); + const event = new Event("change", { bubbles: true }); checkbox.dispatchEvent(event); } }); @@ -180,16 +180,16 @@ export default function AskDocuments() { const backUrl = Module.getInstance() .get() .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folderUid as string); - + const handleDocumentsUpdated = async (newDocumentTypes: IOption[]) => { // Store existing selections const existingSelections = getSelectedDocumentTypes(); - + // Update document types with new ones setDocumentTypes([...documentTypes, ...newDocumentTypes]); - + // Set these as selected - setSelectedDocumentTypes([...existingSelections, ...newDocumentTypes.map(dt => dt.value as string)]); + setSelectedDocumentTypes([...existingSelections, ...newDocumentTypes.map((dt) => dt.value as string)]); }; return ( @@ -215,10 +215,10 @@ export default function AskDocuments() { ); } return ( - ); @@ -246,9 +246,9 @@ export default function AskDocuments() { {folder && ( - diff --git a/src/front/Components/Layouts/Folder/DocumentsReminderHistory/index.tsx b/src/front/Components/Layouts/Folder/DocumentsReminderHistory/index.tsx index 932fb846..d59907e6 100644 --- a/src/front/Components/Layouts/Folder/DocumentsReminderHistory/index.tsx +++ b/src/front/Components/Layouts/Folder/DocumentsReminderHistory/index.tsx @@ -74,7 +74,7 @@ export default function DocumentsReminderHistory(props: IProps) { setTotalPages(totalPages); }) .catch((e) => console.warn(e)); - }, [pageSize]); + }, [pageSize, folderUid]); const fetchReminders = useCallback(() => { DocumentReminders.getInstance() @@ -109,7 +109,7 @@ export default function DocumentsReminderHistory(props: IProps) { setReminders(response); // Set the reminders }) .catch((e) => console.warn(e)); - }, [customerOption, page, pageSize]); // Update on page change + }, [customerOption, page, pageSize, folderUid]); // Update on page change const fetchCustomers = useCallback(async () => { if (!folderUid) return; diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx index 45394578..34623121 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/ClientBox/index.tsx @@ -41,7 +41,7 @@ export default function ClientBox(props: IProps) { } props.onDelete(customerUid); }, - [closeDeleteModal, customer.documents, openErrorModal, props], + [closeDeleteModal, customer.documents, openErrorModal, props, customer, folderUid], ); let createOrUpdateNotePath = Module.getInstance()