Skip to content

Commit

Permalink
asm2024
Browse files Browse the repository at this point in the history
  • Loading branch information
EwanLyon committed Mar 23, 2024
1 parent f352cab commit 0b88906
Show file tree
Hide file tree
Showing 14 changed files with 198 additions and 47 deletions.
4 changes: 2 additions & 2 deletions apps/keystone/src/schema/tickets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ export const Ticket: Lists.Ticket = list({
query: 'numberOfTickets'
});
if (result) {
return 25 * result.numberOfTickets;
return 30 * result.numberOfTickets;
}

return 25 * item.numberOfTickets;
return 30 * item.numberOfTickets;
}
})
}),
Expand Down
2 changes: 2 additions & 0 deletions apps/nextjs/components/Ticket/TicketSale.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
font-weight: bold;
font-style: italic;
font-size: 1.5rem;
text-align: center;
text-wrap: balance;
}

.paymentMethod {
Expand Down
18 changes: 9 additions & 9 deletions apps/nextjs/components/Ticket/TicketSale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Box, Button, Skeleton, TextField } from "@mui/material";
import { UseMutationResponse, useQuery, gql, useMutation } from "urql";
import { useAuth } from "../auth";

import ASM2023Tickets from "../../styles/img/asm2023-tickets.png";
import ASM2024Tickets from "../../styles/img/events/asm24/asm24-ticket.jpg";

