import useLw15ConfData, { UserTicketData } from 'components/LaunchWeek/15/hooks/use-conf-data' import SectionContainer from 'components/Layouts/SectionContainer' import dayjs from 'dayjs' import Link from 'next/link' import { useState } from 'react' import { Button, cn } from 'ui' import { updateTicketColors, useRegistration } from '../hooks/use-registration' import { FifteenSVG, LW15ThemeSwitcher, LWSVG } from '../lw15.components' import { BG_COLORS, TYPO_COLORS } from './colors' import LW15Ticket from './LW15Ticket' import LW15TicketShare from './LW15TicketShare' import TicketURLCopy from './TicketURLCopy' const LW15TicketPage = ({ user: userFromProps, isSharePage, }: { user?: UserTicketData isSharePage?: boolean }) => { const register = useRegistration() const [state, setState] = useState({ saving: false }) const [confState] = useLw15ConfData() const user = isSharePage ? userFromProps : confState.userTicketData const isLoggedTicketOwner = user?.username === confState.userTicketData?.username const selectedFg = user?.metadata?.colors?.foreground || TYPO_COLORS[0] const selectedBg = user?.metadata?.colors?.background || BG_COLORS[0] const handleColorChange = async (type: 'foreground' | 'background', color: string) => { if (!user?.username) return const newColors = { background: type === 'background' ? color : selectedBg, foreground: type === 'foreground' ? color : selectedFg, } setState({ saving: true }) try { await updateTicketColors({ username: user?.username!, userMetadata: user?.metadata, background: newColors.background, foreground: newColors.foreground, }) } finally { setState({ saving: false }) } } const TicketCustomizationSection = ({ className }: { className?: string }) => (
{!isSharePage && (

Customize your ticket

Typo color

{TYPO_COLORS.map((color) => (

Bg color

{BG_COLORS.map((color) => (
)}

Ticket ID: #{user?.ticket_number}

Claimed at: {dayjs(user?.created_at).format('DD MMM / HH:mm')}

) const handleClaimTicket = () => register.signIn() return (

Supabase Launch Week 15

{isSharePage ? ( <> {user?.name?.split(' ')[0]}'s Ticket
Want your own? ) : ( <> Hey @{user?.username},
customize your
Launch Week ticket )}
{isSharePage && !isLoggedTicketOwner && (
)} {isSharePage && isLoggedTicketOwner && (
)}
{!isSharePage && }
) } export default LW15TicketPage