Skip to content

Commit

Permalink
minor: added default parameters in setup page
Browse files Browse the repository at this point in the history
  • Loading branch information
geclos committed Sep 9, 2024
1 parent e749d6e commit 8732b52
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
15 changes: 14 additions & 1 deletion apps/web/src/app/(public)/setup/SetupForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ import { Button, FormWrapper, Input, useToast } from '@latitude-data/web-ui'
import { setupAction } from '$/actions/user/setupAction'
import { useServerAction } from 'zsa-react'

export default function SetupForm({ footer }: { footer: ReactNode }) {
export default function SetupForm({
email,
name,
companyName,
footer,
}: {
email?: string
name?: string
companyName?: string
footer: ReactNode
}) {
const { toast } = useToast()
const { isPending, error, executeFormAction } = useServerAction(setupAction, {
onError: ({ err }) => {
Expand All @@ -30,19 +40,22 @@ export default function SetupForm({ footer }: { footer: ReactNode }) {
label='Name'
placeholder='Jon Snow'
errors={errors?.name}
defaultValue={name}
/>
<Input
name='email'
autoComplete='email'
label='Email'
placeholder='[email protected]'
errors={errors?.email}
defaultValue={email}
/>
<Input
name='companyName'
label='Workspace Name'
placeholder='Acme Inc.'
errors={errors?.companyName}
defaultValue={companyName}
/>
<Button fullWidth isLoading={isPending} fancy>
Create account
Expand Down
13 changes: 11 additions & 2 deletions apps/web/src/app/(public)/setup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import SetupForm from './SetupForm'

export const dynamic = 'force-dynamic'

export default function SetupPage() {
export default function SetupPage({
searchParams,
}: {
searchParams?: { email: string; name: string; companyName: string }
}) {
return (
<FocusLayout
header={
Expand All @@ -18,7 +22,12 @@ export default function SetupPage() {
>
<Card>
<CardContent standalone>
<SetupForm footer={<AuthFooter />} />
<SetupForm
email={searchParams?.email}
name={searchParams?.name}
companyName={searchParams?.companyName}
footer={<AuthFooter />}
/>
</CardContent>
</Card>
</FocusLayout>
Expand Down

0 comments on commit 8732b52

Please sign in to comment.