diff --git a/portal/src/components/entities/resident_registration/multi_step_resident_wizard.rs b/portal/src/components/entities/resident_registration/multi_step_resident_wizard.rs index a3b51f3..339ebf1 100644 --- a/portal/src/components/entities/resident_registration/multi_step_resident_wizard.rs +++ b/portal/src/components/entities/resident_registration/multi_step_resident_wizard.rs @@ -227,7 +227,7 @@ impl Component for MultiStepResidentWizard { DigitalResidentFormData::default() }; - // Create steps + // Create initial steps (will be updated dynamically) let steps: Vec>> = vec![ Rc::new(PersonalInfoStep), Rc::new(PaymentStep::new()), @@ -251,6 +251,14 @@ impl Component for MultiStepResidentWizard { match msg { MultiStepResidentWizardMsg::FormDataChanged(new_data) => { self.form_data = new_data; + + // If we don't have a client secret yet and the form has enough data for payment, + // automatically create the payment intent + if self.client_secret.is_none() && !self.form_data.full_name.is_empty() && !self.form_data.email.is_empty() { + console::log_1(&"🔧 Form data updated with valid info, creating payment intent...".into()); + ctx.link().send_message(MultiStepResidentWizardMsg::CreatePaymentIntent); + } + true } MultiStepResidentWizardMsg::FormCompleted(final_data) => { @@ -335,7 +343,7 @@ impl Component for MultiStepResidentWizard { on_form_change={on_form_change} on_complete={on_complete} on_cancel={Some(on_cancel)} - steps={self.steps.clone()} + steps={self.create_steps_with_client_secret()} validators={self.validators.clone()} show_progress={true} allow_skip_validation={false} @@ -364,6 +372,16 @@ impl Component for MultiStepResidentWizard { } impl MultiStepResidentWizard { + fn create_steps_with_client_secret(&self) -> Vec>> { + let mut payment_step = PaymentStep::new(); + payment_step.set_client_secret(self.client_secret.clone()); + + vec![ + Rc::new(PersonalInfoStep), + Rc::new(payment_step), + ] + } + fn create_payment_intent(&self, ctx: &Context) { let link = ctx.link().clone(); let form_data = self.form_data.clone(); diff --git a/portal/src/components/resident_landing_overlay.rs b/portal/src/components/resident_landing_overlay.rs index 078bd17..7a2ff18 100644 --- a/portal/src/components/resident_landing_overlay.rs +++ b/portal/src/components/resident_landing_overlay.rs @@ -1,7 +1,7 @@ use yew::prelude::*; use web_sys::HtmlInputElement; use crate::models::company::{DigitalResidentFormData, DigitalResident}; -use crate::components::entities::resident_registration::SimpleResidentWizard; +use crate::components::entities::resident_registration::MultiStepResidentWizard; #[derive(Properties, PartialEq)] pub struct ResidentLandingOverlayProps { @@ -344,7 +344,7 @@ impl ResidentLandingOverlay { // Registration wizard content with fade-in animation
-