diff --git a/public/icons/private.svg b/public/icons/private.svg new file mode 100644 index 0000000..5c0eb3f --- /dev/null +++ b/public/icons/private.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/icons/public.svg b/public/icons/public.svg new file mode 100644 index 0000000..fc36d82 --- /dev/null +++ b/public/icons/public.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/_components/ActionButtons.tsx b/src/app/_components/ActionButtons.tsx index 2253ca9..23b2f59 100644 --- a/src/app/_components/ActionButtons.tsx +++ b/src/app/_components/ActionButtons.tsx @@ -1,13 +1,14 @@ "use client"; import { useRef, useState } from "react"; import { useFileActions } from "~/app/_components/FileActions"; +import toast from "react-hot-toast"; export function FileActionsContainer({ fileId, fileName, fileUrl, isOwner, - isPublic, + isPublic: initialIsPublic, // Rename to avoid conflict with local state }: { fileId: string; fileName: string; @@ -15,77 +16,91 @@ export function FileActionsContainer({ isOwner: boolean; isPublic: boolean; }) { - const { handleDownload, handleCopyUrl, handleRemove} = useFileActions(() => fileId, (description: string) => { - if (isOwner) { - console.log(description); + const [isPublic, setIsPublic] = useState(initialIsPublic); // Local state for toggle + const { handleDownload, handleCopyUrl, handleRemove } = useFileActions( + () => fileId, + (description: string) => { + if (isOwner) { + console.log(description); + } } - }); + ); return ( -
+
{/* Download Button */} {/* Copy URL Button */} + {/* Remove Button */} {isOwner && ( )} + + {/* Public/Private Toggle */} {isOwner && ( -
- - -
+ )}
); @@ -98,12 +113,15 @@ export function FileDescriptionContainer({ fileId: string; fileDescription?: string; }) { - const [description, setDescription] = useState(fileDescription || ""); // Add state for description - const { handleDescriptionChange } = useFileActions(() => {}, (description: string) => { - setDescription(description); - return undefined; - }, fileId); // Wrap setDescription in a function + const { handleDescriptionChange } = useFileActions( + () => {}, + (description: string) => { + setDescription(description); + return undefined; + }, + fileId, + ); // Wrap setDescription in a function const debounceTimer = useRef(null); // Initialize debounce timer const handleChange = (e: React.ChangeEvent) => { @@ -111,9 +129,9 @@ export function FileDescriptionContainer({ }; return ( -
+