diff --git a/.eslintrc.json b/.eslintrc.json index 3f92d73..4060e80 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,6 +4,6 @@ "@next/next/no-img-element": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-empty-object-type": "off", - "@typescript-eslint/no-unused-vars":"off" + "@typescript-eslint/no-unused-vars": "off" } } diff --git a/app/host/page.tsx b/app/host/page.tsx new file mode 100644 index 0000000..1b63f2b --- /dev/null +++ b/app/host/page.tsx @@ -0,0 +1,122 @@ +'use client'; + +import EventForm from '@/components/custom/EventForm'; +import FeaturedEvent from '@/components/custom/FeaturedEvent'; +import Footer from '@/components/custom/footer'; +import Header from '@/components/custom/header'; +import { Button } from '@/components/ui/button'; +import { FlipWords } from '@/components/ui/flip-words'; +import { useRouter } from 'next/navigation'; +import React, { useEffect, useRef, useState } from 'react'; +import { motion } from 'framer-motion'; +import { EventFormData } from '@/components/custom/EventForm'; +import { createEvent } from '@/lib/createEvent'; + +const Page = () => { + const router = useRouter(); + const [isClient, setIsClient] = useState(false); + const inputRef = useRef(null); + + useEffect(() => { + setIsClient(true); + }, []); + + function searchForEvents() { + if (inputRef.current && inputRef.current.value === '') return; + + if (inputRef.current) + router.replace('/events?q=' + encodeURIComponent(inputRef.current.value)); + } + + function handleSubmit(data: { + name: string; + description: string; + capacity: number; + ticketPrice: number; + location: string; + eventStartTime: Date; + eventEndTime?: Date | undefined; + images?: string[] | undefined; + }) { + createEvent({ + name: data.name, + description: data.description, + location: data.location, + capacity: data.capacity, + ticketPrice: data.ticketPrice, + startDate: data.eventStartTime, + endDate: data.eventEndTime || new Date(), + images: data.images || [], + toast: ({ title, variant }) => { + alert(title); + }, + }); + router.push('/events'); + } + + const words = [ + 'adventure', + 'concert', + 'outing', + 'journey', + 'hackathon', + 'conference', + ]; + + return ( + <> +
+
+ {/* Video Background */} + {isClient && ( + + )} + + {/* Dark Overlay for Enhanced Readability */} +
+ + {/* Page Content Over the Video */} +
+
+ +
+ + Create your event here! + + + + +
+
+
+
+
+
+ + ); +}; + +export default Page; diff --git a/components/EventPage.tsx b/components/EventPage.tsx index 0c7e0eb..75287e2 100644 --- a/components/EventPage.tsx +++ b/components/EventPage.tsx @@ -16,3 +16,10 @@ const EventPage = () => { }; export default EventPage; + +// profile page + +// EventForm to Register Events +// on submit form +// fix ui to match ticketchain initial ui +// diff --git a/components/ProfilePage.tsx b/components/ProfilePage.tsx new file mode 100644 index 0000000..6bd0bb8 --- /dev/null +++ b/components/ProfilePage.tsx @@ -0,0 +1,123 @@ +import { useRouter } from 'next/router'; +// import { Input } from 'postcss'; // Removed incorrect import +import React, { useEffect, useRef, useState } from 'react'; +import FeaturedEvent from './custom/FeaturedEvent'; +import Footer from './custom/footer'; +import Header from './custom/header'; +import { Button } from './ui/button'; +import { FlipWords } from './ui/flip-words'; + +const ProfilePage = () => { + const router = useRouter(); + const [isClient, setIsClient] = useState(false); + const inputRef: any = useRef(null); + + useEffect(() => { + setIsClient(true); + }, []); + + function searchForEvents() { + if (inputRef.current.value == '') return; + router.replace('/events?q=' + encodeURIComponent(inputRef.current.value)); + } + + const words = [ + 'adventure', + 'concert', + 'outing', + 'journey', + 'hackathon', + 'conference', + ]; + + return ( + <> +
+
+ {/* Video Background */} + {isClient && ( + + )} + + {/* Dark Overlay for Enhanced Readability */} +
+ + {/* Page Content Over the Video */} +
+
+
+
+ Book your next + + on the Flare blockchain. +
+
+ +
+ + +
+
+
+ + + +
+
+
+
+
+
+ + ); +}; + +export default ProfilePage; diff --git a/components/custom/EventDescription.tsx b/components/custom/EventDescription.tsx index 9aaa346..eacb472 100644 --- a/components/custom/EventDescription.tsx +++ b/components/custom/EventDescription.tsx @@ -13,7 +13,7 @@ import { buyHandler } from '@/lib/buyHandler'; import { useToast } from '@/hooks/use-toast'; import NumberPicker from './TicketButton'; -interface EventDescriptionProps { +export interface EventDescriptionProps { eventDetails: { EventID: number; name: string; diff --git a/components/custom/EventForm.tsx b/components/custom/EventForm.tsx index 9273dd0..f6dfe64 100644 --- a/components/custom/EventForm.tsx +++ b/components/custom/EventForm.tsx @@ -58,7 +58,7 @@ const eventSchema = z }); // Define the TypeScript type based on the Zod schema -type EventFormData = z.infer; +export type EventFormData = z.infer; interface EventFormProps { onSubmit: (data: EventFormData) => void; diff --git a/components/Profile.tsx b/components/custom/Profile.tsx similarity index 100% rename from components/Profile.tsx rename to components/custom/Profile.tsx diff --git a/components/custom/header.tsx b/components/custom/header.tsx index b044a19..c25cdfd 100644 --- a/components/custom/header.tsx +++ b/components/custom/header.tsx @@ -62,6 +62,16 @@ const Header = () => { +
  • + + + Host Event + + +
  • void; + +declare global { + interface Window { + ethereumProvider?: ethers.providers.ExternalProvider & { + isMetaMask?: boolean; + request?: (method: string, params?: unknown[]) => Promise; + }; + } +} + +export const createEvent = async ({ + name, + description, + location, + capacity, + ticketPrice, + startDate, + endDate, + images, + toast, +}: CreateEventProps) => { + try { + console.log('Starting createEvent function'); + if (typeof window.ethereum === 'undefined') { + console.error('Ethereum provider not found'); + toast({ + title: 'Please install MetaMask or another Ethereum wallet', + variant: 'destructive', + }); + return; + } + + console.log('Connecting to Ethereum provider'); + const provider = new ethers.providers.Web3Provider(window.ethereum); + const signer = provider.getSigner(); + const contract = getContract().connect(signer); + + console.log('Preparing transaction data'); + const tx = await contract.createEvent( + name, + description, + capacity, + ethers.utils.parseEther(ticketPrice.toString()), + Math.floor(startDate.getTime() / 1000), + images + ); + + console.log('Transaction sent, waiting for confirmation'); + const receipt = await tx.wait(); + + console.log('Transaction confirmed:', receipt.transactionHash); + toast({ + title: `Event created successfully! Transaction Hash: ${receipt.transactionHash}`, + }); + + return receipt.transactionHash; + } catch (error) { + console.error('Error in createEvent:', error); + if (error instanceof Error) { + toast({ + title: `Transaction failed: ${error.message}`, + variant: 'destructive', + }); + } else { + toast({ + title: 'Transaction failed. Please try again.', + variant: 'destructive', + }); + } + throw error; + } +};