import {
  type Meta,
  type StoryObj,
  argsToTemplate,
  moduleMetadata,
} from '@storybook/angular';
import { ProductStockInfoComponent } from '@isa/remission/shared/product';
import { provideProductImageUrl } from '@isa/shared/product-image';
import { provideProductRouterLinkBuilder } from '@isa/shared/product-router-link';

const meta: Meta<ProductStockInfoComponent> = {
  component: ProductStockInfoComponent,
  title: 'remission/shared/product/ProductStockInfoComponent',
  decorators: [
    moduleMetadata({
      providers: [
        provideProductImageUrl('https://produktbilder-test.paragon-data.net'),
        provideProductRouterLinkBuilder((ean: string) => ean),
      ],
    }),
  ],
  args: {
    availableStock: 92,
    stockToRemit: 91,
    targetStock: 1,
    zob: 0,
  },
  argTypes: {
    availableStock: {
      control: { type: 'number' },
      description: 'Total available stock for the product.',
    },
    stockToRemit: {
      control: { type: 'number' },
      description: 'Stock quantity to remit.',
    },
    targetStock: {
      control: { type: 'number' },
      description: 'Target stock level after remittance.',
    },
    zob: {
      control: { type: 'number' },
      description: 'Min Stock Category Management Information.',
      defaultValue: 0,
    },
  },
  render: (args) => ({
    props: args,
    template: `<remi-product-stock-info ${argsToTemplate(args)}></remi-product-stock-info>`,
  }),
};

export default meta;

type Story = StoryObj<ProductStockInfoComponent>;

export const Default: Story = {
  args: {
    availableStock: 92,
    stockToRemit: 91,
    targetStock: 1,
    zob: 0,
  },
};
