committing event form unfinished

This commit is contained in:
ashprit
2024-10-26 15:47:02 +01:00
parent 8e4e747382
commit 9e836a7de1
8 changed files with 6800 additions and 10 deletions

View File

@@ -1,10 +1,53 @@
'use client';
import React from 'react';
import EventDescription from '@/components/custom/EventDescription';
import Home from './Home';
import Home from '../components/Home';
import EventForm from '@/components/custom/EventForm';
export default function Page() {
// Define the handleSubmit function
const handleSubmit = (data: {
name: string;
description: string;
capacity: number;
ticketPrice: number;
eventDate: Date;
eventStartTime?: string;
eventEndTime?: string;
images?: string[];
}) => {
try {
// Log the data to the console (you can replace this with an API call or other logic)
console.log('Form Submitted:', data);
// You can format the eventDate if needed (e.g., to a specific date format)
const formattedDate = new Date(data.eventDate).toISOString();
console.log('Formatted Event Date:', formattedDate);
// Example: Post data to an API endpoint
// fetch('/api/events', {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({ ...data, eventDate: formattedDate }),
// })
// .then((response) => response.json())
// .then((result) => {
// console.log('Success:', result);
// })
// .catch((error) => {
// console.error('Error:', error);
// });
} catch (error) {
console.error('Error submitting form:', error);
}
};
return (
<>
<Home />
{/* <Home /> */}
<EventForm onSubmit={(data) => handleSubmit(data)} />
</>
);
}