import type { Meta, StoryObj } from '@storybook/angular';
import type { UploadState } from '@shared/upload/upload.machine';
import { DocumentUploadComponent } from './document-upload.component';

const meta: Meta<DocumentUploadComponent> = {
  title: 'Organisms/DocumentUpload',
  component: DocumentUploadComponent,
  render: (args) => ({
    props: args,
    template: `<app-document-upload [state]="state" />`,
  }),
};
export default meta;
type Story = StoryObj<DocumentUploadComponent>;

const state: UploadState = {
  categories: [
    {
      categoryId: 'diploma',
      label: 'Diploma',
      description: 'Een kopie van uw diploma (PDF, max 10 MB).',
      required: true,
      acceptedTypes: ['application/pdf'],
      maxSizeMb: 10,
      multiple: false,
      allowPostDelivery: true,
    },
    {
      categoryId: 'cv',
      label: 'Curriculum vitae',
      description: 'Uw cv (PDF of Word).',
      required: false,
      acceptedTypes: ['application/pdf', 'application/msword'],
      maxSizeMb: 5,
      multiple: true,
      allowPostDelivery: false,
    },
  ],
  uploads: [
    {
      localId: 'u-1',
      categoryId: 'diploma',
      fileName: 'diploma.pdf',
      fileSizeMb: 1.2,
      status: { type: 'complete', documentId: 'doc-1' },
      backgroundSync: false,
    },
  ],
  deliveryChannel: { diploma: 'digital', cv: 'digital' },
  rejections: {},
  backgroundSyncAvailable: true,
};

export const Default: Story = { args: { state } };

export const LoadError: Story = {
  args: { state: { ...state, categoriesError: 'De categorieën konden niet worden geladen.' } },
};
