Skip to content

Commit f29142c

Browse files
committed
feat(ResourceHeader): add resource header component with file selection and dialog functionality
1 parent 7f5ce03 commit f29142c

File tree

1 file changed

+101
-0
lines changed
  • app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/resources/components

1 file changed

+101
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import React from 'react';
2+
import { Button, Dialog, DropZone, Icon, Sheet, Text } from 'opub-ui';
3+
4+
import { Icons } from '@/components/icons';
5+
6+
interface ResourceHeaderProps {
7+
listViewFunction: () => void;
8+
isSheetOpen: boolean;
9+
setIsSheetOpen: (open: boolean) => void;
10+
dropZone:any;
11+
uploadedFile: React.ReactNode;
12+
file: File[];
13+
list: { value: string; label: string }[];
14+
resourceId: string;
15+
handleResourceChange: (resourceId: string) => void;
16+
}
17+
18+
const ResourceHeader = ({
19+
listViewFunction,
20+
isSheetOpen,
21+
setIsSheetOpen,
22+
dropZone,
23+
uploadedFile,
24+
file,
25+
list,
26+
resourceId,
27+
handleResourceChange,
28+
}:ResourceHeaderProps) => {
29+
return (
30+
<div>
31+
<div className="flex justify-between gap-6">
32+
<Button
33+
className=" h-fit w-fit justify-end"
34+
size="slim"
35+
kind="tertiary"
36+
variant="interactive"
37+
onClick={listViewFunction}
38+
>
39+
<span className="flex items-center gap-2">
40+
<Icon source={Icons.back} color="warning" size={24} />
41+
</span>
42+
</Button>
43+
44+
<Sheet open={isSheetOpen}>
45+
<Sheet.Trigger>
46+
<Button onClick={() => setIsSheetOpen(true)}>
47+
Select Data File
48+
</Button>
49+
</Sheet.Trigger>
50+
<Sheet.Content side="bottom">
51+
<div className="flex flex-col gap-6 p-10">
52+
<div className="flex items-center justify-between">
53+
<Text variant="bodyLg">Select Charts</Text>
54+
<div className="flex items-center gap-3">
55+
<Dialog>
56+
<Dialog.Trigger>
57+
<Button className=" mx-5">ADD NEW DATA FILE</Button>
58+
</Dialog.Trigger>
59+
<Dialog.Content title={'Add New Resource'}>
60+
<DropZone
61+
name="file_upload"
62+
allowMultiple={true}
63+
onDrop={dropZone}
64+
>
65+
{uploadedFile}
66+
{file.length === 0 && <DropZone.FileUpload />}
67+
</DropZone>
68+
</Dialog.Content>
69+
</Dialog>
70+
<Button kind="tertiary" onClick={() => setIsSheetOpen(false)}>
71+
<Icon source={Icons.cross} size={24} />
72+
</Button>
73+
</div>
74+
</div>
75+
{list.map((item, index) => (
76+
<div
77+
key={index}
78+
className={`rounded-1 border-1 border-solid border-baseGraySlateSolid6 px-6 py-3 ${resourceId === item.value ? ' bg-baseGraySlateSolid5' : ''}`}
79+
>
80+
<Button
81+
kind={'tertiary'}
82+
className="flex w-full justify-start"
83+
disabled={resourceId === item.value}
84+
onClick={(e) => {
85+
handleResourceChange(item.value);
86+
setIsSheetOpen(false);
87+
}}
88+
>
89+
{item.label}
90+
</Button>
91+
</div>
92+
))}
93+
</div>
94+
</Sheet.Content>
95+
</Sheet>
96+
</div>
97+
</div>
98+
);
99+
};
100+
101+
export default ResourceHeader;

0 commit comments

Comments
 (0)