// src/lib/components/machines/SignInMachine.ts
import { createMachine, assign } from 'xstate';

export const SignInMachine = createMachine({
    id: 'signIn',
    initial: 'notSignedIn',
    context: {
        email: '',
        name: ''
    },
    states: {
        notSignedIn: {
            on: { START: 'email' }
        },
        email: {
            on: {
                NEXT: {
                    target: 'name',
                    actions: assign({ email: (_, event) => event.value })
                }
            }
        },
        name: {
            on: {
                NEXT: {
                    target: 'signedIn',
                    actions: assign({ name: (_, event) => event.value })
                }
            }
        },
        signedIn: {
            type: 'final'
        }
    }
});