interface BankTicketResponse {
generateTicket: {
Expand All @@ -25,7 +25,7 @@ interface QUERY_PROFILE_RESULTS {
};
}

const TICKET_PRICE = 25;
const TICKET_PRICE = 30;

export function TicketProduct() {
const auth = useAuth();
Expand Down Expand Up @@ -121,7 +121,7 @@ export function TicketProduct() {
const res = await fetch(
`/api/create_bank_ticket?account=${
auth.ready ? auth?.sessionData?.id : ""
}&tickets=1&event=ASM2023`,
}&tickets=1&event=ASM2024`,
);

if (res.status === 200) {
Expand All @@ -139,18 +139,18 @@ export function TicketProduct() {
return (
<div className={styles.product}>
<Image
alt="3D Render showing two potential ASM2023 ticket designs"
src={ASM2023Tickets}
alt="A mosaic of images taken from ASM2023"
src={ASM2024Tickets}
className={styles.productImage}
/>
<div className={styles.information}>
<section>
<h2>Ticket Information</h2>
<p>Ticket to ASM2023 taking place in Adelaide, July 12-16.</p>
<p>Ticket price: ${TICKET_PRICE} AUD.</p>
<p>Ticket to ASM2024 taking place in Adelaide, July 16-21.</p>
<p>Ticket price: <b>${TICKET_PRICE} AUD</b>.</p>
<p>
All attendees, including runners and staff must purchase tickets to attend the event. Volunteers
will receive a $15 rebate administered on site at ASM2023.
will receive a $15 rebate administered on site at ASM2024.
</p>
</section>
<hr />
Expand All @@ -166,7 +166,7 @@ export function TicketProduct() {
<h2>Stripe</h2>
<p>Clicking on checkout will redirect you to the stripe checkout. </p>
<form
action={`/api/checkout_ticket?account=${accId}&username=${accUsername}&event=ASM2023`}
action={`/api/checkout_ticket?account=${accId}&username=${accUsername}&event=ASM2024`}
method="POST">
<Button
type="submit"
Expand Down
118 changes: 118 additions & 0 deletions apps/nextjs/pages/ASM2024/tickets.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { useEffect, useState } from "react";
import Head from "next/head";
import Image from "next/image";
import Link from "next/link";
import { loadStripe } from "@stripe/stripe-js";
import { ThemeProvider } from "@mui/material";
import { useMutation, useQuery, gql } from "urql";

import styles from "../../styles/ASM2023.Tickets.module.scss";
import DiscordEmbed from "../../components/DiscordEmbed";
import { theme } from "../../components/mui-theme";
import { useAuth } from "../../components/auth";

import ASM2024Logo from "../../styles/img/events/asm24/ASM24 SVG.svg";

import { TicketProduct } from "../../components/Ticket/TicketSale";

import TicketOGImage from "../../styles/img/events/asm24/asm23-ticket-og.png";

const stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY!);

interface BankTicketResponse {
generateTicket: {
ticketID: string;
totalCost: number;
numberOfTickets: number;
error?: Record<string, any>;
};
}

const Tickets = () => {
const auth = useAuth();
const [deletedTicket, setDeletedTicket] = useState(false);

const [, deleteStripeTicket] = useMutation(gql`
mutation ($sessionID: String) {
deleteTicket(where: { stripeID: $sessionID }) {
__typename
}
}
`);

useEffect(() => {
// Check to see if this is a redirect back from Checkout
const query = new URLSearchParams(window.location.search);

if (query.get("cancelled") && query.get("session_id") && !deletedTicket) {
deleteStripeTicket({ sessionID: query.get("session_id") }).then((res) => {
if (!res.error) {
setDeletedTicket(true);
// console.log('Successfully removed a dead ticket :D');
} else {
console.error(res.error);
}
});
}
}, [deleteStripeTicket, deletedTicket]);

const [purchasedTicketsRes] = useQuery({
query: gql`
query ($userID: ID) {
tickets(
where: {
AND: [{ user: { id: { equals: $userID } } }, { event: { endDate: { gt: $currentTime } } }]
}
) {
ticketID
}
}
`,
pause: !auth.ready || !auth?.sessionData?.id,
variables: {
userID: auth.ready ? auth.sessionData?.id ?? "" : "",
},
});

return (
<ThemeProvider theme={theme}>
<div className={styles.app}>
<Head>
<title>ASM2024 Tickets - AusSpeedruns</title>
<DiscordEmbed
title="ASM2024 Tickets - AusSpeedruns"
description="Purchase tickets for the Australian Speedrun Marathon 2024!"
pageUrl="/ASM2024/tickets"
imageSrc={TicketOGImage.src}
/>
</Head>
<main className={styles.content}>
<h1>ASM2024 Tickets</h1>
<Image className={styles.image} src={ASM2024Logo} alt="ASM2024 Logo" />
{purchasedTicketsRes.data?.tickets.length > 0 && auth.ready && (
<section className={styles.linkToProfile}>
<span>
View your tickets on{" "}
<Link href={`/user/${auth?.sessionData?.username}#tickets`}>your profile!</Link>
</span>
</section>
)}
<TicketProduct />
<hr />
<section className={styles.fullWidth}>
<h2>Refund Policy</h2>
<p>
AusSpeedruns does not offer any refunds for purchased ASM2024 tickets, except as required by
Australian law (e.g. the Australian Consumer Law). Individual exceptions may be considered
on a case by case basis, however we acknowledge our full discretion to not grant exceptions
that are sought.
</p>
<p>Please contact Lacey via the AusSpeedruns Discord for any inquires.</p>
</section>
</main>
</div>
</ThemeProvider>
);
};

export default Tickets;
2 changes: 1 addition & 1 deletion apps/nextjs/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function AusSpeedrunsWebsite({ Component, pageProps }: AppProps) {

return (
<AuthProvider>
<Navbar live events={events.data?.events} />
<Navbar events={events.data?.events} />
<Component {...pageProps} />
<Footer />
<CookieConsent
Expand Down
8 changes: 4 additions & 4 deletions apps/nextjs/pages/api/checkout_ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
line_items: [
{
// Provide the exact Price ID (for example, pr_1234) of the product you want to sell
price: 'ASM2023TICKET',
price: 'price_1Ox7VbKT8G4cNWT5ERel76v2',
quantity: 1,
},
],
mode: 'payment',
success_url: `${req.headers.origin}/user/${req.query.username}#tickets`,
cancel_url: `${req.headers.origin}/ASM2023/tickets?cancelled=true&session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${req.headers.origin}/ASM2024/tickets?cancelled=true&session_id={CHECKOUT_SESSION_ID}`,
});

