import {
  ReturnProcessQuestion,
  ReturnProcessQuestionKey,
  ReturnProcessQuestionType,
} from '../models';
import {
  ItemConditionAnswer,
  PackageIncompleteAnswer,
  ReturnReasonAnswer,
  YesNoAnswer,
} from './constants';

export const tolinoQuestions: ReturnProcessQuestion[] = [
  {
    key: ReturnProcessQuestionKey.ItemCondition,
    description: 'Wie ist der Artikelzustand?',
    type: ReturnProcessQuestionType.Select,
    options: [
      {
        label: 'Originalverpackt',
        value: ItemConditionAnswer.OVP,
        nextQuestion: ReturnProcessQuestionKey.ReturnReason,
        returnInfo: {
          itemCondition: 'Originalverpackt',
          returnDetails: {
            [ReturnProcessQuestionKey.ItemCondition]: ItemConditionAnswer.OVP,
          },
        },
      },
      {
        label: 'Geöffnet/Defekt',
        value: ItemConditionAnswer.Damaged,
        nextQuestion: ReturnProcessQuestionKey.DevicePower,
        returnInfo: {
          itemCondition: 'Geöffnet/Defekt',
          returnDetails: {
            [ReturnProcessQuestionKey.ItemCondition]:
              ItemConditionAnswer.Damaged,
          },
        },
      },
    ],
  },
  {
    key: ReturnProcessQuestionKey.DevicePower,
    description: 'Lässt sich das Gerät einschalten?',
    type: ReturnProcessQuestionType.Select,
    options: [
      {
        label: 'Ja',
        value: YesNoAnswer.Yes,
        nextQuestion: ReturnProcessQuestionKey.PackageCompleteGroup,
        returnInfo: {
          returnDetails: {
            [ReturnProcessQuestionKey.DevicePower]: YesNoAnswer.Yes,
          },
        },
      },
      {
        label: 'Nein',
        value: YesNoAnswer.No,
        nextQuestion: ReturnProcessQuestionKey.PackageCompleteGroup,
        returnInfo: {
          returnDetails: {
            [ReturnProcessQuestionKey.DevicePower]: YesNoAnswer.No,
          },
        },
      },
    ],
  },
  {
    key: ReturnProcessQuestionKey.PackageCompleteGroup,
    type: ReturnProcessQuestionType.Group,
    questions: [
      {
        key: ReturnProcessQuestionKey.PackageComplete,
        description: 'Ist die Verpackung vollständig?',
        type: ReturnProcessQuestionType.Select,
        options: [
          {
            label: 'Ja',
            value: YesNoAnswer.Yes,
            nextQuestion: ReturnProcessQuestionKey.ItemDefective,
            returnInfo: {
              returnDetails: {
                [ReturnProcessQuestionKey.PackageComplete]: YesNoAnswer.Yes,
              },
            },
          },
          {
            label: 'Nein',
            value: YesNoAnswer.No,
            nextQuestion: ReturnProcessQuestionKey.PackageIncompleteInfo,
            returnInfo: {
              returnDetails: {
                [ReturnProcessQuestionKey.PackageComplete]: YesNoAnswer.No,
              },
            },
          },
        ],
      },
      {
        key: ReturnProcessQuestionKey.PackageIncompleteInfo,
        type: ReturnProcessQuestionType.Info,
        description: 'Checkliste',
        content: [
          '1.) Karton / Umverpackung',
          '2.) Ladekabel',
          '3.) Quickstart-Guide',
        ],
        nextQuestion: ReturnProcessQuestionKey.PackageMissingItems,
      },
      {
        key: ReturnProcessQuestionKey.PackageMissingItems,
        description: 'Was fehlt?',
        type: ReturnProcessQuestionType.Checklist,
        options: [
          {
            label: 'Karton / Umverpackung',
            value: PackageIncompleteAnswer.OVP,
          },
          {
            label: 'Ladekabel',
            value: PackageIncompleteAnswer.ChargingCable,
          },
          {
            label: 'Quickstart-Guide',
            value: PackageIncompleteAnswer.QuickStartGuide,
          },
        ],
        other: {
          label: 'Sonstiges',
        },
        nextQuestion: ReturnProcessQuestionKey.ItemDefective,
      },
    ],
  },
  {
    key: ReturnProcessQuestionKey.ItemDefective,
    description: 'Hat das Gerät optische oder technische Mängel?',
    type: ReturnProcessQuestionType.Select,
    options: [
      {
        label: 'Ja',
        value: YesNoAnswer.Yes,
        nextQuestion: ReturnProcessQuestionKey.CaseDamaged,
        returnInfo: {
          returnDetails: {
            [ReturnProcessQuestionKey.ItemDefective]: YesNoAnswer.Yes,
          },
        },
      },
      {
        label: 'Nein',
        value: YesNoAnswer.No,
        nextQuestion: undefined, // Wird dynamisch auf Basis der vorherigen Antworten gesetzt - Siehe get-return-process-questions.helper.ts
        returnInfo: {
          returnDetails: {
            [ReturnProcessQuestionKey.ItemDefective]: YesNoAnswer.No,
          },
        },
      },
    ],
  },
  {
    key: ReturnProcessQuestionKey.CaseDamaged,
    description: 'Hat das Gehäuse Mängel oder ist zerkratzt?',
    type: ReturnProcessQuestionType.Select,
    options: [
      {
        label: 'Ja',
        value: YesNoAnswer.Yes,
        nextQuestion: ReturnProcessQuestionKey.DisplayDamaged,
        returnInfo: {
          returnDetails: {
            [ReturnProcessQuestionKey.CaseDamaged]: YesNoAnswer.Yes,
          },
        },
      },
      {
        label: 'Nein',
        value: YesNoAnswer.No,
        nextQuestion: ReturnProcessQuestionKey.DisplayDamaged,
        returnInfo: {
          returnDetails: {
            [ReturnProcessQuestionKey.CaseDamaged]: YesNoAnswer.No,
          },
        },
      },
    ],
  },
  {
    key: ReturnProcessQuestionKey.DisplayDamaged,
    description: 'Hat das Display Kratzer oder ist gebrochen?',
    type: ReturnProcessQuestionType.Select,
    options: [
      {
        label: 'Ja',
        value: YesNoAnswer.Yes,
        nextQuestion: ReturnProcessQuestionKey.UsbPortDamaged,
        returnInfo: {
          returnDetails: {
            [ReturnProcessQuestionKey.DisplayDamaged]: YesNoAnswer.Yes,
          },
        },
      },
      {
        label: 'Nein',
        value: YesNoAnswer.No,
        nextQuestion: ReturnProcessQuestionKey.UsbPortDamaged,
        returnInfo: {
          returnDetails: {
            [ReturnProcessQuestionKey.DisplayDamaged]: YesNoAnswer.No,
          },
        },
      },
    ],
  },
  {
    key: ReturnProcessQuestionKey.UsbPortDamaged,
    description: 'Funktioniert die USB Buchse?',
    type: ReturnProcessQuestionType.Select,
    options: [
      {
        label: 'Ja',
        value: YesNoAnswer.Yes,
        nextQuestion: ReturnProcessQuestionKey.ItemDamaged,
        returnInfo: {
          returnDetails: {
            [ReturnProcessQuestionKey.UsbPortDamaged]: YesNoAnswer.No,
          },
        },
      },
      {
        label: 'Nein',
        value: YesNoAnswer.No,
        nextQuestion: ReturnProcessQuestionKey.ItemDamaged,
        returnInfo: {
          returnDetails: {
            [ReturnProcessQuestionKey.UsbPortDamaged]: YesNoAnswer.Yes,
          },
        },
      },
    ],
  },
  {
    key: ReturnProcessQuestionKey.ReturnReason,
    description: 'Warum wird der Artikel zurückgegeben?',
    type: ReturnProcessQuestionType.Select,
    options: [
      {
        label: 'Gefällt nicht/Widerruf',
        value: ReturnReasonAnswer.Dislike,
        returnInfo: {
          returnReason: 'Gefällt nicht/Widerruf',
          returnDetails: {
            [ReturnProcessQuestionKey.ReturnReason]: ReturnReasonAnswer.Dislike,
          },
        },
      },
      {
        label: 'Fehllieferung',
        value: ReturnReasonAnswer.WrongItem,
        nextQuestion: ReturnProcessQuestionKey.DeliveredItem,
        returnInfo: {
          returnReason: 'Fehllieferung',
          returnDetails: {
            [ReturnProcessQuestionKey.ReturnReason]:
              ReturnReasonAnswer.WrongItem,
          },
        },
      },
    ],
  },
  {
    key: ReturnProcessQuestionKey.DeliveredItem,
    description: 'Welcher Artikel wurde geliefert?',
    type: ReturnProcessQuestionType.Product,
  },
  {
    key: ReturnProcessQuestionKey.ItemDamaged,
    description:
      'Wurde der Artikel durch unsachgemäße Handhabung oder Eigenverschulden beschädigt?',
    type: ReturnProcessQuestionType.Select,
    options: [
      {
        label: 'Ja',
        value: ReturnReasonAnswer.DamagedByCustomer,
        returnInfo: {
          returnReason: 'Geöffnet/Defekt',
          returnDetails: {
            [ReturnProcessQuestionKey.ItemDamaged]:
              ReturnReasonAnswer.DamagedByCustomer,
          },
        },
      },
      {
        label: 'Nein',
        value: ReturnReasonAnswer.ReceivedDamaged,
        returnInfo: {
          returnReason: 'Geöffnet/Defekt',
          returnDetails: {
            [ReturnProcessQuestionKey.ItemDamaged]:
              ReturnReasonAnswer.ReceivedDamaged,
          },
        },
      },
    ],
  },
];
