<commit_before>/**
* UploadFabsFileBox.jsx
* Created by <NAME>
*/

import React from 'react';
import PropTypes from 'prop-types';
import FileComponent from '../addData/FileComponent';
import LoadingBauble from '../SharedComponents/overlays/LoadingBauble';

const propTypes = {
    uploadFile: PropTypes.func,
    fabs: PropTypes.object,
    submission: PropTypes.object
};

const defaultProps = {
    uploadFile: () => {},
    fabs: {},
    submission: {}
};

export default class UploadFabsFileBox extends React.Component {
    uploadFile(file) {
        this.props.uploadFile(file);
    }

    render() {
        let d2Text = "Upload FABS File";
        let loadingD2 = null;
        if (this.props.fabs.status === "uploading") {
            d2Text = "Uploading";
            loadingD2 = <LoadingBauble />;
        }

        const fileStateReady = this.props.submission.files && this.props.submission.files.fabs &&
            this.props.submission.files.fabs.state === 'ready';
        const disabled = !fileStateReady || (this.props.fabs.status === "uploading");
        return (
            <div className="usa-da-upload-fabs-file-box dashed-border-top">
                <FileComponent
                    fileTitle="Financial Assistance Broker Submission (FABS) File"
                    requestName="fabs" />
                <div className="right-align-box">
                    <button
                        className="usa-da-button btn-default"
                        disabled={disabled}
                        onClick={this.props.uploadFile.bind(this, "award")}>
                        {loadingD2}{d2Text}
                    </button>
                </div>
            </div>
        );
    }
}

UploadFabsFileBox.propTypes = propTypes;
UploadFabsFileBox.defaultProps = defaultProps;
<commit_msg>Blocking upload button for FABS if file isn't a valid type<commit_after>/**
* UploadFabsFileBox.jsx
* Created by <NAME>
*/

import React from 'react';
import PropTypes from 'prop-types';
import FileComponent from '../addData/FileComponent';
import LoadingBauble from '../SharedComponents/overlays/LoadingBauble';
import { validUploadFileChecker } from '../../helpers/util';

const propTypes = {
    uploadFile: PropTypes.func,
    fabs: PropTypes.object,
    submission: PropTypes.object
};

const defaultProps = {
    uploadFile: () => {},
    fabs: {},
    submission: {}
};

export default class UploadFabsFileBox extends React.Component {
    uploadFile(file) {
        this.props.uploadFile(file);
    }

    render() {
        let d2Text = "Upload FABS File";
        let loadingD2 = null;
        if (this.props.fabs.status === "uploading") {
            d2Text = "Uploading";
            loadingD2 = <LoadingBauble />;
        }

        const fileStateReady = this.props.submission.files && this.props.submission.files.fabs &&
            this.props.submission.files.fabs.state === 'ready' &&
            validUploadFileChecker(this.props.submission.files.fabs);
        const disabled = !fileStateReady || (this.props.fabs.status === "uploading");
        return (
            <div className="usa-da-upload-fabs-file-box dashed-border-top">
                <FileComponent
                    fileTitle="Financial Assistance Broker Submission (FABS) File"
                    requestName="fabs" />
                <div className="right-align-box">
                    <button
                        className="usa-da-button btn-default"
                        disabled={disabled}
                        onClick={this.props.uploadFile.bind(this, "award")}>
                        {loadingD2}{d2Text}
                    </button>
                </div>
            </div>
        );
    }
}

UploadFabsFileBox.propTypes = propTypes;
UploadFabsFileBox.defaultProps = defaultProps;

{'fraction_non_alphanumeric': 0.12165002627430373, 'fraction_numerical': 0.0031529164477141357, 'mean_word_length': 2.070161290322581, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, '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': '369058', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1056, 'n_words': 209}