feat: implement file upload functionality and enhance admin dashboard layout

This commit is contained in:
Ardeman
2025-03-10 12:21:08 +08:00
parent 8c2298ff61
commit 9a0c6c1f0b
9 changed files with 246 additions and 105 deletions
+11 -6
View File
@@ -6,17 +6,19 @@ import {
type Dispatch,
type SetStateAction,
} from 'react'
import { z } from 'zod'
type TUpload =
| 'featured_image'
| 'ads'
| 'content'
| 'profile_picture'
| undefined
export const uploadCategorySchema = z
.enum(['featured_image', 'ads', 'content', 'profile_picture'])
.optional()
type TUpload = z.infer<typeof uploadCategorySchema>
type AdminContextProperties = {
isUploadOpen: TUpload
setIsUploadOpen: Dispatch<SetStateAction<TUpload>>
uploadedFile?: string
setUploadedFile: Dispatch<SetStateAction<string | undefined>>
}
const AdminContext = createContext<AdminContextProperties | undefined>(
@@ -25,12 +27,15 @@ const AdminContext = createContext<AdminContextProperties | undefined>(
export const AdminProvider = ({ children }: PropsWithChildren) => {
const [isUploadOpen, setIsUploadOpen] = useState<TUpload>()
const [uploadedFile, setUploadedFile] = useState<string | undefined>()
return (
<AdminContext.Provider
value={{
isUploadOpen,
setIsUploadOpen,
uploadedFile,
setUploadedFile,
}}
>
{children}