import * as React from 'react';
import { withTranslation, WithTranslation } from 'utils/i18n';

import Step from 'containers/checkout';
import { GetSlots, GetTimeSlots, BookSlot } from 'containers/checkout/steps/heimsokn';

interface IProps extends WithTranslation {
  step: string;
  subscriptionId: string;
  namespacesRequired: string[];
  ssn: string;
}

const COLOR = 'ocean';

class Heimsokn extends React.Component<IProps> {
  static async getInitialProps({ query }: any) {
    const { step, subscriptionId, ssn } = query;

    return {
      step,
      subscriptionId,
      ssn,
      namespacesRequired: ['change'],
    };
  }

  render() {
    const { subscriptionId, ssn, t } = this.props;

    return (
      <Step
        color={COLOR}
        titleSteps={[
          t('steps.getSlots.header'),
          t('steps.getTimeSlots.header'),
          t('steps.bookSlot.button'),
        ]}
        totalSteps={3}
        checkoutLink="heimsokn"
        subscriptionId={subscriptionId}
        returnLink={`/${ssn}/thjonusta/${subscriptionId}`}
      >
        <GetSlots />
        <GetTimeSlots />
        <BookSlot />
      </Step>
    );
  }
}

export default withTranslation('change')(Heimsokn);
