Fix onboarding process not getting the subcription plan
This commit is contained in:
@@ -28,6 +28,9 @@ export interface UserRegistration {
|
||||
phone?: string;
|
||||
language?: string;
|
||||
timezone?: string;
|
||||
subscription_plan?: string;
|
||||
use_trial?: boolean;
|
||||
payment_method_id?: string;
|
||||
}
|
||||
|
||||
export interface UserLogin {
|
||||
|
||||
@@ -104,10 +104,14 @@ export const OnboardingWizard: React.FC = () => {
|
||||
console.log('🔄 Auto-completing user_registered step for new user...');
|
||||
setAutoCompletionAttempted(true);
|
||||
|
||||
// Merge with any existing data (e.g., subscription_plan from registration)
|
||||
const existingData = userRegisteredStep?.data || {};
|
||||
|
||||
markStepCompleted.mutate({
|
||||
userId: user.id,
|
||||
stepName: 'user_registered',
|
||||
data: {
|
||||
...existingData, // Preserve existing data like subscription_plan
|
||||
auto_completed: true,
|
||||
completed_at: new Date().toISOString(),
|
||||
source: 'onboarding_wizard_auto_completion'
|
||||
|
||||
@@ -29,7 +29,15 @@ export interface AuthState {
|
||||
|
||||
// Actions
|
||||
login: (email: string, password: string) => Promise<void>;
|
||||
register: (userData: { email: string; password: string; full_name: string; tenant_name?: string }) => Promise<void>;
|
||||
register: (userData: {
|
||||
email: string;
|
||||
password: string;
|
||||
full_name: string;
|
||||
tenant_name?: string;
|
||||
subscription_plan?: string;
|
||||
use_trial?: boolean;
|
||||
payment_method_id?: string;
|
||||
}) => Promise<void>;
|
||||
logout: () => void;
|
||||
refreshAuth: () => Promise<void>;
|
||||
updateUser: (updates: Partial<User>) => void;
|
||||
@@ -93,7 +101,15 @@ export const useAuthStore = create<AuthState>()(
|
||||
}
|
||||
},
|
||||
|
||||
register: async (userData: { email: string; password: string; full_name: string; tenant_name?: string }) => {
|
||||
register: async (userData: {
|
||||
email: string;
|
||||
password: string;
|
||||
full_name: string;
|
||||
tenant_name?: string;
|
||||
subscription_plan?: string;
|
||||
use_trial?: boolean;
|
||||
payment_method_id?: string;
|
||||
}) => {
|
||||
try {
|
||||
set({ isLoading: true, error: null });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user