refactor: consolidate message display options into a shared MessageOptions interface.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { assignCorrespondentsBulk } from '../../lib/apiClient';
|
import { assignCorrespondentsBulk } from '../../lib/apiClient';
|
||||||
import type { Identifier } from '../../types/identifiers';
|
import type { Identifier } from '../../types/identifiers';
|
||||||
|
import type { MessageOptions } from '../../types/documents';
|
||||||
|
|
||||||
type BulkAssignmentResponse = {
|
type BulkAssignmentResponse = {
|
||||||
assigned?: number;
|
assigned?: number;
|
||||||
@@ -18,8 +19,8 @@ interface UseBulkDocumentActionsArgs {
|
|||||||
setStatusMessage: (message: string, variant?: string) => void;
|
setStatusMessage: (message: string, variant?: string) => void;
|
||||||
selectedDocumentIds?: Identifier[];
|
selectedDocumentIds?: Identifier[];
|
||||||
selectedFolderIds?: Identifier[];
|
selectedFolderIds?: Identifier[];
|
||||||
handleDocumentsDelete: (ids: Identifier[], options?: { showMessage?: boolean }) => Promise<boolean>;
|
handleDocumentsDelete: (ids: Identifier[], options?: MessageOptions) => Promise<boolean>;
|
||||||
handleFolderDelete: (id: Identifier, options?: { showMessage?: boolean }) => Promise<boolean>;
|
handleFolderDelete: (id: Identifier, options?: MessageOptions) => Promise<boolean>;
|
||||||
clearDocumentSelection: () => void;
|
clearDocumentSelection: () => void;
|
||||||
updateDocumentCaches?: (id: Identifier, updater: (doc: any) => any) => void;
|
updateDocumentCaches?: (id: Identifier, updater: (doc: any) => any) => void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
updateDocument,
|
updateDocument,
|
||||||
} from '../../lib/apiClient';
|
} from '../../lib/apiClient';
|
||||||
import type { DocumentId, FolderId as FolderIdentifier } from '../../types/identifiers';
|
import type { DocumentId, FolderId as FolderIdentifier } from '../../types/identifiers';
|
||||||
import type { Document } from '../../types/documents';
|
import type { Document, MessageOptions } from '../../types/documents';
|
||||||
|
|
||||||
type FolderId = FolderIdentifier | 'root';
|
type FolderId = FolderIdentifier | 'root';
|
||||||
type NullableFolderId = FolderId | null;
|
type NullableFolderId = FolderId | null;
|
||||||
@@ -78,10 +78,6 @@ interface DocumentTagExtras {
|
|||||||
input?: { value?: string } | null;
|
input?: { value?: string } | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MessageOptions {
|
|
||||||
showMessage?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface UseDocumentMutationsArgs {
|
interface UseDocumentMutationsArgs {
|
||||||
token?: string | null;
|
token?: string | null;
|
||||||
documentLookup: Map<DocumentId, Document>;
|
documentLookup: Map<DocumentId, Document>;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
renameFolder as renameFolderRequest,
|
renameFolder as renameFolderRequest,
|
||||||
} from '../../lib/apiClient';
|
} from '../../lib/apiClient';
|
||||||
import type { FolderId } from '../../types/identifiers';
|
import type { FolderId } from '../../types/identifiers';
|
||||||
|
import type { MessageOptions } from '../../types/documents';
|
||||||
|
|
||||||
type FolderKey = FolderId | 'root';
|
type FolderKey = FolderId | 'root';
|
||||||
|
|
||||||
@@ -409,7 +410,7 @@ const useFolderTreeActions = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleFolderDelete = useCallback(
|
const handleFolderDelete = useCallback(
|
||||||
async (folderId: FolderKey, { showMessage = true }: { showMessage?: boolean } = {}) => {
|
async (folderId: FolderKey, { showMessage = true }: MessageOptions = {}) => {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
if (showMessage) {
|
if (showMessage) {
|
||||||
setStatusMessage('Log in to manage folders.', 'error');
|
setStatusMessage('Log in to manage folders.', 'error');
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ export interface DocumentVersion {
|
|||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MessageOptions {
|
||||||
|
showMessage?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface Document {
|
export interface Document {
|
||||||
id?: Identifier;
|
id?: Identifier;
|
||||||
title?: string | null;
|
title?: string | null;
|
||||||
|
|||||||
Reference in New Issue
Block a user