+
+
+
+
Document Library Foundation
+
+ Manage reusable PDF documents such as SLA, warranty, datasheet, and profile files.
+
+
+
+
+
+
+
+
+
+
+
+
+ {filteredItems.length === 0 ? (
+
+ No document library items match the current filters.
+
+ ) : (
+ filteredItems.map((item) => (
+
+
+
+
{item.name}
+
+ {item.code} • {item.documentType} • {item.brand} • {item.language} •{' '}
+ {item.productType}
+
+
+ {item.description || 'No description provided.'}
+
+
+
+ {item.status}
+ Active {item.activeVersion ?? '-'}
+ {item.versionCount} version(s)
+
+
+
+
+
+
+
+ ))
+ )}
+
+
setDialogState((current) => ({ ...current, open }))}
+ library={dialogState.library}
+ />
+
+ {detailState.open && detailState.libraryId ? (
+
+ setDetailState((current) => ({ ...current, open }))}
+ />
+
+ ) : null}
+
+ );
+}
diff --git a/src/features/foundation/document-library/mutations.ts b/src/features/foundation/document-library/mutations.ts
new file mode 100644
index 0000000..3bdd48c
--- /dev/null
+++ b/src/features/foundation/document-library/mutations.ts
@@ -0,0 +1,101 @@
+import { mutationOptions } from '@tanstack/react-query';
+import { getQueryClient } from '@/lib/query-client';
+import {
+ activateDocumentLibraryVersion,
+ archiveDocumentLibraryVersion,
+ createDocumentLibrary,
+ deleteDraftDocumentLibraryVersion,
+ publishDocumentLibraryVersion,
+ updateDocumentLibrary,
+ uploadDocumentLibraryVersion
+} from './service';
+import { documentLibraryKeys } from './queries';
+import type {
+ DocumentLibraryMutationPayload,
+ DocumentLibraryVersionUploadPayload
+} from './types';
+
+async function invalidateLibraryLists() {
+ await getQueryClient().invalidateQueries({ queryKey: documentLibraryKeys.lists() });
+}
+
+async function invalidateLibraryDetail(id: string) {
+ await getQueryClient().invalidateQueries({ queryKey: documentLibraryKeys.detail(id) });
+}
+
+export const createDocumentLibraryMutation = mutationOptions({
+ mutationFn: (values: DocumentLibraryMutationPayload) => createDocumentLibrary(values),
+ onSettled: async (_data, error) => {
+ if (!error) {
+ await invalidateLibraryLists();
+ }
+ }
+});
+
+export const updateDocumentLibraryMutation = mutationOptions({
+ mutationFn: ({
+ id,
+ values
+ }: {
+ id: string;
+ values: Partial