// Generate ticket code
const returnData = await urqlClient.mutation(gql`
mutation ($userID: ID!, $stripeID: String, $apiKey: String!) {
generateTicket(
userID: $userID
event: "ASM2023"
event: "ASM2024"
numberOfTickets: 1
method: stripe
stripeID: $stripeID
Expand All @@ -57,7 +57,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)

res.redirect(303, session.url!);
} catch (err: any) {
res.status(err.statusCode || 500).json(err.message);
res.status(err.statusCode ?? 500).json(err.message);
}
} else {
res.setHeader('Allow', 'POST');
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/pages/api/create_bank_ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
res.status(200).json(data);
return resolve();
} catch (err: any) {
res.status(err.statusCode || 500).json(err.message);
res.status(err.statusCode ?? 500).json(err.message);
return resolve();
}
} else {
Expand Down
54 changes: 31 additions & 23 deletions apps/nextjs/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const ASGX2024: AusSpeedrunsEvent = {
},
logo: "events/asgx24/asgx-logo-white.png",
heroImage: "events/asgx24/asgx24-hero.png",
total: "TBA",
};

const ASDH2024: AusSpeedrunsEvent = {
Expand All @@ -72,7 +73,20 @@ const ASDH2024: AusSpeedrunsEvent = {
name: "Game On Cancer",
},
logo: "events/asdh24/DreamHack24Logo.png",
heroImage: "events/asdh24/Dreamhack24Hero.jpg",
heroImage: "events/asdh24/Dreamhack24Hero.jpg"
};

const ASM2024: AusSpeedrunsEvent = {
fullName: "Australian Speedrun Marathon 2024",
preferredName: "ASM2024",
shortName: "ASM2024",
startDate: "16 July 2024 09:00:00 GMT+0930",
dates: "July 16 - 21, 2023",
charity: {
name: "Game On Cancer",
},
logo: "events/asm24/ASM24 SVG.svg",
heroImage: "events/asm24/asm24-hero-temp.png",
};

export default function Home() {
Expand All @@ -94,14 +108,9 @@ export default function Home() {
/>
</Head>
<main>
<div className={styles.banner}>
{/* <div className={styles.banner}>
{!mobileWidth && (
<Image
src={DreamhackLogo}
height={30}
width={371}
alt="The Dreamhack Wordmark Logo"
/>
<Image src={DreamhackLogo} height={30} width={371} alt="The Dreamhack Wordmark Logo" />
)}
Our Dreamhack schedule just got released!
<Button
Expand All @@ -110,15 +119,21 @@ export default function Home() {
iconRight={faCalendar}
actionText="Dreamhack Schedule"
/>
</div>
<EventLive event={"ASGX2024"} />
</div> */}
{/* <EventLive event={"ASGX2024"} /> */}
{/* <ASMMLive /> */}
<HeroBlock
event={ASDH2024}
schedule
tagLine="The Dreamhack Schedule is Released!"
tagLine="See you at Dreamhack!"
ticketLink="https://dreamhack.com/australia/"
/>
<HeroBlock
event={ASM2024}
submitRuns
tagLine="Tickets are selling and Submissions are open!"
ticketLink="/ASM2024/tickets"
/>
{/* <DualUpcomingEvent
eventA={{
event: ASGX2024,
Expand All @@ -132,27 +147,20 @@ export default function Home() {
ticketLink: "https://dreamhack.com/australia/",
}}
/> */}
<LastEventBlock
tagLine="The Game Expo 2024 was awesome and we obliterated last years total!"
event={ASGX2024}
backgroundPos="center"
/>
<LastEventBlock
tagLine="AusSpeedruns At PAX 2023 SMASHED it out of the park over DOUBLING our previous record!"
event={ASAP2023}
backgroundPos="center"
// overrideHeight='800px'
/>
<LastEventBlock
tagLine="The Australian Speedrunning community once again came together to put on the best ASM ever to help raise $35,000!!!"
event={ASM2023}
backgroundPos="center"
// overrideHeight='800px'
/>
<LastEventBlock
tagLine="We had an incredible time showcasing speedruns at the very first TGX!"
event={next}
backgroundPos="center"
/>
<LastEventBlock
tagLine="We smashed our donation record and put on 3 jam packed days of speedrunning."
event={current}
backgroundPos="center"
/>
<section className={styles.archive}>
<div className={styles.content}>
Expand Down
Loading

0 comments on commit 0b88906

Please sign in to comment.