<commit_before>import * as React from "react";

import renderComponentIf from "../global/renderComponentIf";

interface IParticipationProps {
    formId: string;
    email: string;
    projectActive: boolean;
    projectStatus: string;
    commitUrl: string;
}

interface IParticipationState {
    error: string;
    email: string;
}

export default class ParticipateInProject extends React.Component<IParticipationProps, IParticipationState> {
    constructor(props) {
        super(props);
        this.state = {
            error: null,
            email: null
        };
    }

    displayContactEmail = () => (
        <div>
            <p>By clicking ‘Take Part’ you’re signing up with {this.props.email}.</p>
        </div>
    )

    displayError = () => {
        if (this.state.error !== null) {
            return <div className="error">
                <p>{this.state.error}</p>
            </div>;
        }
    }

    setEmail = (event: React.ChangeEvent<HTMLInputElement>) => {
        this.setState({ email: event.currentTarget.value });
    }

    askContactEmail = () => (
        <div>
            <p>Want to participate? Enter your e-mail address and click 'Take Part'!</p>
            {this.displayError()}
            <input className="form-control" name="email" type="email" placeholder="Your e-mail address" onChange={(event) => this.setEmail(event)}></input>
        </div>
    )

    submitForm = () => {
        if (this.state.email.match(/^\S+@\S+\.\S+$/) === null) {
            this.setState({ error: "Please provide a valid e-mail address" });
            return;
        }
        const form = document.getElementById(this.props.formId) as HTMLFormElement;
        if (form) {
            form.submit();
        }
    }

    render() {
        let caption = "Participate!";
        if (this.props.projectStatus === "ComingSoon") {<commit_msg>Fixed bug in e-mail validation while logged in<commit_after>import * as React from "react";

import renderComponentIf from "../global/renderComponentIf";

interface IParticipationProps {
    formId: string;
    email: string;
    projectActive: boolean;
    projectStatus: string;
    commitUrl: string;
}

interface IParticipationState {
    error: string;
    email: string;
}

export default class ParticipateInProject extends React.Component<IParticipationProps, IParticipationState> {
    constructor(props) {
        super(props);
        this.state = {
            error: null,
            email: null
        };
    }

    displayContactEmail = () => (
        <div>
            <p>By clicking ‘Take Part’ you’re signing up with {this.props.email}.</p>
        </div>
    )

    displayError = () => {
        if (this.state.error !== null) {
            return <div className="error">
                <p>{this.state.error}</p>
            </div>;
        }
    }

    setEmail = (event: React.ChangeEvent<HTMLInputElement>) => {
        this.setState({ email: event.currentTarget.value });
    }

    askContactEmail = () => (
        <div>
            <p>Want to participate? Enter your e-mail address and click 'Take Part'!</p>
            {this.displayError()}
            <input className="form-control" name="email" type="email" placeholder="Your e-mail address" onChange={(event) => this.setEmail(event)}></input>
        </div>
    )

    submitForm = () => {
        if (!this.props.email && !this.validEmail()) {
            this.setState({ error: "Please provide a valid e-mail address" });
            return;
        }

        const form = document.getElementById(this.props.formId) as HTMLFormElement;
        if (form) {
            form.submit();
        }
    }

    private validEmail = () => this.state.email && this.state.email.match(/^\S+@\S+\.\S+$/);

    render() {
        let caption = "Participate!";
        if (this.props.projectStatus === "ComingSoon") {
{'fraction_non_alphanumeric': 0.1404552509053285, 'fraction_numerical': 0.0, 'mean_word_length': 2.195867768595041, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 48, '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': '3740747', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1097, 'n_words': 251}