import BmsProblem from '@/components/utils/BmsProblem.vue';

export default {
  title: 'Composants/utils/Problem',
  component: BmsProblem,
};

const Template = (args) => ({
  components: {
    BmsProblem,
  },
  setup() {
    return { args };
  },
  template: `
    <BmsProblem v-bind="args"/>
  `,
});

export const GenericProblem = Template.bind({});
GenericProblem.args = {
  expanded: true,
  problem: {
    type: 'https://problems.bms.live/fake-problem/bo/loop-problem',
    title: '[FAKE] Une boucle de redirection a été detectée',
    status: 400,
    loop: '/ -> /another-url -> /',
  },
};

export const ProblemWithCorrelationId = Template.bind({});
ProblemWithCorrelationId.args = {
  expanded: true,
  problem: {
    type: 'https://problems.bms.live/fake-problem/bo/loop-problem',
    title: '[FAKE] Une boucle de redirection a été detectée',
    status: 400,
    loop: '/ -> /another-url -> /',
    correlationId: '8cba6864-6a4d-438e-acf5-d721ec4c79af',
  },
};

export const ProblemWithViolation = Template.bind({});
ProblemWithViolation.args = {
  expanded: true,
  problem: {
    name: 'siteHostRepresentation',
    violations: {
      host: [
        {
          violationType:
            'sipa.cms.admin.site.interfaces.representation.validator.SiteHostValid',
          objectType:
            'sipa.cms.admin.site.interfaces.representation.SiteHostRepresentation',
          rejectedValue: 'ouest-france.int.bms.live',
          type: 'https://problems.bms.live/cms/generic-violation',
          title: 'Elément invalide',
          status: 400,
          detail: 'Create a site host containing bms.live is forbidden',
        },
      ],
    },
    type: 'https://problems.bms.live/cms/validation-error',
    title: 'Erreur de validation',
    status: 400,
    correlationId: '8cba6864-6a4d-438e-acf5-d721ec4c79af',
    detail:
      '1 erreur(s) détecté(s) lors de la validation de siteHostRepresentation',
  },
};

export const ProblemWithDiagrams = Template.bind({});
ProblemWithDiagrams.args = {
  expanded: true,
  problem: {
    type: 'https://problems.bms.live/fake-problem/bo/loop-problem',
    title: '[FAKE] Une boucle de redirection a été detectée',
    status: 400,
    loop: '/ -> /another-url -> /',
    diagrams: ['https://placeholder.pics/svg/200'],
  },
};
