From 653b55c12aed9d4af495739a8d7b21f9285ae483 Mon Sep 17 00:00:00 2001 From: dztonik Date: Fri, 21 Mar 2025 09:16:44 +0000 Subject: [PATCH 1/2] username ticket lw14 --- .../pages/launch-week/tickets/[username].tsx | 189 +++--------------- 1 file changed, 24 insertions(+), 165 deletions(-) diff --git a/apps/www/pages/launch-week/tickets/[username].tsx b/apps/www/pages/launch-week/tickets/[username].tsx index eebcedc8cef..015a6037a22 100644 --- a/apps/www/pages/launch-week/tickets/[username].tsx +++ b/apps/www/pages/launch-week/tickets/[username].tsx @@ -1,187 +1,46 @@ -import { useState } from 'react' -import { GetStaticProps, GetStaticPaths } from 'next' -import dayjs from 'dayjs' import { NextSeo } from 'next-seo' -import Link from 'next/link' -import Error from 'next/error' -import { createClient, Session } from '@supabase/supabase-js' -import { Button } from 'ui' -import { LW_URL, SITE_ORIGIN } from '~/lib/constants' -import supabase from '~/lib/supabase' -import { Database } from '~/lib/database.types' -import { AnimatePresence, m, LazyMotion, domAnimation } from 'framer-motion' -import { DEFAULT_TRANSITION, INITIAL_BOTTOM, getAnimation } from '~/lib/animations' +import { LW14_DATE, LW14_TITLE, LW14_URL, SITE_ORIGIN } from '~/lib/constants' +import { LwView } from '~/components/LaunchWeek/14/LwView' +import { useRouter } from 'next/router' +import { Lw14ConfDataProvider } from '~/components/LaunchWeek/14/hooks/use-conf-data' -import DefaultLayout from '~/components/Layouts/Default' -import SectionContainer from '~/components/Layouts/SectionContainer' -import { TicketState, ConfDataContext, UserData } from '~/components/LaunchWeek/hooks/use-conf-data' -import CanvasSingleMode from '~/components/LaunchWeek/13/Multiplayer/CanvasSingleMode' -import ThreeTicketCanvas from '~/components/LaunchWeek/13/ThreeTicketCanvas' +const Lw14Page = () => { + const TITLE = `${LW14_TITLE} | ${LW14_DATE}` + const DESCRIPTION = 'Join us for a week of announcing new features, every day at 7 AM PT.' + const OG_IMAGE = `${SITE_ORIGIN}/images/launchweek/14/lw14-og.png?lw=14` -interface Props { - user: UserData - users: UserData[] - ogImageUrl: string -} - -export default function UsernamePage({ user, ogImageUrl }: Props) { - const { username, name, platinum, secret } = user - - const ticketType = secret ? 'secret' : platinum ? 'platinum' : 'regular' - - const DISPLAY_NAME = name || username - const TITLE = `${DISPLAY_NAME ? DISPLAY_NAME.split(' ')[0] + '’s' : 'Get your'} Launch Week Ticket` - const DESCRIPTION = `Claim your Supabase Launch Week 13 ticket for a chance to win supa swag.` - - const [session] = useState(null) - const [ticketState, setTicketState] = useState('ticket') - - const transition = DEFAULT_TRANSITION - const initial = INITIAL_BOTTOM - const animate = getAnimation({ duration: 1 }) - const exit = { opacity: 0, transition: { ...transition, duration: 0.2 } } - - if (!username) { - return + const { query } = useRouter() + const ticketNumber = query.ticketNumber?.toString() + const defaultUserData = { + id: query.id?.toString(), + ticket_number: ticketNumber ? parseInt(ticketNumber, 10) : undefined, + name: query.name?.toString(), + username: query.username?.toString(), + platinum: !!query.platinum, } return ( <> - null, - ticketState, - setTicketState, - }} - > - - -
- - - -
-
-
-

- Join {DISPLAY_NAME?.split(' ')[0]}
for Launch Week 13 -

- - Claim your own ticket for a chance to win limited swag and to follow all - the announcements. - -
-
- -
-
-
-
-
-
-
- - -
-
+ + + + ) } -export const getStaticProps: GetStaticProps = async ({ params }) => { - const username = params?.username?.toString() || null - let user - - const supabaseAdmin = createClient( - process.env.NEXT_PUBLIC_SUPABASE_URL!, - process.env.LIVE_SUPABASE_COM_SERVICE_ROLE_KEY! - ) - - // fetch the normal ticket - // stores the og images in supabase storage - fetch(`${SITE_ORIGIN}/api-v2/ticket-og?username=${encodeURIComponent(username ?? '')}`) - - // fetch a specific user - if (username) { - const { data } = await supabaseAdmin! - .from('tickets_view') - .select('name, username, ticket_number, metadata, platinum, secret, role, company, location') - .eq('launch_week', 'lw13') - .eq('username', username) - .single() - - user = data - } - - // fetch the platinum ticket - // stores the og images in supabase storage - if (user?.secret) { - fetch( - `${SITE_ORIGIN}/api-v2/ticket-og?username=${encodeURIComponent(username ?? '')}&secret=true` - ) - } else if (user?.platinum) { - // fetch /api-v2/ticket-og - fetch( - `${SITE_ORIGIN}/api-v2/ticket-og?username=${encodeURIComponent(username ?? '')}&platinum=true` - ) - } - - const ticketType = user?.secret ? 'secret' : user?.platinum ? 'platinum' : 'regular' - const ogImageUrl = `${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/images/launch-week/lw13/og/${ticketType}/${username}.png?t=${dayjs(new Date()).format('DHHmmss')}` - - return { - props: { - user: { - ...user, - username, - }, - ogImageUrl, - key: username, - }, - revalidate: 5, - } -} - -export const getStaticPaths: GetStaticPaths = async () => { - return Promise.resolve({ - paths: [], - fallback: 'blocking', - }) -} +export default Lw14Page From 26fef4f04365d77d9f2eeda6f8f2121f9cce1eea Mon Sep 17 00:00:00 2001 From: dztonik Date: Fri, 21 Mar 2025 10:45:39 +0000 Subject: [PATCH 2/2] change urls --- apps/www/components/LaunchWeek/14/TicketCopy.tsx | 4 ++-- apps/www/components/LaunchWeek/14/TicketShare.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/www/components/LaunchWeek/14/TicketCopy.tsx b/apps/www/components/LaunchWeek/14/TicketCopy.tsx index 39f88470b3b..3ae8d2fb59d 100644 --- a/apps/www/components/LaunchWeek/14/TicketCopy.tsx +++ b/apps/www/components/LaunchWeek/14/TicketCopy.tsx @@ -9,8 +9,8 @@ export default function TicketCopy() { const { username } = userData const [copied, setCopied] = useState(false) const buttonRef = useRef(null) - const displayUrl = `.../launch-week?referal=${username}` - const link = `${LW14_URL}?referal=${username}` + const displayUrl = `.../launch-week/tickets/${username}` + const link = `${LW14_URL}/tickets/${username}` return (