diff --git a/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/DistributionList.tsx b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/DistributionList.tsx index e082f3db..9b52784b 100644 --- a/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/DistributionList.tsx +++ b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/DistributionList.tsx @@ -1,7 +1,10 @@ import React from 'react'; +import Link from 'next/link'; +import router from 'next/router'; import { Button, ButtonGroup, + Combobox, Divider, DropZone, Icon, @@ -12,6 +15,7 @@ import { bytesToSize } from '@/lib/utils'; import { Icons } from '@/components/icons'; import { LinkButton } from '@/components/Link'; import { EditDistribution } from './EditDistribution'; +import { EditResource } from './EditResource'; export function DistributionList({ setPage, @@ -40,21 +44,19 @@ const NoList = ({ const fileTypes = ['PDF', 'CSV', 'XLS', 'XLSX', 'TXT']; const [fileSelected, setFileSelected] = React.useState(false); - - const [file, setFile] = React.useState(); + const [file, setFile] = React.useState([]); const handleDropZoneDrop = React.useCallback( (_dropFiles: File[], acceptedFiles: File[]) => { - setFile(acceptedFiles[0]); + setFile((files) => [...files, ...acceptedFiles]); setFileSelected(true); }, [] ); - function handleFileDelete(props: React.MouseEvent) { - props.stopPropagation(); - setFileSelected(false); - setFile(undefined); + function handleFileDelete(index: any) { + const updatedFiles = [...file.slice(0, index), ...file.slice(index + 1)]; + setFile(updatedFiles); } const hint = ( @@ -76,42 +78,42 @@ const NoList = ({ ); - const fileUpload = !file && ; - const uploadedFile = file && ( -
-
- -
-
- - {file.name} - -
- - {bytesToSize(file.size)} - + const fileUpload = file.length === 0 && ( + + ); + const uploadedFile = file.length > 0 && ( +
+
+
+ +
{file[0].name.substring(0, 15) + ' ...'}
+ {file[0].size} bytes
-
); return ( - - {uploadedFile} - {fileUpload} - + <> + {fileSelected ? ( + + ) : ( + + {uploadedFile} + {fileUpload} + + )} + ); }; diff --git a/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx new file mode 100644 index 00000000..7d6bd2a0 --- /dev/null +++ b/app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditResource.tsx @@ -0,0 +1,269 @@ +import React from 'react'; +import Link from 'next/link'; +import GraphqlTable from '@/app/[locale]/dashboard/components/GraphqlTable/graphqlTable'; +import { IconTrash } from '@tabler/icons-react'; +import { + Button, + ButtonGroup, + Checkbox, + Combobox, + DataTable, + Divider, + DropZone, + Icon, + IconButton, + Text, + TextField, +} from 'opub-ui'; + +import { Icons } from '@/components/icons'; + +export const EditResource = ({ + uploadedFile, + handleDropZoneDrop, + file, +}: any) => { + const fileUpload = file.length === 0 && ; + + const table = { + columns: [ + { + accessorKey: 'field_key', + header: 'FIELD KEY', + }, + { + accessorKey: 'display_name', + header: 'DISPLAY NAME', + }, + { + accessorKey: 'description', + header: 'DESCRIPTION', + }, + { + accessorKey: 'format', + header: 'FORMAT', + }, + { + header: 'DELETE', + cell: ({ row }: any) => ( + console.log(row.original) } + > + Delete + + ), + }, + ], + rows: [ + { + field_key: 'date', + display_name: 'Date', + description: 'Date on which measurements are taken', + format: 'Date', + }, + { + field_key: 'date', + display_name: 'Date', + description: 'Date on which measurements are taken', + format: 'Date', + }, + { + field_key: 'date', + display_name: 'Date', + description: 'Date on which measurements are taken', + format: 'Date', + }, + ], + }; + + return ( +
+
+ Resource Name : +
+ +
+ + + + Go back to
+ Resource List +
+ + +
+ +
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ + {uploadedFile} + {fileUpload} + +
+
+
+
+ console.log('hi')}> + Enabel Preview + + +
+ +
+
+ + Select Rows to be
shown in the Preview +
+ + +
+
+
+ See Preview +
+
+
+ Fields in the Resource +
+ + Refetch Fields{' '} + + + + Reset Fields {' '} + + +
+
+ + The Field settings apply to the Resource on a master level and can not + be changed in Access Models. + +
+ +
+
+ ); +};