@@ -11,10 +11,9 @@ import { z } from 'zod';
1111import { createOrganization } from '../actions/create-organization' ;
1212import { createOrganizationMinimal } from '../actions/create-organization-minimal' ;
1313import type { OnboardingFormFields } from '../components/OnboardingStepInput' ;
14- import { STORAGE_KEY , companyDetailsSchema , steps } from '../lib/constants' ;
14+ import { companyDetailsSchema , steps } from '../lib/constants' ;
1515import { updateSetupSession } from '../lib/setup-session' ;
1616import type { CompanyDetails } from '../lib/types' ;
17- import { useLocalStorage } from './useLocalStorage' ;
1817
1918interface UseOnboardingFormProps {
2019 setupId ?: string ;
@@ -29,9 +28,8 @@ export function useOnboardingForm({
2928} : UseOnboardingFormProps = { } ) {
3029 const router = useRouter ( ) ;
3130
32- // If we have a setupId, use the initialData from KV, otherwise use localStorage
33- const [ savedAnswers , setSavedAnswers ] = useLocalStorage < Partial < CompanyDetails > > (
34- STORAGE_KEY ,
31+ // Use state instead of localStorage - initialized from KV data if setupId exists
32+ const [ savedAnswers , setSavedAnswers ] = useState < Partial < CompanyDetails > > (
3533 setupId && initialData ? initialData : { } ,
3634 ) ;
3735
@@ -108,6 +106,7 @@ export function useOnboardingForm({
108106 // Organization created, now redirect to plans page
109107 router . push ( `/upgrade/${ data . organizationId } ` ) ;
110108
109+ // Clear answers after successful creation
111110 setSavedAnswers ( { } ) ;
112111 } else {
113112 toast . error ( 'Failed to create organization' ) ;
0 commit comments