From d5ada17bbd4e04d02fd7a5bd288828f03cdbf886 Mon Sep 17 00:00:00 2001 From: Florian Trayon <26360935+FlorianLeChat@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:47:52 +0100 Subject: [PATCH] Fixed errors when uploading user files following NextJS 15 update --- .../dashboard/components/file-upload.tsx | 54 +++++++------------ 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/app/[locale]/dashboard/components/file-upload.tsx b/app/[locale]/dashboard/components/file-upload.tsx index db0b567..32859b7 100644 --- a/app/[locale]/dashboard/components/file-upload.tsx +++ b/app/[locale]/dashboard/components/file-upload.tsx @@ -59,9 +59,9 @@ import { Button, buttonVariants } from "../../components/ui/button"; export default function FileUpload( { states -}: { +}: Readonly<{ states: TableMeta; -} ) +}> ) { // Déclaration des variables d'état. const session = useSession(); @@ -69,8 +69,8 @@ export default function FileUpload( { const modalMessages = useTranslations( "modals" ); const [ key, setKey ] = useState( "" ); const [ quota, setQuota ] = useState( 0 ); - const [ isOpen, setOpen ] = useState( false ); - const [ isEncrypted, setEncrypted ] = useState( false ); + const [ isOpen, setIsOpen ] = useState( false ); + const [ isEncrypted, setIsEncrypted ] = useState( false ); const [ uploadState, uploadAction, isPending ] = useActionState( uploadFiles, { success: true, reason: "", @@ -257,8 +257,8 @@ export default function FileUpload( { // avant de réinitialiser le formulaire en cas de succès. if ( success ) { - setOpen( false ); - setEncrypted( false ); + setIsOpen( false ); + setIsEncrypted( false ); form.reset(); @@ -324,7 +324,7 @@ export default function FileUpload( { if ( !isPending ) { form.reset(); - setOpen( state ); + setIsOpen( state ); } }} > @@ -418,10 +418,8 @@ export default function FileUpload( { @@ -567,9 +561,7 @@ export default function FileUpload( { name={field.name} checked={field.value} disabled={isPending} - onCheckedChange={( - value - ) => + onCheckedChange={( value ) => { if ( value ) { @@ -584,7 +576,7 @@ export default function FileUpload( { // Mise à jour de l'état de chiffrement. field.onChange( value ); - setEncrypted( value ); + setIsEncrypted( value ); }} /> @@ -645,17 +637,14 @@ export default function FileUpload( { variant: "outline" } ), "w-full justify-start text-left font-normal", - !field.value - && "text-muted-foreground" + !field.value && "text-muted-foreground" )} > {field.value ? format( - new Date( - field.value - ), + new Date( field.value ), "PPP", { locale: dateFormat @@ -670,10 +659,7 @@ export default function FileUpload( {