From 19a1d07ad8a856a54914472172ca263a86c9be0b Mon Sep 17 00:00:00 2001 From: ArshiLamba Date: Sun, 21 Jul 2024 21:24:14 +0800 Subject: [PATCH 01/32] feat(client): Create createevents.ts x --- client/src/pages/route-map.tsx | 2 + client/src/pages/user/createevents.tsx | 122 +++++++++++++++++++++++++ client/src/pages/user/route-map.tsx | 19 ++++ 3 files changed, 143 insertions(+) create mode 100644 client/src/pages/user/createevents.tsx create mode 100644 client/src/pages/user/route-map.tsx diff --git a/client/src/pages/route-map.tsx b/client/src/pages/route-map.tsx index 8318d145..841e35d8 100644 --- a/client/src/pages/route-map.tsx +++ b/client/src/pages/route-map.tsx @@ -10,6 +10,7 @@ import * as React from 'react'; import NotFound from '@pages/404'; import RootPage from '@pages/root'; import routeMap from '@pages/auth/route-map'; +import routeMap1 from './user/route-map'; export type PathStr = `/${string}`; export type RootPathStr = '*' | '/' | PathStr; @@ -40,5 +41,6 @@ const routes: RootRouteMap = { title: 'Admin', }, ...routeMap, + ...routeMap1 } as const; export default routes; diff --git a/client/src/pages/user/createevents.tsx b/client/src/pages/user/createevents.tsx new file mode 100644 index 00000000..43da1075 --- /dev/null +++ b/client/src/pages/user/createevents.tsx @@ -0,0 +1,122 @@ +// src/pages/user/createevents.tsx + +import React from 'react'; +import { useForm } from 'react-hook-form'; +import { z, ZodSchema } from 'zod'; +import { zodResolver } from '@hookform/resolvers/zod'; + +// Define your form schema using zod +const eventSchema: ZodSchema = z.object({ + title: z.string().min(1, 'Title is required'), + date: z.string().min(1, 'Date is required'), + time: z.string().min(1, 'Time is required'), + location: z.string().min(1, 'Location is required'), + description: z.string().optional(), + file: z.instanceof(File).optional(), +}); + +// Define TypeScript type for form data +type EventFormData = z.infer; + +const EventCreationPage: React.FC = () => { + const { + register, + handleSubmit, + setValue, + } = useForm({ + resolver: zodResolver(eventSchema), + mode: 'onBlur', + }); + + // Handle form submission + const onSubmit = (data: EventFormData) => { + console.log('Form Data:', data); + + // Handle file upload here if needed + }; + + // Handle file input change + const handleFileChange = (event: React.ChangeEvent) => { + const file = event.target.files?.[0]; + if (file) { + setValue('file', file); + } + }; + + return ( +
+

Create Event

+
+
+ + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + +
+ +
+ +