import type { Meta, StoryObj } from '@storybook/angular';
import { applicationConfig } from '@storybook/angular';
import { provideHttpClient } from '@angular/common/http';
import { provideApiClient } from '@shared/infrastructure/api-client.provider';
import { IntakeWizardComponent } from './intake-wizard.component';
import { IntakeState, Answers } from '@herregistratie/domain/intake.machine';
import { Uren } from '@registratie/domain/value-objects/uren';

const validData = { werktBuitenland: false, uren: 4160 as Uren, punten: 200 as Uren };

const meta: Meta<IntakeWizardComponent> = {
  title: 'Domein/Herregistratie/IntakeWizard',
  component: IntakeWizardComponent,
  // Injects BigProfileStore (optimistic flag) which creates httpResources.
  decorators: [applicationConfig({ providers: [provideHttpClient(), provideApiClient()] })],
};
export default meta;
type Story = StoryObj<IntakeWizardComponent>;

const answering = (answers: Answers, cursor = 0): IntakeState => ({
  tag: 'Answering',
  answers,
  cursor,
  errors: {},
  scholingThreshold: 1000,
});

export const Start: Story = { args: { seed: answering({}) } };
// Inline reveal: country/hours appear within the buitenland step (cursor 0).
export const AbroadBranch: Story = { args: { seed: answering({ buitenlandGewerkt: 'ja' }, 0) } };
// Inline reveal: the scholing question appears within the werk step (cursor 1).
export const LowHoursScholing: Story = {
  args: { seed: answering({ buitenlandGewerkt: 'nee', uren: '500' }, 1) },
};
export const Review: Story = {
  args: { seed: answering({ buitenlandGewerkt: 'nee', uren: '4160', punten: '200' }, 2) },
};
export const Submitting: Story = { args: { seed: { tag: 'Submitting', data: validData } } };
export const Submitted: Story = { args: { seed: { tag: 'Submitted', data: validData } } };
export const Failed: Story = {
  args: { seed: { tag: 'Failed', data: validData, error: 'Netwerkfout' } },
};
