more refactor complete
This commit is contained in:
		@@ -227,7 +227,7 @@ impl Component for MultiStepResidentWizard {
 | 
			
		||||
            DigitalResidentFormData::default()
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        // Create steps
 | 
			
		||||
        // Create initial steps (will be updated dynamically)
 | 
			
		||||
        let steps: Vec<Rc<dyn FormStep<DigitalResidentFormData>>> = 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<Rc<dyn FormStep<DigitalResidentFormData>>> {
 | 
			
		||||
        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<Self>) {
 | 
			
		||||
        let link = ctx.link().clone();
 | 
			
		||||
        let form_data = self.form_data.clone();
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
                <div class="flex-grow-1 overflow-auto"
 | 
			
		||||
                     style="opacity: 0; animation: fadeIn 0.5s ease-in-out 0.25s forwards;">
 | 
			
		||||
                    <SimpleResidentWizard
 | 
			
		||||
                    <MultiStepResidentWizard
 | 
			
		||||
                        on_registration_complete={link.callback(ResidentLandingMsg::RegistrationComplete)}
 | 
			
		||||
                        on_back_to_parent={link.callback(|_| ResidentLandingMsg::BackToLanding)}
 | 
			
		||||
                        success_resident_id={None}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user