import {
  type Meta,
  type StoryObj,
  applicationConfig,
  argsToTemplate,
  moduleMetadata,
} from '@storybook/angular';
import { ProductInfoRedemptionComponent } from '@isa/checkout/shared/product-info';
import { provideProductImageUrl } from '@isa/shared/product-image';
import { provideProductRouterLinkBuilder } from '@isa/shared/product-router-link';
import { provideRouter } from '@angular/router';

const meta: Meta<ProductInfoRedemptionComponent> = {
  title: 'checkout/shared/product-info/ProductInfoRedemption',
  component: ProductInfoRedemptionComponent,
  decorators: [
    applicationConfig({
      providers: [
        provideRouter([
          { path: ':ean', component: ProductInfoRedemptionComponent },
        ]),
      ],
    }),
    moduleMetadata({
      providers: [
        provideProductImageUrl('https://produktbilder-test.paragon-data.net'),
        provideProductRouterLinkBuilder((ean: string) => ean),
      ],
    }),
  ],
};

export default meta;

type Story = StoryObj<ProductInfoRedemptionComponent>;

export const Primary: Story = {
  args: {
    item: {
      product: {
        ean: '9783498007706',
        name: 'Die Assistentin',
        contributors: 'Wahl, Caroline',
        format: 'TB',
        formatDetail: 'Taschenbuch (Kartoniert)',
        manufacturer: 'Test Manufacturer',
        publicationDate: '2023-01-01',
      },
      redemptionPoints: 100,
    },
    orientation: 'vertical',
  },
  argTypes: {
    item: { control: 'object' },
    orientation: {
      control: { type: 'radio' },
      options: ['horizontal', 'vertical'],
    },
  },
};
