<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import {
  Step,
  Stepper,
  StepButton,
  StepContent,
} from 'material-ui/Stepper';
import { FormattedMessage } from 'react-intl';
import { ShoppingCartPropType } from '../propTypes';
import PrivateRoute from '../router/privateRoute.jsx';
import AddressStepContent from './addressStepContent.jsx';
import PaymentStepContent from './paymentStepContent.jsx';
import ConfirmationStepContent from './confirmationStepContent.jsx';
import { OrderSteps } from './order.reducer';
import { createSelectStep } from '../actions';

const styles = {
  container: {
    padding: '24px',
  },
  productAvatar: {
    margin: '10px 0',
  },
  footerRow: {
    fontSize: '22px',
    fontWeight: 'bold',
  },
  amount: {
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'space-between',
  },
  buttonRow: {
    display: 'flex',
    justifyContent: 'space-between',
  },
  deleteButton: {
    marginRight: '8px',
  },
  itemsContainer: {
    display: 'flex',
    flexWrap: 'wrap',
    padding: '8px',
  },
};

class OrderStepper extends React.Component {
  componentWillMount() {
    if (this.props.shoppingCart.items.length === 0) {
      this.props.history.push('/');
    } else {
      this.navigateToCorrectStep();
    }
  }

  componentDidUpdate() {
    if (!this.props.history.location.pathname.includes(this.props.orderStep)) {
      this.navigateToCorrectStep();
    }
  }

  navigateToCorrectStep() {
    switch (this.props.orderStep) {
      default:<commit_msg>reset order stepper after unmount<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import {
  Step,
  Stepper,
  StepButton,
  StepContent,
} from 'material-ui/Stepper';
import { FormattedMessage } from 'react-intl';
import { ShoppingCartPropType } from '../propTypes';
import PrivateRoute from '../router/privateRoute.jsx';
import AddressStepContent from './addressStepContent.jsx';
import PaymentStepContent from './paymentStepContent.jsx';
import ConfirmationStepContent from './confirmationStepContent.jsx';
import { OrderSteps } from './order.reducer';
import { createSelectStep } from '../actions';

const styles = {
  container: {
    padding: '24px',
  },
  productAvatar: {
    margin: '10px 0',
  },
  footerRow: {
    fontSize: '22px',
    fontWeight: 'bold',
  },
  amount: {
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'space-between',
  },
  buttonRow: {
    display: 'flex',
    justifyContent: 'space-between',
  },
  deleteButton: {
    marginRight: '8px',
  },
  itemsContainer: {
    display: 'flex',
    flexWrap: 'wrap',
    padding: '8px',
  },
};

class OrderStepper extends React.Component {
  componentWillMount() {
    if (this.props.shoppingCart.items.length === 0) {
      this.props.history.push('/');
    } else {
      this.navigateToCorrectStep();
    }
  }

  componentDidUpdate() {
    if (!this.props.history.location.pathname.includes(this.props.orderStep)) {
      this.navigateToCorrectStep();
    }
  }

  componentWillUnmount() {
    if (this.props.orderStep === OrderSteps.CONFIRMATION) {
      this.props.selectStep(OrderSteps.ADDRESS);
    }
  }

  navigateToCorrectStep() {
    switch (this.props.orderStep) {
      default:
{'fraction_non_alphanumeric': 0.14472537053182213, 'fraction_numerical': 0.005812263876780006, 'mean_word_length': 3.577127659574468, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2866892', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1092, 'n_words': 228}