feat: implement file upload functionality and enhance admin dashboard layout
This commit is contained in:
+11
-6
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user