Restore Firestore save logic in SetupWizard with proper user authentication
This commit is contained in:
1 parent
884dc7e835
commit
3f4c60ab67
2 files changed
+10
-3
No files matched your search
+1
-1
@@ -567,7 +567,7 @@ export default function BudgetDashboard() {
|
||||
|
||||
{/* Modals and Components */}
|
||||
{showAuthModal && <AuthModal isOpen={showAuthModal} onClose={() => setShowAuthModal(false)} onAuthSuccess={handleAuthSuccess} />}
|
||||
{showSetupWizard && <SetupWizard onComplete={handleSetupComplete} onSkip={() => setShowSetupWizard(false)} />}
|
||||
{showSetupWizard && <SetupWizard onComplete={handleSetupComplete} onSkip={() => setShowSetupWizard(false)} userId={user?.uid || ''} />}
|
||||
{editingTransaction && (
|
||||
<TransactionEdit
|
||||
transaction={editingTransaction}
|
||||
|
||||
@@ -28,11 +28,12 @@ interface Envelope {
|
||||
interface SetupWizardProps {
|
||||
onComplete: (accounts: Account[], envelopes: Envelope[]) => void;
|
||||
onSkip: () => void;
|
||||
userId: string;
|
||||
}
|
||||
|
||||
type WizardStep = 'welcome' | 'data-source' | 'accounts' | 'envelopes' | 'income-setup' | 'get-paid-setup' | 'complete';
|
||||
|
||||
export default function SetupWizard({ onComplete, onSkip }: SetupWizardProps) {
|
||||
export default function SetupWizard({ onComplete, onSkip, userId }: SetupWizardProps) {
|
||||
const [currentStep, setCurrentStep] = useState<WizardStep>('welcome');
|
||||
const [dataSource, setDataSource] = useState<'import' | 'manual' | null>(null);
|
||||
const [accounts, setAccounts] = useState<Account[]>([]);
|
||||
@@ -147,9 +148,15 @@ export default function SetupWizard({ onComplete, onSkip }: SetupWizardProps) {
|
||||
return account;
|
||||
});
|
||||
|
||||
await DataService.saveUserData(userId, {
|
||||
accounts: accountsWithDefaults,
|
||||
envelopes: envelopesWithAllocations,
|
||||
transactions: [],
|
||||
setupCompleted: true,
|
||||
});
|
||||
onComplete(accountsWithDefaults, envelopesWithAllocations);
|
||||
} catch (error) {
|
||||
console.error('Error completing setup:', error);
|
||||
console.error('Error saving setup data:', error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user