<commit_before>import React, {Component} from 'react'
import PropTypes from 'prop-types'
import {
    Button,
    Modal,
    Row,
    Col,
    Form,
    FormGroup,
    HelpBlock,
    FormControl,
    ControlLabel,
    Well
} from 'react-bootstrap'
import {CubeGrid, ThreeBounce} from 'better-react-spinkit'
import EtherAmount from './EtherAmount'
import CurrentOrderStateAlert from "./CurrentOrderStateAlert"
import { BigNumWeiToDisplayString, secondsToDisplayString} from "./Utils"


class FundOrderModal extends Component {

    constructor(props) {
        super(props)
        this.state = {
            amount: props.order.paymentAmount,
            numberOfPayments: 1,
        }

        this.reset = this.reset.bind(this)
        this.handleAmountChange = this.handleAmountChange.bind(this)
        this.handleNumPaymentsChange = this.handleNumPaymentsChange.bind(this)
        this.handleSubmit = this.handleSubmit.bind(this)
        this.getTotalCoveredPayments = this.getTotalCoveredPayments.bind(this)
        this.getNewFailureDate = this.getNewFailureDate.bind(this)
    }

    componentWillReceiveProps(nextProps) {
        // Make sure to reset input fields to default values when opening modal
        if (nextProps.showModal !== this.state.showModal){
            if (nextProps.showModal)
                this.reset()
        }
    }

    reset() {
        if (this.props.order.ownerFunds < 0) {
            // Set the missing amount as start value
            this.handleAmountChange(this.props.order.ownerFunds.abs())
        } else {<commit_msg>Bugfix: Don't update payment amount while modal is open.<commit_after>import React, {Component} from 'react'
import PropTypes from 'prop-types'
import {
    Button,
    Modal,
    Row,
    Col,
    Form,
    FormGroup,
    HelpBlock,
    FormControl,
    ControlLabel,
    Well
} from 'react-bootstrap'
import {CubeGrid, ThreeBounce} from 'better-react-spinkit'
import EtherAmount from './EtherAmount'
import CurrentOrderStateAlert from "./CurrentOrderStateAlert"
import { BigNumWeiToDisplayString, secondsToDisplayString} from "./Utils"


class FundOrderModal extends Component {

    constructor(props) {
        super(props)
        this.state = {
            amount: props.order.paymentAmount,
            numberOfPayments: 1,
        }

        this.reset = this.reset.bind(this)
        this.handleAmountChange = this.handleAmountChange.bind(this)
        this.handleNumPaymentsChange = this.handleNumPaymentsChange.bind(this)
        this.handleSubmit = this.handleSubmit.bind(this)
        this.getTotalCoveredPayments = this.getTotalCoveredPayments.bind(this)
        this.getNewFailureDate = this.getNewFailureDate.bind(this)
    }

    componentWillReceiveProps(nextProps) {
        // Make sure to reset input fields to default values when opening modal
        if (nextProps.showModal !== this.props.showModal){
            if (nextProps.showModal)
                this.reset()
        }
    }

    reset() {
        if (this.props.order.ownerFunds < 0) {
            // Set the missing amount as start value
            this.handleAmountChange(this.props.order.ownerFunds.abs())
        } else {
{'fraction_non_alphanumeric': 0.09228346456692914, 'fraction_numerical': 0.0012598425196850393, 'mean_word_length': 2.718969555035129, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3703906', 'n_tokens_mistral': 918, 'n_tokens_neox': 885, 'n_words': 198}