Update homepage and link input to search

This commit is contained in:
2024-10-26 20:23:36 +01:00
parent 797712ecf1
commit eb43087dbf
3 changed files with 107 additions and 24 deletions

View File

@@ -2,6 +2,7 @@
import React, { useEffect, useState, useRef } from 'react'; import React, { useEffect, useState, useRef } from 'react';
import Header from '../../components/custom/header'; import Header from '../../components/custom/header';
import Footer from '../../components/custom/footer'; import Footer from '../../components/custom/footer';
import { useSearchParams } from 'next/navigation';
// Define the Event interface including new fields // Define the Event interface including new fields
interface Event { interface Event {
@@ -70,6 +71,8 @@ const EventsPage: React.FC = () => {
const [showSortMenu, setShowSortMenu] = useState<boolean>(false); const [showSortMenu, setShowSortMenu] = useState<boolean>(false);
const [showFilterMenu, setShowFilterMenu] = useState<boolean>(false); const [showFilterMenu, setShowFilterMenu] = useState<boolean>(false);
const searchParams = useSearchParams();
const sortRef = useRef<HTMLDivElement>(null); const sortRef = useRef<HTMLDivElement>(null);
const filterRef = useRef<HTMLDivElement>(null); const filterRef = useRef<HTMLDivElement>(null);
@@ -140,6 +143,9 @@ const EventsPage: React.FC = () => {
useEffect(() => { useEffect(() => {
document.addEventListener('mousedown', handleClickOutside); document.addEventListener('mousedown', handleClickOutside);
if (searchParams.get("q")) {
setSearchQuery(searchParams.get("q")!);
};
return () => { return () => {
document.removeEventListener('mousedown', handleClickOutside); document.removeEventListener('mousedown', handleClickOutside);
}; };

View File

@@ -1,16 +1,26 @@
'use client'; 'use client';
import { useEffect, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { useRouter } from 'next/navigation';
import Header from '../components/custom/header'; import Header from '../components/custom/header';
import Footer from '../components/custom/footer'; import Footer from '../components/custom/footer';
import { Input } from '@/components/ui/input'; import { Input } from '@/components/ui/input';
import FeaturedEvent from '@/components/custom/FeaturedEvent';
import { Button } from '@/components/ui/button';
export default function Home() { export default function Home() {
const router = useRouter();
const [isClient, setIsClient] = useState(false); const [isClient, setIsClient] = useState(false);
const inputRef: any = useRef(null);
useEffect(() => { useEffect(() => {
setIsClient(true); setIsClient(true);
}, []); }, []);
function searchForEvents() {
if (inputRef.current.value == "") return;
router.replace("/events?q=" + encodeURIComponent(inputRef.current.value));
}
return ( return (
<> <>
<Header /> <Header />
@@ -32,34 +42,55 @@ export default function Home() {
<div className="absolute inset-0 bg-black opacity-50 z-10"></div> <div className="absolute inset-0 bg-black opacity-50 z-10"></div>
{/* Page Content Over the Video */} {/* Page Content Over the Video */}
<div className="relative z-20 min-h-screen bg-gradient-to-b from-transparent to-gray-900 pt-16"> <div className="relative z-20 min-h-screen bg-gradient-to-b from-transparent to-gray-900 pt-20">
<div className="container mx-auto p-4"> <div className="container mx-auto p-4">
<div className="flex items-center justify-center"> <h1 className="text-4xl font-bold text-white text-shadow-lg">
Book your next adventure <div className="inline bg-white p-2 rounded-lg shadow-lg text-black">on the <span className="bg-clip-text text-transparent bg-gradient-to-r from-pink-500 to-pink-600">Flare</span> blockchain</div>
</h1>
<div className="flex items-center justify-center mt-6 flex-col gap-4">
<Input <Input
type="text" type="text"
placeholder="Search events ..." placeholder="Search for your next experience..."
className="search-bar mt-4 p-2 border bg-white bg-opacity-25 border-gray-300 rounded-xl w-full max-w-5xl text-white" className="flex w-full rounded-md border border-input bg-white bg-opacity-50 placeholder:text-black px-4 py-6 text-lg shadow-sm"
ref={inputRef}
/> />
<Button
className="bg-pink-600 bg-opacity-50 text-white px-4 py-6 text-lg w-full hover:bg-pink-500"
onClick={searchForEvents}
>Search for events</Button>
</div> </div>
<main> <main>
<br></br> <section className="mb-8 mt-4 mx-auto grid grid-cols-4 gap-4">
<section className="mb-8"> <FeaturedEvent
<h2 className="text-2xl font-semibold text-white mb-4"> name="FAB XO Halloween"
Featured Events description="Halloween is upon us and is one of the biggest nights of the FAB XO calendar. Fancy dress is encouraged! So have your fancy dress ready and we look forward to seeing who have the best fancy dress on the night! As a special treat we will be serving our very own witches brew!!!"
</h2> location="Birmingham, UK"
<p className="text-gray-300"> capacity={100}
No events available at the moment. ticketsSold={50}
</p> eventStartDate={1729980000}
</section> eventHost="0x225C73C8c536C4F5335a2C1abECa95b0f221eeF6"
<section> imageURL={"https://www.guildofstudents.com/asset/Event/7572/Halloween-Fab-XO-Web-Event.jpg"}
<h2 className="text-2xl font-semibold text-white mb-4"> />
Upcoming Events <FeaturedEvent
</h2> name="Halls Halloween Spooktacular"
<ul className="list-disc list-inside text-gray-300"> description="Put on your spookiest costume and head on down to Pritchatts Park and join your Event Activators for our ResLife SPOOKTACULAR on Wednesday 30th October 5-8pm."
<li>Event 1 - Date</li> location="Birmingham, UK"
<li>Event 2 - Date</li> capacity={100}
<li>Event 3 - Date</li> ticketsSold={50}
</ul> eventStartDate={1730307600}
eventHost="0x225C73C8c536C4F5335a2C1abECa95b0f221eeF6"
imageURL={"https://www.guildofstudents.com/asset/Event/41187/Spooktacular-Web-Event-2024.png"}
/>
<FeaturedEvent
name="Housing Fair"
description="Were hosting a Housing Fair, so make sure you save the date! Whether youre living in student accommodation or the local community, this will be a great place to start as you begin thinking about where youll be living next year."
location="Birmingham, UK"
capacity={100}
ticketsSold={50}
eventStartDate={1730804400}
eventHost="0x225C73C8c536C4F5335a2C1abECa95b0f221eeF6"
imageURL={"https://www.guildofstudents.com/asset/Event/41111/Housing-Fair-Web-Event.png"}
/>
</section> </section>
</main> </main>
<Footer /> <Footer />
@@ -68,4 +99,4 @@ export default function Home() {
</div> </div>
</> </>
); );
} }

View File

@@ -0,0 +1,46 @@
'use client';
import React from 'react';
import {
Card,
CardHeader,
CardFooter,
CardTitle,
CardDescription,
CardContent,
} from '@/components/ui/card';
interface props {
name: string;
description: string;
location: string;
capacity: number;
ticketsSold: number;
eventStartDate: number;
eventHost: string;
imageURL: string | null;
}
const FeaturedEvent = ({
name, description, location, capacity, ticketsSold, eventStartDate, eventHost, imageURL
}: props) => {
return <Card>
<CardHeader>
{imageURL && <img src={imageURL}></img>}
<CardTitle>
{name}
</CardTitle>
<CardDescription>
{location}<br />
{new Date(eventStartDate*1000).toLocaleString()}
</CardDescription>
</CardHeader>
<CardContent>
{description}
</CardContent>
<CardFooter>
<i>Host: {eventHost.substring(0, 8)}...{eventHost.substring(eventHost.length-3)}</i>
</CardFooter>
</Card>
}
export default FeaturedEvent;