feat: ✨ implement manually add file, use every() to check if pdfs can be dropped, implement file delete, remove nested scrollarea for document preview
This commit is contained in:
parent
c5eb0115dd
commit
e6c0e16e84
@ -23,6 +23,7 @@ import {
|
|||||||
IconDownload,
|
IconDownload,
|
||||||
IconEye,
|
IconEye,
|
||||||
IconEyeOff,
|
IconEyeOff,
|
||||||
|
IconFilePlus,
|
||||||
IconFiles,
|
IconFiles,
|
||||||
IconLayoutSidebarLeftCollapse,
|
IconLayoutSidebarLeftCollapse,
|
||||||
IconLayoutSidebarLeftExpand,
|
IconLayoutSidebarLeftExpand,
|
||||||
@ -314,26 +315,52 @@ function Organizrr() {
|
|||||||
<Group>
|
<Group>
|
||||||
<IconFiles />
|
<IconFiles />
|
||||||
<Title order={3}>Files</Title>
|
<Title order={3}>Files</Title>
|
||||||
|
<ActionIcon
|
||||||
|
variant="subtle"
|
||||||
|
ml="auto"
|
||||||
|
onClick={() => {
|
||||||
|
const id = Math.random().toString(36).replace("0.", "file_");
|
||||||
|
form.insertListItem("files", { id, documents: [] });
|
||||||
|
setActiveFile(form.getValues().files.length - 1);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<IconFilePlus />
|
||||||
|
</ActionIcon>
|
||||||
</Group>
|
</Group>
|
||||||
</AppShell.Section>
|
</AppShell.Section>
|
||||||
<AppShell.Section grow my="md" component={ScrollArea}>
|
<AppShell.Section grow my="md" component={ScrollArea}>
|
||||||
<Stack>
|
<Stack>
|
||||||
{form.values.files.map((f, idx) => (
|
{form.values.files.map((f, idx) => (
|
||||||
<Stack key={f.id} gap="xs">
|
<Stack key={f.id} gap="xs">
|
||||||
<Button
|
<Group>
|
||||||
variant={idx === activeFile ? "" : "subtle"}
|
<Button
|
||||||
onClick={() => {
|
variant={idx === activeFile ? "" : "subtle"}
|
||||||
setActiveFile(idx);
|
onClick={() => {
|
||||||
closeMobile();
|
setActiveFile(idx);
|
||||||
}}
|
closeMobile();
|
||||||
rightSection={
|
}}
|
||||||
generatingFilenames.includes(f.id) ? (
|
rightSection={
|
||||||
<Loader size="xs" type="bars" color="white" />
|
generatingFilenames.includes(f.id) ? (
|
||||||
) : null
|
<Loader size="xs" type="bars" color="white" />
|
||||||
}
|
) : null
|
||||||
>
|
}
|
||||||
<Text>{f.suffix || f.id}</Text>
|
style={{ flex: 1 }}
|
||||||
</Button>
|
>
|
||||||
|
<Text>{f.suffix || f.id}</Text>
|
||||||
|
</Button>
|
||||||
|
<ActionIcon
|
||||||
|
onClick={() => {
|
||||||
|
if (activeFile === idx) {
|
||||||
|
setActiveFile(null);
|
||||||
|
}
|
||||||
|
form.removeListItem("files", idx);
|
||||||
|
}}
|
||||||
|
variant="subtle"
|
||||||
|
c="red"
|
||||||
|
>
|
||||||
|
<IconTrash />
|
||||||
|
</ActionIcon>
|
||||||
|
</Group>
|
||||||
{activeFile != idx &&
|
{activeFile != idx &&
|
||||||
form.errors &&
|
form.errors &&
|
||||||
Object.entries(form.errors)
|
Object.entries(form.errors)
|
||||||
@ -480,14 +507,12 @@ function Organizrr() {
|
|||||||
</Stack>
|
</Stack>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
{form.values.documents
|
{form.values.files[activeFile].documents.every((doc) =>
|
||||||
.find(
|
form.values.documents
|
||||||
(doc) =>
|
.find((d) => d.id === doc.id)
|
||||||
doc.id ===
|
?.file.name.toLowerCase()
|
||||||
form.values.files[activeFile]?.documents[0].id
|
.endsWith(".pdf")
|
||||||
)
|
) && (
|
||||||
?.file.name.toLowerCase()
|
|
||||||
.endsWith(".pdf") && (
|
|
||||||
<Stack
|
<Stack
|
||||||
w={300}
|
w={300}
|
||||||
key={form.values.files[activeFile]?.documents.length}
|
key={form.values.files[activeFile]?.documents.length}
|
||||||
@ -540,16 +565,12 @@ function Organizrr() {
|
|||||||
<Stack align="center">
|
<Stack align="center">
|
||||||
{activeDocument &&
|
{activeDocument &&
|
||||||
activeDocument.file.name.toLowerCase().endsWith(".pdf") && (
|
activeDocument.file.name.toLowerCase().endsWith(".pdf") && (
|
||||||
<>
|
<Document
|
||||||
<ScrollArea maw="100%">
|
file={activeDocument.file}
|
||||||
<Document
|
onLoadSuccess={onDocumentLoadSuccess}
|
||||||
file={activeDocument.file}
|
>
|
||||||
onLoadSuccess={onDocumentLoadSuccess}
|
<Page pageNumber={pageNumber} scale={0.8} />
|
||||||
>
|
</Document>
|
||||||
<Page pageNumber={pageNumber} scale={0.8} />
|
|
||||||
</Document>
|
|
||||||
</ScrollArea>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</AppShell.Section>
|
</AppShell.Section>
|
||||||
|
Loading…
Reference in New Issue
Block a user