diff --git a/client/src/components/CustomTable.tsx b/client/src/components/CustomTable.tsx index cd218d5..944758e 100644 --- a/client/src/components/CustomTable.tsx +++ b/client/src/components/CustomTable.tsx @@ -32,7 +32,7 @@ const CustomTable = () => { { id: 2, name: 'Jane Smith', age: 30 }, { id: 3, name: 'Sam Green', age: 22 }, ]); - const [editingCell, setEditingCell] = useState({ rowIndex: null, columnId: null }); + const [editingCell, setEditingCell] = useState<{ rowIndex: string | number | null, columnId: string | number | null }>({ rowIndex: null, columnId: null }); const tableColumns = useMemo[]>(() => columns, []); @@ -50,7 +50,7 @@ const CustomTable = () => { value: DataType[keyof DataType] ) => { const updatedData = [...data]; - updatedData[rowIndex][columnId] = value; + (updatedData[rowIndex][columnId] as DataType[keyof DataType]) = value; setData(updatedData); //setEditingCell({ rowIndex: null, columnId: null }); }; @@ -90,8 +90,8 @@ const CustomTable = () => { {isEditing ? ( handleEditCell(rowIndex, cell.column.id, e.target.value)} + value={data[rowIndex][cell.column.id as keyof DataType]} + onChange={(e) => handleEditCell(rowIndex, (cell.column.id as keyof DataType), e.target.value)} onBlur={() => setEditingCell({ rowIndex: null, columnId: null })} autoFocus /> diff --git a/client/src/components/FolderViewer.tsx b/client/src/components/FolderViewer.tsx index ab220a7..f3abac1 100644 --- a/client/src/components/FolderViewer.tsx +++ b/client/src/components/FolderViewer.tsx @@ -4,19 +4,11 @@ import React, { useEffect, useState } from 'react' import DocumentService from '../services/DocumentService' import { mutate } from 'swr' import FileViewer from './modals/FileViewer' -import { ActionIcon, Anchor, Breadcrumbs, Button, Divider, FileButton, Flex, Loader, MantineStyleProp, RingProgress, ScrollAreaAutosize, Table, Text } from '@mantine/core' +import { ActionIcon, Anchor, Breadcrumbs, Button, Divider, FileButton, Flex, Loader, MantineStyleProp, RingProgress, ScrollAreaAutosize, Stack, Table, Text } from '@mantine/core' import { IconCancel, IconDownload, IconFile, IconFileFilled, IconFilePlus, IconFileUpload, IconFolderFilled, IconX } from '@tabler/icons-react' -interface FolderProps { - folder: IDocumentFolder; - index: number; - handleFolderClick: (folder: IDocumentFolder) => void; -} - interface DocumentProps { doc: IDocument; - index: number; - handleDocumentClick: (index: number) => void; } const FileItemStyle: MantineStyleProp = { @@ -29,22 +21,6 @@ const FileItemStyle: MantineStyleProp = { padding: '8px' } -function ItemFolder({ folder, handleFolderClick, ...props }: FolderProps) { - return ( - handleFolderClick(folder)} - > - - - {folder.name} - - - ) -} - const handleSave = async (file: Blob, filename: string) => { const link = document.createElement('a') link.href = window.URL.createObjectURL(file) @@ -54,7 +30,7 @@ const handleSave = async (file: Blob, filename: string) => { window.URL.revokeObjectURL(link.href) } -function ItemDocument({ doc, index, handleDocumentClick, ...props }: DocumentProps) { +function ItemDocument({ doc }: DocumentProps) { const [shouldFetch, setShouldFetch] = useState(false) const { file, isLoading } = useDownload(shouldFetch ? doc?.document_folder_id : null, shouldFetch ? doc?.id : null) @@ -66,33 +42,24 @@ function ItemDocument({ doc, index, handleDocumentClick, ...props }: DocumentPro setShouldFetch(false) } } - }, [shouldFetch, file]) + }, [shouldFetch, file, doc.name]) return ( - - handleDocumentClick(index)} - {...props} - > - - {doc.name} - - - { - if (!isLoading) { - setShouldFetch(true) - } - }} - variant='subtle'> - {isLoading ? - - : - + + { + e.stopPropagation() + if (!isLoading) { + setShouldFetch(true) } - - + }} + variant='subtle'> + {isLoading ? + + : + + } + ) } @@ -175,133 +142,151 @@ export default function FolderViewer() { return ( - + {fileViewerModal && + + } + - - { - setCurrentFolder(null) - setBreadcrumbs([]) - }} - > - Главная - - {breadcrumbs.map((breadcrumb, index) => ( + + handleBreadcrumbClick(index)} + onClick={() => { + setCurrentFolder(null) + setBreadcrumbs([]) + }} > - {breadcrumb.name} + Главная - ))} - + {breadcrumbs.map((breadcrumb, index) => ( + handleBreadcrumbClick(index)} + > + {breadcrumb.name} + + ))} + - {currentFolder && - - 0 ? '1px dashed gray' : 'none', - borderRadius: '8px', - }}> - - - {(props) => } - + {currentFolder && + + 0 ? '1px dashed gray' : 'none', + borderRadius: '8px', + }}> + + + {(props) => } + - {filesToUpload.length > 0 && - <> - + {filesToUpload.length > 0 && + <> + - - - } - + + + } + - + - {filesToUpload.length > 0 && - - {filesToUpload.map((file, index) => ( - - - - {file.name} - + {filesToUpload.length > 0 && + + {filesToUpload.map((file, index) => ( + + + + {file.name} + - { - setFilesToUpload(prev => { - return prev.filter((_, i) => i != index) - }) - }} ml='auto' variant='subtle'> - - - - ))} - - } + { + setFilesToUpload(prev => { + return prev.filter((_, i) => i != index) + }) + }} ml='auto' variant='subtle'> + + + + ))} + + } + - - } - - - - + } - - +
+ + + Название + Дата создания + + + - - {currentFolder ? ( - documents?.map((doc: IDocument, index: number) => ( - - - - - - )) - ) : ( - folders?.map((folder: IDocumentFolder, index: number) => ( - - - - - - )) - )} - -
+ + {currentFolder ? ( + documents?.map((doc: IDocument, index: number) => ( + handleDocumentClick(index)} style={{ cursor: 'pointer' }}> + + + + {doc.name} + + + + {new Date(doc.create_date).toLocaleDateString()} + + + + + + )) + ) : ( + folders?.map((folder: IDocumentFolder) => ( + handleFolderClick(folder)} style={{ cursor: 'pointer' }}> + + + + {folder.name} + + + + {new Date(folder.create_date).toLocaleDateString()} + + + + + )) + )} + + +
) } \ No newline at end of file diff --git a/client/src/constants/app.tsx b/client/src/constants/app.tsx index 815f744..c7e7369 100644 --- a/client/src/constants/app.tsx +++ b/client/src/constants/app.tsx @@ -133,7 +133,7 @@ const pages = [ component: , drawer: true, dashboard: true, - enabled: true, + enabled: false, }, { label: "Table test", @@ -142,7 +142,7 @@ const pages = [ component: , drawer: true, dashboard: true, - enabled: true, + enabled: false, }, { label: "Component test", @@ -151,7 +151,7 @@ const pages = [ component: , drawer: true, dashboard: true, - enabled: true, + enabled: false, }, ]