From 1f1f8a5fa4158eab0264f76abf30aaf2e6427640 Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Thu, 1 Aug 2024 01:59:01 +0800 Subject: [PATCH] Feat/whale init (#28243) * duplicate page * whale init * table background * prepare * sync undocumented remote schema from master * revert remote schema sync * add lw12 tickets migration file * ticket init * set up lw12 ticket layout * finish ticket layout and customization form * lw12 ticket og * ticket styling * code highlight border * launch week migrations * local dev progress * keep local gh config * comment section * comment section * comment out username.tsx * remove lw/ticekts temp * update copy * fix migration view * redirect to try * use misc * lw12 og * share * share correct * env var * username page * update example env * push new db schema * trigger deploy * update ticket og * ticket themes * bypass browser * change env var name * fix * fix * process env * create client server side * lw announcements * promoToast * animated bg * update ticket og bg * minor details * secret ticket * social share text * social share textgst * flow text * update og * update og handler * Update index.ts * use functions.invoke and use generic supabase URL * Update index.ts * Update handler.tsx * Update package-lock.json * Update handler.tsx * add next api route * moved to vercel edge function * set revalidate * Update route.tsx * Delete lw-ticket-og.tsx * Update route.tsx * Update [username].tsx * Update [username].tsx * add more fetches * Update turbo.json * ticket themes updated * copy and layout updated * Update index.tsx * Update Ticket.tsx * Update TicketingFlow.tsx * update countdown * updated bg * small updates * moat * Update [username].tsx * Update 20240723155310_add_lw12_ticketing_schema.sql * optimistic ticket stuff og generation * Update index.tsx * updated layout * update themes in og * Update constants.ts * attr renamed * Update TicketingFlow.tsx * Update TicketActions.tsx * grammar * moar updates * Update TicketActions.tsx * Update TicketActions2.tsx * Update TicketActions.tsx * Update Hero.tsx * Update TicketingFlow.tsx * remove console logs --------- Co-authored-by: Francesco Sansalvadore --- apps/docs/features/app.providers.tsx | 2 + apps/docs/next.config.mjs | 1 + apps/www/.env.local.example | 1 + apps/www/app/api-v2/ticket-og/route.tsx | 550 ++++++++++++++++ apps/www/components/Footer/index.tsx | 9 +- apps/www/components/Hero/Hero.tsx | 8 + .../LaunchWeek/11/Ticket/Ticket.tsx | 116 ---- .../LaunchWeek/11/Ticket/TicketActions.tsx | 114 ---- .../LaunchWeek/11/Ticket/TicketContainer.tsx | 13 - .../LaunchWeek/11/Ticket/TicketCopy.tsx | 39 -- .../LaunchWeek/11/Ticket/TicketFooter.tsx | 36 -- .../LaunchWeek/11/Ticket/TicketNumber.tsx | 31 - .../LaunchWeek/11/Ticket/TicketingFlow.tsx | 160 ----- .../components/LaunchWeek/12/Countdown.tsx | 41 ++ .../LaunchWeek/12/HackathonCallout.tsx | 38 ++ .../LaunchWeek/12/LW12Background.tsx | 44 ++ .../components/LaunchWeek/12/LWMeetups.tsx | 152 +++++ .../components/LaunchWeek/12/LWSummary.tsx | 101 +++ .../components/LaunchWeek/12/LabelBadge.tsx | 14 + .../LaunchWeek/12/LaunchWeekLogoHeader.tsx | 16 + .../LaunchWeek/12/LaunchWeekPrizeCard.tsx | 33 + .../LaunchWeek/12/LaunchWeekPrizeSection.tsx | 82 +++ .../LaunchWeek/12/Releases/BuildStage.tsx | 75 +++ .../LaunchWeek/12/Releases/Day1.tsx | 92 +++ .../LaunchWeek/12/Releases/LWHeader.tsx | 52 ++ .../LaunchWeek/12/Releases/LWStickyNav.tsx | 127 ++++ .../LaunchWeek/12/Releases/MainStage.tsx | 32 + .../LaunchWeek/12/Releases/PrizeActions.tsx | 15 + .../12/Releases/components/AdventCard.tsx | 119 ++++ .../12/Releases/components/DaySection.tsx | 142 ++++ .../12/Releases/components/index.tsx | 84 +++ .../LaunchWeek/12/Releases/data/index.ts | 4 + .../12/Releases/data/lw12_build_stage.tsx | 290 +++++++++ .../LaunchWeek/12/Releases/data/lw12_data.tsx | 312 +++++++++ .../LW11Game.tsx => 12/Ticket/LW12Game.tsx} | 13 +- .../LaunchWeek/12/Ticket/Ticket.tsx | 172 +++++ .../LaunchWeek/12/Ticket/TicketActions.tsx | 29 + .../LaunchWeek/12/Ticket/TicketActions2.tsx | 137 ++++ .../LaunchWeek/12/Ticket/TicketContainer.tsx | 18 + .../LaunchWeek/12/Ticket/TicketCopy.tsx | 46 ++ .../Ticket/TicketCustomizationForm.tsx | 52 +- .../{11 => 12}/Ticket/TicketForm.tsx | 140 ++-- .../{11 => 12}/Ticket/TicketHeader.tsx | 0 .../{11 => 12}/Ticket/TicketPresence.tsx | 24 +- .../{11 => 12}/Ticket/TicketProfile.tsx | 0 .../LaunchWeek/12/Ticket/TicketingFlow.tsx | 193 ++++++ .../LaunchWeek/12/Ticket/ticketThemes.tsx | 164 +++++ .../7/LaunchSection/TicketBrick.tsx | 10 +- .../LaunchWeek/7/Ticket/ActualTicket.tsx | 189 ------ .../LaunchWeek/7/Ticket/TicketActions.tsx | 126 ---- .../LaunchWeek/7/Ticket/TicketContainer.tsx | 51 -- .../LaunchWeek/7/Ticket/TicketForm.tsx | 177 ----- .../LaunchWeek/7/Ticket/TicketHeader.tsx | 19 - .../LaunchWeek/7/Ticket/TicketNumber.tsx | 95 --- .../LaunchWeek/7/Ticket/TicketProfile.tsx | 86 --- .../LaunchWeek/7/Ticket/TicketVisual.tsx | 132 ---- .../7/Ticket/conf-container.module.css | 11 - .../LaunchWeek/7/Ticket/conf-container.tsx | 5 - .../LaunchWeek/7/Ticket/form.module.css | 248 ------- .../components/LaunchWeek/7/Ticket/form.tsx | 202 ------ .../7/Ticket/loading-dots.module.css | 48 -- .../LaunchWeek/7/Ticket/loading-dots.tsx | 27 - .../7/Ticket/ticket-actions.module.css | 70 -- .../7/Ticket/ticket-copy.module.css | 190 ------ .../LaunchWeek/7/Ticket/ticket-copy.tsx | 92 --- .../7/Ticket/ticket-form.module.css | 65 -- .../7/Ticket/ticket-image.module.css | 33 - .../LaunchWeek/7/Ticket/ticket-image.tsx | 37 -- .../7/Ticket/ticket-info-footer.tsx | 30 - .../7/Ticket/ticket-info.module.css | 83 --- .../7/Ticket/ticket-mono-mobile.tsx | 34 - .../LaunchWeek/7/Ticket/ticket-mono.tsx | 23 - .../7/Ticket/ticket-profile.module.css | 149 ----- .../7/Ticket/ticket-visual.module.css | 119 ---- .../LaunchWeek/7/Ticket/ticket.module.css | 151 ----- .../components/LaunchWeek/8/Ticket/Ticket.tsx | 79 --- .../LaunchWeek/8/Ticket/TicketActions.tsx | 119 ---- .../LaunchWeek/8/Ticket/TicketContainer.tsx | 179 ----- .../8/Ticket/TicketCustomizationForm.tsx | 145 ----- .../LaunchWeek/8/Ticket/TicketDisclaimer.tsx | 7 - .../LaunchWeek/8/Ticket/TicketFooter.tsx | 13 - .../LaunchWeek/8/Ticket/TicketForm.tsx | 170 ----- .../LaunchWeek/8/Ticket/TicketHeader.tsx | 20 - .../LaunchWeek/8/Ticket/TicketNumber.tsx | 31 - .../LaunchWeek/8/Ticket/TicketProfile.tsx | 42 -- .../LaunchWeek/8/Ticket/form.module.css | 248 ------- .../8/Ticket/ticket-actions.module.css | 70 -- .../8/Ticket/ticket-copy.module.css | 190 ------ .../LaunchWeek/8/Ticket/ticket-copy.tsx | 85 --- .../8/Ticket/ticket-form.module.css | 65 -- .../8/Ticket/ticket-profile.module.css | 149 ----- .../8/Ticket/ticket-visual.module.css | 71 -- .../LaunchWeek/8/Ticket/ticket.module.css | 160 ----- .../LaunchWeek/X/Ticket/LWXGame.tsx | 213 ------ .../components/LaunchWeek/X/Ticket/Ticket.tsx | 84 --- .../LaunchWeek/X/Ticket/TicketActions.tsx | 97 --- .../LaunchWeek/X/Ticket/TicketContainer.tsx | 19 - .../LaunchWeek/X/Ticket/TicketCopy.tsx | 52 -- .../X/Ticket/TicketCustomizationForm.tsx | 137 ---- .../LaunchWeek/X/Ticket/TicketFooter.tsx | 38 -- .../LaunchWeek/X/Ticket/TicketForm.tsx | 146 ----- .../LaunchWeek/X/Ticket/TicketHeader.tsx | 13 - .../LaunchWeek/X/Ticket/TicketNumber.tsx | 21 - .../LaunchWeek/X/Ticket/TicketPresence.tsx | 80 --- .../LaunchWeek/X/Ticket/TicketProfile.tsx | 42 -- .../LaunchWeek/X/Ticket/TicketingFlow.tsx | 206 ------ .../LaunchWeek/hooks/use-conf-data.ts | 10 +- .../LaunchWeek/hooks/useWinningChances.ts | 4 +- apps/www/components/Nav/index.tsx | 35 +- apps/www/components/Panel/Panel.tsx | 3 + apps/www/hooks/useDarkLaunchWeeks.tsx | 13 + apps/www/lib/constants.ts | 21 +- apps/www/lib/database.types.ts | 57 ++ apps/www/lib/redirects.js | 10 - apps/www/lib/supabaseAdmin.ts | 11 + apps/www/lib/theme.utils.ts | 3 +- apps/www/next.config.mjs | 1 + apps/www/package.json | 1 + apps/www/pages/_app.tsx | 4 +- apps/www/pages/ga-week/index.tsx | 8 +- apps/www/pages/ga-week/tickets/[username].tsx | 163 ----- apps/www/pages/launch-week/7/index.tsx | 2 +- .../launch-week/7/tickets/[username].tsx | 164 ----- .../www/pages/launch-week/7/tickets/index.tsx | 171 ----- .../launch-week/8/tickets/[username].tsx | 180 ------ .../www/pages/launch-week/8/tickets/index.tsx | 183 ------ apps/www/pages/launch-week/index.tsx | 100 +++ apps/www/pages/launch-week/launchWeek.css | 4 - .../pages/launch-week/tickets/[username].tsx | 212 ++++++ apps/www/pages/launch-week/x/index.tsx | 5 +- .../launch-week/x/tickets/[username].tsx | 168 ----- .../www/pages/launch-week/x/tickets/index.tsx | 167 ----- .../public/images/launchweek/12/bg-dark.svg | 48 ++ .../public/images/launchweek/12/bg-light.svg | 48 ++ .../launchweek/12/lw12-backpack-crop.png | Bin 0 -> 61100 bytes .../images/launchweek/12/lw12-backpack.png | Bin 0 -> 30538 bytes .../public/images/launchweek/12/lw12-og.png | Bin 0 -> 91342 bytes apps/www/public/sitemap_www.xml | 24 + apps/www/tailwind.config.js | 5 + package-lock.json | 152 ++++- .../ui-patterns/CountdownWidget/index.tsx | 14 +- .../ui-patterns/PromoToast/PromoToast.tsx | 26 +- packages/ui-patterns/index.tsx | 1 + .../ui/src/components/CodeBlock/CodeBlock.tsx | 25 +- .../banners/LW11CountdownBanner/index.ts | 1 - .../Countdown.tsx | 0 .../LW12CountdownBanner.tsx} | 15 +- .../VideoPreview.tsx | 0 .../src/layout/banners/data/Announcement.json | 8 +- packages/ui/src/layout/banners/index.tsx | 1 - supabase/config.toml | 9 + supabase/functions/lw12-ticket-og/README.md | 22 + supabase/functions/lw12-ticket-og/handler.tsx | 610 ++++++++++++++++++ supabase/functions/lw12-ticket-og/index.ts | 11 + .../20240723131601_drop_unused_tables.sql | 6 + ...240723155310_add_lw12_ticketing_schema.sql | 142 ++++ supabase/seed.sql | 6 + turbo.json | 4 +- 158 files changed, 4901 insertions(+), 7403 deletions(-) create mode 100644 apps/www/app/api-v2/ticket-og/route.tsx delete mode 100644 apps/www/components/LaunchWeek/11/Ticket/Ticket.tsx delete mode 100644 apps/www/components/LaunchWeek/11/Ticket/TicketActions.tsx delete mode 100644 apps/www/components/LaunchWeek/11/Ticket/TicketContainer.tsx delete mode 100644 apps/www/components/LaunchWeek/11/Ticket/TicketCopy.tsx delete mode 100644 apps/www/components/LaunchWeek/11/Ticket/TicketFooter.tsx delete mode 100644 apps/www/components/LaunchWeek/11/Ticket/TicketNumber.tsx delete mode 100644 apps/www/components/LaunchWeek/11/Ticket/TicketingFlow.tsx create mode 100644 apps/www/components/LaunchWeek/12/Countdown.tsx create mode 100644 apps/www/components/LaunchWeek/12/HackathonCallout.tsx create mode 100644 apps/www/components/LaunchWeek/12/LW12Background.tsx create mode 100644 apps/www/components/LaunchWeek/12/LWMeetups.tsx create mode 100644 apps/www/components/LaunchWeek/12/LWSummary.tsx create mode 100644 apps/www/components/LaunchWeek/12/LabelBadge.tsx create mode 100644 apps/www/components/LaunchWeek/12/LaunchWeekLogoHeader.tsx create mode 100644 apps/www/components/LaunchWeek/12/LaunchWeekPrizeCard.tsx create mode 100644 apps/www/components/LaunchWeek/12/LaunchWeekPrizeSection.tsx create mode 100644 apps/www/components/LaunchWeek/12/Releases/BuildStage.tsx create mode 100644 apps/www/components/LaunchWeek/12/Releases/Day1.tsx create mode 100644 apps/www/components/LaunchWeek/12/Releases/LWHeader.tsx create mode 100644 apps/www/components/LaunchWeek/12/Releases/LWStickyNav.tsx create mode 100644 apps/www/components/LaunchWeek/12/Releases/MainStage.tsx create mode 100644 apps/www/components/LaunchWeek/12/Releases/PrizeActions.tsx create mode 100644 apps/www/components/LaunchWeek/12/Releases/components/AdventCard.tsx create mode 100644 apps/www/components/LaunchWeek/12/Releases/components/DaySection.tsx create mode 100644 apps/www/components/LaunchWeek/12/Releases/components/index.tsx create mode 100644 apps/www/components/LaunchWeek/12/Releases/data/index.ts create mode 100644 apps/www/components/LaunchWeek/12/Releases/data/lw12_build_stage.tsx create mode 100644 apps/www/components/LaunchWeek/12/Releases/data/lw12_data.tsx rename apps/www/components/LaunchWeek/{11/Ticket/LW11Game.tsx => 12/Ticket/LW12Game.tsx} (95%) create mode 100644 apps/www/components/LaunchWeek/12/Ticket/Ticket.tsx create mode 100644 apps/www/components/LaunchWeek/12/Ticket/TicketActions.tsx create mode 100644 apps/www/components/LaunchWeek/12/Ticket/TicketActions2.tsx create mode 100644 apps/www/components/LaunchWeek/12/Ticket/TicketContainer.tsx create mode 100644 apps/www/components/LaunchWeek/12/Ticket/TicketCopy.tsx rename apps/www/components/LaunchWeek/{11 => 12}/Ticket/TicketCustomizationForm.tsx (76%) rename apps/www/components/LaunchWeek/{11 => 12}/Ticket/TicketForm.tsx (50%) rename apps/www/components/LaunchWeek/{11 => 12}/Ticket/TicketHeader.tsx (100%) rename apps/www/components/LaunchWeek/{11 => 12}/Ticket/TicketPresence.tsx (74%) rename apps/www/components/LaunchWeek/{11 => 12}/Ticket/TicketProfile.tsx (100%) create mode 100644 apps/www/components/LaunchWeek/12/Ticket/TicketingFlow.tsx create mode 100644 apps/www/components/LaunchWeek/12/Ticket/ticketThemes.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ActualTicket.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/TicketActions.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/TicketContainer.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/TicketForm.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/TicketHeader.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/TicketNumber.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/TicketProfile.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/TicketVisual.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/conf-container.module.css delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/conf-container.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/form.module.css delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/form.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/loading-dots.module.css delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/loading-dots.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ticket-actions.module.css delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ticket-copy.module.css delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ticket-copy.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ticket-form.module.css delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ticket-image.module.css delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ticket-image.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ticket-info-footer.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ticket-info.module.css delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ticket-mono-mobile.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ticket-mono.tsx delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ticket-profile.module.css delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ticket-visual.module.css delete mode 100644 apps/www/components/LaunchWeek/7/Ticket/ticket.module.css delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/Ticket.tsx delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/TicketActions.tsx delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/TicketContainer.tsx delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/TicketCustomizationForm.tsx delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/TicketDisclaimer.tsx delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/TicketFooter.tsx delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/TicketForm.tsx delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/TicketHeader.tsx delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/TicketNumber.tsx delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/TicketProfile.tsx delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/form.module.css delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/ticket-actions.module.css delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/ticket-copy.module.css delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/ticket-copy.tsx delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/ticket-form.module.css delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/ticket-profile.module.css delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/ticket-visual.module.css delete mode 100644 apps/www/components/LaunchWeek/8/Ticket/ticket.module.css delete mode 100644 apps/www/components/LaunchWeek/X/Ticket/LWXGame.tsx delete mode 100644 apps/www/components/LaunchWeek/X/Ticket/Ticket.tsx delete mode 100644 apps/www/components/LaunchWeek/X/Ticket/TicketActions.tsx delete mode 100644 apps/www/components/LaunchWeek/X/Ticket/TicketContainer.tsx delete mode 100644 apps/www/components/LaunchWeek/X/Ticket/TicketCopy.tsx delete mode 100644 apps/www/components/LaunchWeek/X/Ticket/TicketCustomizationForm.tsx delete mode 100644 apps/www/components/LaunchWeek/X/Ticket/TicketFooter.tsx delete mode 100644 apps/www/components/LaunchWeek/X/Ticket/TicketForm.tsx delete mode 100644 apps/www/components/LaunchWeek/X/Ticket/TicketHeader.tsx delete mode 100644 apps/www/components/LaunchWeek/X/Ticket/TicketNumber.tsx delete mode 100644 apps/www/components/LaunchWeek/X/Ticket/TicketPresence.tsx delete mode 100644 apps/www/components/LaunchWeek/X/Ticket/TicketProfile.tsx delete mode 100644 apps/www/components/LaunchWeek/X/Ticket/TicketingFlow.tsx create mode 100644 apps/www/hooks/useDarkLaunchWeeks.tsx create mode 100644 apps/www/lib/supabaseAdmin.ts delete mode 100644 apps/www/pages/ga-week/tickets/[username].tsx delete mode 100644 apps/www/pages/launch-week/7/tickets/[username].tsx delete mode 100644 apps/www/pages/launch-week/7/tickets/index.tsx delete mode 100644 apps/www/pages/launch-week/8/tickets/[username].tsx delete mode 100644 apps/www/pages/launch-week/8/tickets/index.tsx create mode 100644 apps/www/pages/launch-week/index.tsx create mode 100644 apps/www/pages/launch-week/tickets/[username].tsx delete mode 100644 apps/www/pages/launch-week/x/tickets/[username].tsx delete mode 100644 apps/www/pages/launch-week/x/tickets/index.tsx create mode 100644 apps/www/public/images/launchweek/12/bg-dark.svg create mode 100644 apps/www/public/images/launchweek/12/bg-light.svg create mode 100644 apps/www/public/images/launchweek/12/lw12-backpack-crop.png create mode 100644 apps/www/public/images/launchweek/12/lw12-backpack.png create mode 100644 apps/www/public/images/launchweek/12/lw12-og.png delete mode 100644 packages/ui/src/layout/banners/LW11CountdownBanner/index.ts rename packages/ui/src/layout/banners/{LW11CountdownBanner => LW12CountdownBanner}/Countdown.tsx (100%) rename packages/ui/src/layout/banners/{LW11CountdownBanner/LW11CountdownBanner.tsx => LW12CountdownBanner/LW12CountdownBanner.tsx} (70%) rename packages/ui/src/layout/banners/{LW11CountdownBanner => LW12CountdownBanner}/VideoPreview.tsx (100%) create mode 100644 supabase/functions/lw12-ticket-og/README.md create mode 100644 supabase/functions/lw12-ticket-og/handler.tsx create mode 100644 supabase/functions/lw12-ticket-og/index.ts create mode 100644 supabase/migrations/20240723131601_drop_unused_tables.sql create mode 100644 supabase/migrations/20240723155310_add_lw12_ticketing_schema.sql diff --git a/apps/docs/features/app.providers.tsx b/apps/docs/features/app.providers.tsx index 9a40768434..51e4b0cabe 100644 --- a/apps/docs/features/app.providers.tsx +++ b/apps/docs/features/app.providers.tsx @@ -1,6 +1,7 @@ import { CommandMenuProvider } from '@ui-patterns/Cmdk' import { ThemeProvider } from 'common' import { PortalToast } from 'ui' +import { PromoToast } from 'ui-patterns' import { type PropsWithChildren } from 'react' import SiteLayout from '~/layouts/SiteLayout' @@ -26,6 +27,7 @@ function GlobalProviders({ children }: PropsWithChildren) {
+ {children} diff --git a/apps/docs/next.config.mjs b/apps/docs/next.config.mjs index 259c5e70ed..b1e0446d9a 100644 --- a/apps/docs/next.config.mjs +++ b/apps/docs/next.config.mjs @@ -53,6 +53,7 @@ const nextConfig = { 'img.youtube.com', 'archbee-image-uploads.s3.amazonaws.com', 'obuldanrptloktxcffvn.supabase.co', + 'xguihxuzqibwxjnimxev.supabase.co', ], }, // TODO: @next/mdx ^13.0.2 only supports experimental mdxRs flag. next ^13.0.2 will stop warning about this being unsupported. diff --git a/apps/www/.env.local.example b/apps/www/.env.local.example index a5955cbb55..af319dc983 100644 --- a/apps/www/.env.local.example +++ b/apps/www/.env.local.example @@ -8,4 +8,5 @@ NEXT_PUBLIC_REFERENCE_DOCS_URL="https://localhost:3010" NEXT_PUBLIC_STUDIO_URL="http://localhost:8082" NEXT_PUBLIC_SUPABASE_ANON_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhndWloeHV6cWlid3hqbmlteGV2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzUwOTQ4MzUsImV4cCI6MTk5MDY3MDgzNX0.0PMlOxtKL4O9GGZuAP_Xl4f-Tut1qOnW4bNEmAtoB8w" NEXT_PUBLIC_SUPABASE_URL="https://xguihxuzqibwxjnimxev.supabase.co" +SUPABASE_COM_SERVICE_ROLE_KEY="secret" NEXT_PUBLIC_URL="http://localhost:3000" diff --git a/apps/www/app/api-v2/ticket-og/route.tsx b/apps/www/app/api-v2/ticket-og/route.tsx new file mode 100644 index 0000000000..04bc1ca37d --- /dev/null +++ b/apps/www/app/api-v2/ticket-og/route.tsx @@ -0,0 +1,550 @@ +import React from 'react' +import { ImageResponse } from '@vercel/og' +import { createClient } from '@supabase/supabase-js' +import { themes } from '~/components/LaunchWeek/12/Ticket/ticketThemes' + +export const runtime = 'edge' // 'nodejs' is the default +export const dynamic = 'force-dynamic' // defaults to auto +export const fetchCache = 'force-no-store' +export const revalidate = 0 + +const corsHeaders = { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type', +} + +const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL + +const STORAGE_URL = `${SUPABASE_URL}/storage/v1/object/public/images/launch-week/lw12` + +// Load custom font +const FONT_URL = `${STORAGE_URL}/assets/font/CircularStd-Book.otf` +const MONO_FONT_URL = `${STORAGE_URL}/assets/font/SourceCodePro-Regular.ttf` +const font = fetch(new URL(FONT_URL, import.meta.url)).then((res) => res.arrayBuffer()) +const mono_font = fetch(new URL(MONO_FONT_URL, import.meta.url)).then((res) => res.arrayBuffer()) +// const BUCKET_FOLDER_VERSION = 'v1' + +const LW_TABLE = 'tickets' +const LW_MATERIALIZED_VIEW = 'tickets_view' + +export async function GET(req: Request, res: Response) { + const url = new URL(req.url) + console.log(process.env.NEXT_PUBLIC_SUPABASE_URL) + const username = url.searchParams.get('username') ?? url.searchParams.get('amp;username') + const assumePlatinum = url.searchParams.get('platinum') ?? url.searchParams.get('amp;platinum') + const userAgent = req.headers.get('user-agent') + + try { + if (!username) throw new Error('missing username param') + + const supabaseAdminClient = createClient( + process.env.NEXT_PUBLIC_SUPABASE_URL as string, + process.env.LIVE_SUPABASE_COM_SERVICE_ROLE_KEY as string + ) + + // Track social shares + if (userAgent?.toLocaleLowerCase().includes('twitter')) { + await supabaseAdminClient + .from(LW_TABLE) + .update({ shared_on_twitter: 'now' }) + .eq('launch_week', 'lw12') + .eq('username', username) + .is('shared_on_twitter', null) + } else if (userAgent?.toLocaleLowerCase().includes('linkedin')) { + await supabaseAdminClient + .from(LW_TABLE) + .update({ shared_on_linkedin: 'now' }) + .eq('launch_week', 'lw12') + .eq('username', username) + .is('shared_on_linkedin', null) + } + + // Get ticket data + const { data: user, error } = await supabaseAdminClient + .from(LW_MATERIALIZED_VIEW) + .select( + 'id, name, ticket_number, shared_on_twitter, shared_on_linkedin, platinum, secret, role, company, location' + ) + .eq('launch_week', 'lw12') + .eq('username', username) + .maybeSingle() + + if (error) console.log('fetch error', error.message) + if (!user) throw new Error(error?.message ?? 'user not found') + + const { + name, + ticket_number: ticketNumber, + secret, + platinum: isPlatinum, + shared_on_twitter: sharedOnTwitter, + shared_on_linkedin: sharedOnLinkedIn, + } = user + + console.log(user) + + const platinum = isPlatinum ?? (!!sharedOnTwitter && !!sharedOnLinkedIn) ?? false + if (assumePlatinum && !platinum) + return await fetch(`${STORAGE_URL}/assets/platinum_no_meme.jpg`) + + // Generate image and upload to storage. + const ticketType = secret ? 'secret' : platinum ? 'platinum' : 'regular' + + const STYLING_CONFIG = { + BACKGROUND: themes[ticketType].OG_BACKGROUND, + FOREGROUND: themes[ticketType].TICKET_FOREGROUND, + FOREGROUND_LIGHT: themes[ticketType].TICKET_FOREGROUND_LIGHT, + TICKET_BORDER: themes[ticketType].TICKET_BORDER, + TICKET_FOREGROUND: themes[ticketType].TICKET_FOREGROUND, + TICKET_BACKGROUND: themes[ticketType].TICKET_BACKGROUND, + TICKET_BACKGROUND_CODE: themes[ticketType].TICKET_BACKGROUND_CODE, + TICKET_FOREGROUND_LIGHT: themes[ticketType].TICKET_FOREGROUND_LIGHT, + BORDER: themes[ticketType].TICKET_BORDER, + CODE_LINE_NUMBER: themes[ticketType].CODE_LINE_NUMBER, + CODE_BASE: themes[ticketType].CODE_THEME['hljs'].color, + CODE_HIGHLIGHT: themes[ticketType].CODE_HIGHLIGHT_BACKGROUND, + CODE_FUNCTION: themes[ticketType].CODE_THEME['hljs'].color, + CODE_VARIABLE: themes[ticketType].CODE_THEME['hljs'].color, + CODE_METHOD: themes[ticketType].CODE_THEME['hljs'].color, + CODE_EXPRESSION: themes[ticketType].CODE_THEME['hljs-keyword'].color, + CODE_STRING: themes[ticketType].CODE_THEME['hljs-string'].color, + CODE_NUMBER: themes[ticketType].CODE_THEME['hljs'].color, + CODE_NULL: themes[ticketType].CODE_THEME['hljs'].color, + JSON_KEY: themes[ticketType].CODE_THEME['hljs-attr'].color, + } + + const fontData = await font + const monoFontData = await mono_font + const OG_WIDTH = 1200 + const OG_HEIGHT = 628 + const OG_PADDING_X = 60 + const OG_PADDING_Y = 60 + const TICKET_WIDTH = 550 + const TICKET_RATIO = 396 / 613 + const TICKET_HEIGHT = TICKET_WIDTH / TICKET_RATIO + const TICKET_POS_TOP = OG_PADDING_Y + const TICKET_POS_LEFT = 540 + const LOGO_WIDTH = 40 + const LOGO_RATIO = 436 / 449 + const DISPLAY_NAME = name || username + const FIRST_NAME = DISPLAY_NAME?.split(' ')[0] + + const BACKGROUND = { + regular: { + LOGO: `${STORAGE_URL}/assets/supabase/supabase-logo-icon.png`, + BACKGROUND_GRID: `${STORAGE_URL}/assets/bg-dark.png?t=2024-07-26T11%3A13%3A36.534Z`, + }, + platinum: { + LOGO: `${STORAGE_URL}/assets/supabase/supabase-logo-icon.png`, + BACKGROUND_GRID: `${STORAGE_URL}/assets/bg-dark.png?t=2024-07-26T11%3A13%3A36.534Z`, + }, + secret: { + LOGO: `${STORAGE_URL}/assets/supabase/supabase-logo-icon-white.png`, + BACKGROUND_GRID: `${STORAGE_URL}/assets/bg-light.png`, + }, + } + + const lineNumberStyle = { + paddingLeft: 24, + width: 46, + color: STYLING_CONFIG.CODE_LINE_NUMBER, + } + + const generatedTicketImage = new ImageResponse( + ( + <> +
+ {/* Background */} + + {/* Ticket */} +
+ + Launch Week 12 + + Ticket + + + {/* Request code snippet */} +
+
+ 1 + 2 + 3 + 4 + 5 +
+
+ + await{' '} + + supabase + + + + . + from + ( + 'tickets' + ) + + + . + select + ( + '*' + ) + + + . + eq + ( + 'username' + , + {username} + ) + + + . + single + ( + ) + +
+
+ {/* Response Json */} +
+
+ TICKET RESPONSE +
+
+
+ 1 + { +
+
+ 2 + + + "data" + + : + { + +
+
+
+ 3 + + + "name" + + : + + "{name}" + + , + +
+
+ 4 + + + "username" + + : + + "{username}" + + , + +
+
+ 6 + + + "ticket_number" + + : + + "{ticketNumber}" + + , + +
+
+ 7 + + + "role" + + : + + "{user.role}" + + , + +
+
+ 8 + + + "company" + + : + + "{user.company}" + + , + +
+
+ 9 + + + "location" + + : + + "{user.location}" + + , + +
+
+
+ 10 + }, +
+
+ 11 + + + "error" + + : + + null + + +
+
+ 12 + } +
+
+
+
+ +
+
+ logo +
+ +

