import { useQuery } from '@tanstack/react-query' import { useParams } from 'common' import { useEffect, useState } from 'react' import { CardContent } from 'ui' import { Admonition } from 'ui-patterns/Admonition' import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader' import { z } from 'zod' import { StripeAtlasApplicationForm } from './StripeAtlasApplicationForm' import { InterstitialLayout, LogoPair, PartnerLogo, SupabaseLogo, } from '@/components/layouts/InterstitialLayout' import { stripeAtlasApplicationQueryOptions } from '@/data/stripe-atlas/stripe-atlas-application-query' import { BASE_PATH } from '@/lib/constants' function decodeBase64Param(base64encoded: string): Base64Data | null { try { const bytes = Uint8Array.from(atob(base64encoded), (char) => char.charCodeAt(0)) const decoded = new TextDecoder().decode(bytes) return base64DataSchema.parse(JSON.parse(decoded)) } catch { return null } } const base64DataSchema = z.discriminatedUnion('type', [ z.object({ type: z.literal('success'), stripeAtlasToken: z.string(), }), z.object({ type: z.literal('error'), message: z.string(), }), ]) type Base64Data = z.infer export const StripeAtlasApplicationScreen = () => { const params = useParams() // give the router a chance to parse the query params const [hydrated, setHydrated] = useState(false) useEffect(() => setHydrated(true), []) if (!hydrated) { return ( ) } const decoded = params.data ? decodeBase64Param(params.data) : null return ( } right={} /> } title="$500 Credit Code for Stripe Atlas Merchants" description="Confirm your details below. Once the application is confirmed, you will receive a credit code via email." > {decoded === null && (

To claim your Stripe Atlas perk, please make sure:

  • You're a founder of the Stripe Atlas company.
  • Your company is already incorporated on Stripe.
  • You're using the "Pre-fill my application" button on the Stripe Atlas dashboard.
} />
)} {decoded?.type === 'error' && ( {decoded.message}

} />
)} {decoded?.type === 'success' && ( )}
) } const PrefilledApplication = ({ stripeAtlasToken }: { stripeAtlasToken: string }) => { const { data: application, error, isPending, isError, } = useQuery(stripeAtlasApplicationQueryOptions({ stripeAtlasToken })) if (isPending) return if (isError) { return ( {error.message}

} />
) } return ( ) } const LoadingCard = () => { return (
) }