diff --git a/src/app/_components/ActionButtons.tsx b/src/app/_components/ActionButtons.tsx index 336a711..dcd89a4 100644 --- a/src/app/_components/ActionButtons.tsx +++ b/src/app/_components/ActionButtons.tsx @@ -1,5 +1,6 @@ 'use client'; -import {useFileActions} from "~/app/_components/FileActions"; +import { useRef, useState } from "react"; +import { useFileActions } from "~/app/_components/FileActions"; export function FileActionsContainer({ fileId, @@ -12,7 +13,7 @@ export function FileActionsContainer({ fileUrl: string; isOwner: boolean; }) { - const { handleDownload, handleCopyUrl, handleRemove } = useFileActions(() => fileId, (description: string) => { + const { handleDownload, handleCopyUrl, handleRemove} = useFileActions(() => fileId, (description: string) => { if (isOwner) { console.log(description); } @@ -84,4 +85,36 @@ export function FileActionsContainer({ ); +} + +export function FileDescriptionContainer({ + fileId, + fileDescriprtion, +}: { + fileId: string; + fileDescriprtion?: string; +}) { + + const [description, setDescription] = useState(fileDescriprtion || ""); // Add state for description + 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) => { + handleDescriptionChange(e, debounceTimer); // Pass the debounce timer + }; + + return ( +
+