|
1 | | -import { Inter as FontSans } from "next/font/google"; |
2 | | -import { useState } from "react"; |
| 1 | +import Image from "next/image"; |
| 2 | +import { useRouter } from "next/navigation"; |
3 | 3 |
|
4 | | -import { usePings } from "@/hooks/pings"; |
| 4 | +import { ContentCard, ContentCardProps } from "@/components/content-card"; |
| 5 | +import CardContainer from "@/components/ui/card_container"; |
5 | 6 | import { cn } from "@/lib/utils"; |
| 7 | +import hero_image from "@/public/hero_img.png"; |
| 8 | +import styles from "@/styles/index.module.css"; |
6 | 9 |
|
7 | 10 | import { Button } from "../components/ui/button"; |
8 | 11 |
|
9 | | -const fontSans = FontSans({ |
10 | | - subsets: ["latin"], |
11 | | - variable: "--font-sans", |
12 | | -}); |
| 12 | +/** |
| 13 | + * Returns a list of upcoming events as ContentCardProps to display |
| 14 | + * |
| 15 | + * @returns List of events sorted in order |
| 16 | + */ |
| 17 | +function getEvents(): Array<ContentCardProps> { |
| 18 | + // Currently a mock function, doesn't do anything other than make some stuff to display |
| 19 | + // TODO: replace with a real fetch against the Events endpoint once #3 is closed |
| 20 | + const mockEvents = [ |
| 21 | + { title: "Community Solar Info Night", dateTime: "12 Jul 2026" }, |
| 22 | + { title: "Electrify Your Home Workshop", dateTime: "19 Jul 2026" }, |
| 23 | + { title: "EV Test Drive Day", dateTime: "26 Jul 2026" }, |
| 24 | + { title: "Heat Pump Q&A Session", dateTime: "2 Aug 2026" }, |
| 25 | + { title: "Battery Storage Info Session", dateTime: "9 Aug 2026" }, |
| 26 | + ]; |
| 27 | + |
| 28 | + return mockEvents.map((event, index) => ({ |
| 29 | + imageSrc: hero_image.src, |
| 30 | + imageAlt: event.title, |
| 31 | + title: event.title, |
| 32 | + description: |
| 33 | + "Join us to learn how to electrify your home and cut your energy bills.", |
| 34 | + dateTime: event.dateTime, |
| 35 | + href: `/events/${index + 1}`, |
| 36 | + })); |
| 37 | +} |
| 38 | + |
| 39 | +/** |
| 40 | + * Returns the three quick-link tiles (WA Savings, News, Resources) shown |
| 41 | + * below the hero, linking out to their respective pages. |
| 42 | + * |
| 43 | + * @returns List of quick-link tiles |
| 44 | + */ |
| 45 | +function getQuickLinks(): Array<ContentCardProps> { |
| 46 | + return [ |
| 47 | + { |
| 48 | + imageSrc: hero_image.src, |
| 49 | + imageAlt: "WA Savings", |
| 50 | + title: "WA Savings", |
| 51 | + description: |
| 52 | + "See how much you could save by switching to electric appliances and solar in WA.", |
| 53 | + href: "/wa-savings", |
| 54 | + }, |
| 55 | + { |
| 56 | + imageSrc: hero_image.src, |
| 57 | + imageAlt: "News", |
| 58 | + title: "News", |
| 59 | + description: |
| 60 | + "Read the latest updates from Electrify Everything WA and our community.", |
| 61 | + href: "/news", |
| 62 | + }, |
| 63 | + { |
| 64 | + imageSrc: hero_image.src, |
| 65 | + imageAlt: "Resources", |
| 66 | + title: "Resources", |
| 67 | + description: |
| 68 | + "Explore guides and resources to help you electrify your home.", |
| 69 | + href: "/resources", |
| 70 | + }, |
| 71 | + ]; |
| 72 | +} |
13 | 73 |
|
14 | 74 | export default function Home() { |
15 | | - const [clicked, setClicked] = useState(false); |
16 | | - const { data, isLoading } = usePings({ |
17 | | - enabled: clicked, |
18 | | - }); |
| 75 | + const router = useRouter(); |
| 76 | + const events = getEvents(); |
| 77 | + const quickLinks = getQuickLinks(); |
19 | 78 |
|
20 | 79 | return ( |
21 | 80 | <main |
22 | 81 | className={cn( |
23 | 82 | "flex min-h-screen flex-col items-center gap-4 p-24 font-sans", |
24 | | - fontSans.variable, |
25 | 83 | )} |
26 | 84 | > |
27 | | - <h1 className="text-3xl text-primary">Test title</h1> |
28 | | - <Button onClick={() => setClicked(true)}> |
29 | | - {isLoading ? "Loading" : "Ping"} |
30 | | - </Button> |
31 | | - <p> |
32 | | - Response from server: <span>{data as string}</span> |
33 | | - </p> |
| 85 | + <div className={styles["hero"]}> |
| 86 | + <div className={styles["hero-body"]}> |
| 87 | + <div className={styles["hero-text"]}> |
| 88 | + Electrifying our households to build a safer, more sustainable |
| 89 | + future. |
| 90 | + </div> |
| 91 | + <Button |
| 92 | + className={styles["hero-button"]} |
| 93 | + onClick={() => router.push("/get-involved")} |
| 94 | + > |
| 95 | + Get Involved <span className={styles["arrow"]}>▸</span> |
| 96 | + </Button> |
| 97 | + </div> |
| 98 | + <div className={styles["hero-img"]}> |
| 99 | + <Image |
| 100 | + src={hero_image} |
| 101 | + alt={ |
| 102 | + "Image of a house with electric alternative to fossil fuel products" |
| 103 | + } |
| 104 | + /> |
| 105 | + </div> |
| 106 | + </div> |
| 107 | + <div className={styles["news-and-events"]}> |
| 108 | + <div className="flex justify-center"> |
| 109 | + <CardContainer cards={quickLinks} /> |
| 110 | + </div> |
| 111 | + <h1 className="m-5 text-5xl font-bold">Upcoming Events</h1> |
| 112 | + <div className="flex justify-center"> |
| 113 | + <CardContainer cards={events} /> |
| 114 | + </div> |
| 115 | + </div> |
34 | 116 | </main> |
35 | 117 | ); |
36 | 118 | } |
0 commit comments