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