diff --git a/apps/console/src/pages/organizations/documents/DocumentsPage.tsx b/apps/console/src/pages/organizations/documents/DocumentsPage.tsx index 6ee3ed22a..fdeca3ff6 100644 --- a/apps/console/src/pages/organizations/documents/DocumentsPage.tsx +++ b/apps/console/src/pages/organizations/documents/DocumentsPage.tsx @@ -6,7 +6,7 @@ import { IconPlusLarge, PageHeader, } from "@probo/ui"; -import { useState } from "react"; +import { useMemo, useState } from "react"; import { type PreloadedQuery, usePreloadedQuery, @@ -67,17 +67,21 @@ export default function DocumentsPage(props: { ({ node: { canSendSigningNotifications } }) => canSendSigningNotifications, ); - const [documentListConnectionId, setDocumentListConnectionId] = useState( - ConnectionHandler.getConnectionID( - organizationId, - "DocumentsListQuery_documents", - { - orderBy: { direction: "ASC", field: "TITLE" }, - filter: { documentTypes: null }, - }, - ), + const unfilteredConnectionId = useMemo( + () => + ConnectionHandler.getConnectionID( + organizationId, + "DocumentsListQuery_documents", + { + orderBy: { direction: "ASC", field: "TITLE" }, + filter: { documentTypes: null }, + }, + ), + [organizationId], ); + const [, setDocumentListConnectionId] = useState(unfilteredConnectionId); + const handleSendSigningNotifications = async () => { await sendSigningNotifications({ variables: { @@ -104,7 +108,7 @@ export default function DocumentsPage(props: { )} {organization.canCreateDocument && ( {__("New document")} } diff --git a/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx b/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx index 962fcf2ec..cddab515c 100644 --- a/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx +++ b/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx @@ -86,7 +86,18 @@ export function DocumentList(props: { const handleDocumentTypeFilterChange = (value: string) => { const newType = value === "ALL" ? null : (value as DocumentType); + clear(); setDocumentTypeFilter(newType); + onConnectionIdChange( + ConnectionHandler.getConnectionID( + organizationId, + "DocumentsListQuery_documents", + { + orderBy: { direction: "ASC", field: "TITLE" }, + filter: { documentTypes: newType ? [newType] : null }, + }, + ), + ); startTransition(() => { pagination.refetch( { documentTypes: newType ? [newType] : null }, @@ -165,7 +176,7 @@ export function DocumentList(props: { onValueChange={handleDocumentTypeFilterChange} > - {documentTypes.map((type) => ( + {documentTypes.map(type => ( @@ -174,140 +185,140 @@ export function DocumentList(props: {
{documents.length > 0 - ? ( - ["refetch"]} - > - - {selection.length === 0 - ? ( - - - 0 - } - onChange={() => reset(documents.map(d => d.id))} - /> - - - {__("Name")} - - {__("Status")} - {__("Version")} - - {__("Type")} - - {__("Classification")} - {__("Approvers")} - {__("Last update")} - {__("Signatures")} - {hasAnyAction && } - - ) - : ( - - -
-
- {sprintf(__("%s documents selected"), selection.length)} - {" "} - - - -
-
- {canUpdateAny && ( - - - - )} - {canRequestAnySignatures && ( - - - - )} - - - - {canDeleteAny && ( - - )} -
-
- - - )} - - - {documents.map(document => ( - toggle(document.id)} - key={document.id} - fragmentRef={document} - connectionId={connectionId} - hasAnyAction={hasAnyAction} - /> - ))} - -
- ) - : ( - -
-

- {__("No documents yet")} -

-

- {__("Create your first document to get started.")} -

-
-
- )} + ? ( + ["refetch"]} + > + + {selection.length === 0 + ? ( + + + 0 + } + onChange={() => reset(documents.map(d => d.id))} + /> + + + {__("Name")} + + {__("Status")} + {__("Version")} + + {__("Type")} + + {__("Classification")} + {__("Approvers")} + {__("Last update")} + {__("Signatures")} + {hasAnyAction && } + + ) + : ( + + +
+
+ {sprintf(__("%s documents selected"), selection.length)} + {" "} + - + +
+
+ {canUpdateAny && ( + + + + )} + {canRequestAnySignatures && ( + + + + )} + + + + {canDeleteAny && ( + + )} +
+
+ + + )} + + + {documents.map(document => ( + toggle(document.id)} + key={document.id} + fragmentRef={document} + connectionId={connectionId} + hasAnyAction={hasAnyAction} + /> + ))} + +
+ ) + : ( + +
+

+ {__("No documents yet")} +

+

+ {__("Create your first document to get started.")} +

+
+
+ )}
);