+ + Join {FIRST_NAME} for + + + Launch Week 12 + +

+

+ August 12-16 / 7AM PT +

+
+
+ + ), + { + width: OG_WIDTH, + height: OG_HEIGHT, + fonts: [ + { + name: 'Circular', + data: fontData, + style: 'normal', + }, + { + name: 'SourceCodePro', + data: monoFontData, + style: 'normal', + }, + ], + headers: { + 'content-type': 'image/png', + 'cache-control': 'public, max-age=31536000, s-maxage=31536000, no-transform, immutable', + 'cdn-cache-control': 'max-age=31536000', + }, + } + ) + + // [Note] Uncomment only for local testing to return the image directly and skip storage upload. + // return await generatedTicketImage + + // Upload image to storage. + const { error: storageError } = await supabaseAdminClient.storage + .from('images') + .upload(`launch-week/lw12/og/${ticketType}/${username}.png`, generatedTicketImage.body!, { + contentType: 'image/png', + // cacheControl: `${60 * 60 * 24 * 7}`, + cacheControl: `0`, + // Update cached og image, people might need to update info + upsert: true, + }) + + if (storageError) throw new Error(`storageError: ${storageError.message}`) + + const NEW_TIMESTAMP = new Date() + + return await fetch(`${STORAGE_URL}/og/${ticketType}/${username}.png?t=${NEW_TIMESTAMP}`) + } catch (error: any) { + return new Response(JSON.stringify({ error: error.message }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' }, + status: 400, + }) + } +} diff --git a/apps/www/components/Footer/index.tsx b/apps/www/components/Footer/index.tsx index 2625e44407..e4a61d91f0 100644 --- a/apps/www/components/Footer/index.tsx +++ b/apps/www/components/Footer/index.tsx @@ -1,5 +1,4 @@ import Link from 'next/link' -import { useTheme } from 'next-themes' import { Badge, IconDiscord, IconGitHubSolid, IconTwitterX, IconYoutubeSolid, cn } from 'ui' import Image from 'next/image' import { useRouter } from 'next/router' @@ -10,6 +9,7 @@ import footerData from 'data/Footer' import * as supabaseLogoWordmarkDark from 'common/assets/images/supabase-logo-wordmark--dark.png' import * as supabaseLogoWordmarkLight from 'common/assets/images/supabase-logo-wordmark--light.png' import { ThemeToggle } from 'ui-patterns/ThemeToggle' +import useDarkLaunchWeeks from '../../hooks/useDarkLaunchWeeks' interface Props { className?: string @@ -17,12 +17,11 @@ interface Props { } const Footer = (props: Props) => { - const { resolvedTheme } = useTheme() const { pathname } = useRouter() - const isLaunchWeek = pathname.includes('/launch-week') + const isDarkLaunchWeek = useDarkLaunchWeeks() const isGAWeek = pathname.includes('/ga-week') - const forceDark = isLaunchWeek || pathname === '/' + const forceDark = isDarkLaunchWeek || pathname === '/' if (props.hideFooter) { return null @@ -32,7 +31,7 @@ const Footer = (props: Props) => {