mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
Moves the sign-in and standalone page bodies (`/sign-in`, `/sign-up`, `/sign-in-sso`, `/sign-in-partner`, `/sign-in-mfa`, `/sign-in-recovery-code`, `/forgot-password`, `/forgot-password-mfa`, `/reset-password`, `/cli/login`, `/partners/stripe/projects/login`, `/authorize`, `/redeem`, `/logout`, `/maintenance`, `/verify-email`, `/support/csat`, `/mcp/secrets`) into their route files and deletes the pages (FE-3106). Part 4 of the stack. **Depends on:** #53212 **Changed:** - `routes/_auth/**` and the standalone routes – page bodies inlined; `next/router`/`next/link`/`next/head` → native TanStack (`navigate({ to, search })`, `search: true` to carry the query, `href` for runtime return URLs) and inline `<title>`. Layout chains match the old `getLayout`s - `components/interfaces/CliLogin/CliLoginScreen.tsx` – the CLI login screen moves out of the page so its test can import it without the route file exporting it - `tests/routes/{authorize,_auth/**}.test.tsx` – moved from `tests/pages/**` and rendered with `renderRoute` **Removed:** - 18 page files Addresses [FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages). ## To test - Sign out, open `/sign-in` and `/sign-up` – same layout and title; switching between them keeps `returnTo` - Sign in with MFA – `/sign-in-mfa` returns to the original page - `/cli/login?session_id=…` and `/authorize?…` – flows complete as before - `/logout` – redirects to `/sign-in` --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
96 lines
3.6 KiB
TypeScript
96 lines
3.6 KiB
TypeScript
import { createFileRoute, Link } from '@tanstack/react-router'
|
|
import { useState } from 'react'
|
|
import { Button, cn } from 'ui'
|
|
|
|
import { SignInOptions } from '@/components/interfaces/SignIn/SignInOptions'
|
|
import { SignInWithExternalProvider } from '@/components/interfaces/SignIn/SignInWithExternalProvider'
|
|
import { SignUpForm } from '@/components/interfaces/SignIn/SignUpForm'
|
|
import { SignInLayout } from '@/components/layouts/SignInLayout/SignInLayout'
|
|
import { UnknownInterface } from '@/components/ui/UnknownInterface'
|
|
import { useEnabledIdentityProviders } from '@/hooks/misc/useEnabledIdentityProviders'
|
|
import { useHydratedQuery } from '@/hooks/misc/useHydratedQuery'
|
|
import { useInboundBranding } from '@/hooks/misc/useInboundBranding'
|
|
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
|
|
import { getSignInQuery } from '@/lib/gotrue'
|
|
import { buildStudioPageTitle } from '@/lib/page-title'
|
|
|
|
const PAGE_TITLE = buildStudioPageTitle({ section: 'Sign up', brand: 'Supabase Dashboard' })
|
|
const PAGE_DESCRIPTION =
|
|
'Sign up for Supabase. Start for free. Build production-grade applications with a Postgres database, Authentication, instant APIs, Realtime, Functions, Storage and Vector embeddings.'
|
|
|
|
export const Route = createFileRoute('/_auth/sign-up')({
|
|
head: () => ({
|
|
meta: [{ title: PAGE_TITLE }, { name: 'description', content: PAGE_DESCRIPTION }],
|
|
}),
|
|
component: SignUp,
|
|
})
|
|
|
|
function SignUp() {
|
|
return (
|
|
<SignInLayout heading="Get started" subheading="Create a new account" inboundFlow="sign-up">
|
|
<SignUpPage />
|
|
</SignInLayout>
|
|
)
|
|
}
|
|
|
|
function SignUpPage() {
|
|
const [showOtherOptions, setShowOtherOptions] = useState(false)
|
|
const [isSubmitted, setIsSubmitted] = useState(false)
|
|
const query = useHydratedQuery()
|
|
const { dashboardAuthSignUp: signUpEnabled } = useIsFeatureEnabled(['dashboard_auth:sign_up'])
|
|
|
|
const { focusProvider } = useInboundBranding('sign-up')
|
|
const signUpProviders = useEnabledIdentityProviders().filter((provider) => provider.showOnSignUp)
|
|
|
|
if (!signUpEnabled) {
|
|
return <UnknownInterface fullHeight={false} urlBack="/sign-in" />
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{focusProvider ? (
|
|
<div className="flex flex-col gap-5">
|
|
{!isSubmitted && <SignInWithExternalProvider provider={focusProvider} />}
|
|
{showOtherOptions ? (
|
|
<>
|
|
{!isSubmitted && (
|
|
<SignInOptions
|
|
providers={signUpProviders.filter((provider) => provider.id !== focusProvider.id)}
|
|
dividerBgClass="bg-surface-100"
|
|
/>
|
|
)}
|
|
<SignUpForm onSuccess={() => setIsSubmitted(true)} />
|
|
</>
|
|
) : (
|
|
<Button
|
|
block
|
|
variant="text"
|
|
size="large"
|
|
className="-mt-2 text-foreground-light"
|
|
onClick={() => setShowOtherOptions(true)}
|
|
>
|
|
Show other options
|
|
</Button>
|
|
)}
|
|
</div>
|
|
) : (
|
|
<div className="flex flex-col gap-5">
|
|
{!isSubmitted && <SignInOptions providers={signUpProviders} />}
|
|
<SignUpForm onSuccess={() => setIsSubmitted(true)} />
|
|
</div>
|
|
)}
|
|
|
|
<div className={cn('self-center text-center text-sm mb-8', isSubmitted ? 'mt-2' : 'mt-8')}>
|
|
<span className="text-foreground-light">Have an account?</span>{' '}
|
|
<Link
|
|
to="/sign-in"
|
|
search={getSignInQuery(query)}
|
|
className="underline text-foreground hover:text-foreground-light transition"
|
|
>
|
|
Sign in
|
|
</Link>
|
|
</div>
|
|
</>
|
|
)
|
|
}
|