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

import Step from 'containers/checkout';
import { ConfirmChange, ChoosePlan } from 'containers/checkout/steps';

interface IProps extends WithTranslation {
  change?: any;
  step: string;
  pack: string;
  subscriptionId: string;
  namespacesRequired: string[];
}

const COLOR = 'ocean';

@inject('change')
class Velja extends React.Component<IProps> {
  static async getInitialProps({ query }: any) {
    const { step, subscriptionId, pack, ssn } = query;

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

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

    return (
      <Step
        color={COLOR}
        titleSteps={[t('steps.addServicepack.heading'), t('steps.confirmation.heading')]}
        totalSteps={2}
        checkoutLink="velja"
        subscriptionId={subscriptionId}
        returnLink={`/${ssn}/thjonusta/${subscriptionId}?pack=${pack}`}
      >
        <ChoosePlan />
        <ConfirmChange />
      </Step>
    );
  }
}

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