fix: update upload handling to conditionally reset upload state based on category
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
import { useRemixFormContext } from 'remix-hook-form'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
|
||||
import { useAdminContext } from '~/contexts/admin'
|
||||
import { useAdminContext, type TUpload } from '~/contexts/admin'
|
||||
|
||||
import { Button } from './button'
|
||||
|
||||
@@ -57,6 +57,7 @@ export const InputFile = <TFormValues extends Record<string, unknown>>(
|
||||
if (uploadedFile && isUploadOpen === name) {
|
||||
setValue(name as string, uploadedFile)
|
||||
setUploadedFile(undefined)
|
||||
setIsUploadOpen(undefined)
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [uploadedFile])
|
||||
@@ -85,7 +86,7 @@ export const InputFile = <TFormValues extends Record<string, unknown>>(
|
||||
size="fit"
|
||||
className="absolute right-3 h-[42px]"
|
||||
onClick={() => {
|
||||
setIsUploadOpen('featured_image')
|
||||
setIsUploadOpen(name as TUpload)
|
||||
}}
|
||||
>
|
||||
<CloudArrowUpIcon className="h-4 w-4 text-gray-500/50" />
|
||||
|
||||
Reference in New Issue
Block a user