ui-nyla/src/components/Dateien/dateienInterfaces.ts

98 lines
3 KiB
TypeScript

import { ColumnConfig } from '../FormGenerator';
import React from 'react';
import { EditFieldConfig } from '../Popup/EditForm';
// Re-export file-related interfaces from hooks
export type { UserFile, FileInfo } from '../../hooks/useFiles';
// Import for local use
import type { UserFile } from '../../hooks/useFiles';
// Component Props Interfaces
export interface DateienTableProps {
className?: string;
}
// Table Action Interface
export interface TableAction {
label: string;
onClick: (file: UserFile) => Promise<void> | void;
icon: React.ReactNode | ((file: UserFile) => React.ReactNode);
}
// File Operation Handler Types
export interface FileHandlers {
handleFileDownload: (fileId: string, fileName: string) => Promise<boolean>;
handleFileDelete: (fileId: string, onOptimisticDelete?: () => void) => Promise<boolean>;
handleFileUpload: (file: globalThis.File, workflowId?: string) => Promise<{ success: boolean; fileData?: any; error?: string }>;
handleFileUpdate: (fileId: string, updateData: Partial<{ fileName: string }>) => Promise<{ success: boolean; fileData?: any; error?: string }>;
}
// Hook Return Types for File Operations
export interface FileOperationsReturn extends FileHandlers {
downloadingFiles: Set<string>;
deletingFiles: Set<string>;
uploadingFile: boolean;
downloadError: string | null;
deleteError: string | null;
uploadError: string | null;
isLoading: boolean;
}
// Hook Return Types for User Files
export interface UserFilesReturn {
files: UserFile[];
loading: boolean;
error: string | null;
refetch: () => Promise<void>;
removeFileOptimistically: (fileId: string) => void;
addFileOptimistically: (newFile: UserFile) => void;
}
// File Table Configuration
export interface FileTableConfig {
columns: ColumnConfig[];
actions: TableAction[];
pageSize: number;
searchable: boolean;
filterable: boolean;
sortable: boolean;
resizable: boolean;
pagination: boolean;
}
// File Size Formatter Function Type
export type FileSizeFormatter = (sizeInBytes?: number) => string;
// Date Formatter Function Type
export type DateFormatter = (value?: string) => string;
// Hook Return Type for Dateien Logic
export interface DateienLogicReturn {
files: UserFile[];
loading: boolean;
error: string | null;
refetch: () => Promise<void>;
columns: ColumnConfig[];
actions: TableAction[];
downloadingFiles: Set<string>;
deletingFiles: Set<string>;
previewingFiles: Set<string>;
downloadError: string | null;
deleteError: string | null;
previewError: string | null;
editModalOpen: boolean;
editingFile: UserFile | null;
editFileFields: EditFieldConfig[];
previewModalOpen: boolean;
previewingFile: UserFile | null;
handleEditFile: (file: UserFile) => void;
handleSaveFile: (updatedFile: UserFile) => Promise<void>;
handleCancelEdit: () => void;
handlePreviewFile: (file: UserFile) => void;
handleClosePreview: () => void;
handleDelete: (file: UserFile) => Promise<void>;
handleDeleteMultiple: (files: UserFile[]) => Promise<void>;
}