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

import Step from 'containers/checkout';
import { ChangeAutorefill } from 'containers/checkout/steps';

interface IBreytaProps extends WithTranslation {
  step: string;
  pack: string;
  subscriptionId: string;
  namespacesRequired: string[];
}

const COLOR = 'ocean';

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

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

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

    return (
      <Step
        color={COLOR}
        titleSteps={[t('steps.confirmation.heading')]}
        totalSteps={1}
        checkoutLink="breyta"
        subscriptionId={subscriptionId}
        returnLink={`/${ssn}/thjonusta/${subscriptionId}?pack=${pack}`}
      >
        <ChangeAutorefill />
      </Step>
    );

  }
}

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