import { QuestStatus, QuestType } from '@rpg-engine/shared';
import { Meta, Story } from '@storybook/react';
import React from 'react';
import {
  IQuestInfoProps,
  QuestInfo,
} from '../../../components/Quests/QuestInfo/QuestInfo';
import { RPGUIRoot } from '../../../components/RPGUI/RPGUIRoot';
const meta: Meta = {
  title: 'Features/Quest/Quest Info',
  component: QuestInfo,
};

export default meta;

const Template: Story<IQuestInfoProps> = args => (
  <RPGUIRoot>
    <QuestInfo {...args} />
  </RPGUIRoot>
);

export const Default = Template.bind({});

const buttonMock = [
  {
    disabled: false,
    title: 'Accept',
    onClick: (QuestId: string, NPCId: String) => console.log(QuestId, NPCId),
  },
  {
    disabled: true,
    title: 'Share',
    onClick: (QuestId: string, NPCId: String) => console.log(QuestId, NPCId),
  },
  {
    disabled: false,
    title: 'Reject',
    onClick: (QuestId: string, NPCId: String) => console.log(QuestId, NPCId),
  },
];

const IQuestMock = [
  {
    _id: '6317996c77f2420047a20b55',
    rewards: [
      {
        id: '6317996c77f2420047a20b53',
        itemKeys: ['6317996c77f2420047a20b53'],
        spellKeys: ['6317996c77f2420047a20b53'],
        qty: 1,
      },
    ],
    objectives: [
      {
        id: '6317996c77f2420047a20b53',
        type: QuestType.Kill,
        status: QuestStatus.Pending,
        killCount: 10,
        killCountTarget: 30,
        creatureKeys: ['6317996c77f2420047a20b53'],
      },
    ],
    npcId: '6317996b77f2420047a20825',
    title: 'Deliver message to the trader1',
    key: 'interaction-trader',
    description:
      "Need to send a message to my brother, the trader, about my father's health. I cannot do it because it is too dangerous out there. Please, help me by delivering this message to him.",
    createdAt: '2022-09-06T19:03:08.285+0000',
    updatedAt: '2022-09-06T19:03:08.304+0000',
  },
  {
    _id: '6317996c77f2420047a20b55',
    rewards: [
      {
        id: '6317996c77f2420047a20b53',
        itemKeys: ['6317996c77f2420047a20b53'],
        spellKeys: ['6317996c77f2420047a20b53'],
        qty: 1,
      },
    ],
    objectives: [
      {
        id: '6317996c77f2420047a20b53',
        type: QuestType.Kill,
        status: QuestStatus.Pending,
        killCount: 10,
        killCountTarget: 30,
        creatureKeys: ['6317996c77f2420047a20b53'],
      },
    ],
    npcId: '6317996b77f2420047a20825',
    title: 'Deliver message to the trader2',
    key: 'interaction-trader',
    description:
      "Need to send a message to my brother, the trader, about my father's health. I cannot do it because it is too dangerous out there. Please, help me by delivering this message to him.",
    createdAt: '2022-09-06T19:03:08.285+0000',
    updatedAt: '2022-09-06T19:03:08.304+0000',
  },
];

Default.args = {
  onClose: () => console.log('closing'),
  buttons: buttonMock,
  quests: IQuestMock,
  onChangeQuest: (index: number, questId: string) =>
    console.log(index, questId),
};
