<commit_before>export const TOGGLE_PROFILE_VIEW = 'TOGGLE_PROFILE_VIEW';
export const TOGGLE_EVENT = 'TOGGLE_EVENT';
export const REQUEST_LOGIN = 'REQUEST_LOGIN';
export const RECEIVE_LOGIN = 'RECEIVE_LOGIN';
export const FAIL_LOGIN = 'FAIL_LOGIN';
export const REQUEST_EVENTS = 'REQUEST_EVENTS';
export const RECEIVE_EVENTS = 'RECEIVE_EVENTS';
export const FAIL_TO_GET_EVENTS = 'FAIL_TO_GET_EVENTS';
export const REQUEST_VENUE = 'REQUEST_VENUE';
export const RECEIVE_VENUE = 'RECEIVE_VENUE';
export const RECEIVE_ALL_VENUES = 'RECEIVE_ALL_VENUES';
export const FAIL_TO_RECEIVE_VENUE = 'FAIL_TO_RECEIVE_VENUE';
export const REQUEST_SKILLS = 'REQUEST_SKILLS';
export const RECEIVE_SKILLS = 'RECEIVE_SKILLS';
export const FAIL_TO_GET_SKILLS = 'FAIL_TO_GET_SKILLS';
export const RSVPD_TO_EVENT = 'RSVPD_TO_EVENT';
export const UPDATE_EMAIL = 'UPDATE_EMAIL';
export const UPDATE_NNUMBER = 'UPDATE_NNUMBER';
export const SEND_PERSON = 'SEND_PERSON';

export function fetchAll() {
    return (dispatch, getState) => {
        dispatch(fetchPerson()).then(() => dispatch(fetchEvents())
            .then(() => Promise.all(
                getState().eventActions.events.map((event, i) => dispatch(fetchVenue(event.relationships.venue.data.id, i))))
                .then(() => dispatch(fetchSkills())
            )
        ))
    }
}

export function updateEmail(email) {
    return {
        type: UPDATE_EMAIL,
        email
    }
}

export function updateNNumber(nNumber) {
    return {
        type: UPDATE_NNUMBER,
        nNumber
    }
}

function sendPerson() {
    return {
        type: SEND_PERSON
    }
}

export function postPerson() {
    return (dispatch, getState) => {
        dispatch(sendPerson());
        const nNumber = getState().loginActions.person.attributes.nNumber;
        const person = Object.assign({}, getState().loginActions.person, {
            type: 'people',
            id: getState().loginActions.person.id,
            attributes: {
                contact: getState().loginActions.person.attributes.contact
            }
        });
        if (nNumber.length > 0) person.attributes.nNumber = nNumber;
        const data = {
            data: person,
        };
        $.ajax({
                type: 'PATCH',
                acccepts: 'application/vnd.api+json',
                contentType: 'application/vnd.api+json',
                url: 'https://api.tnyu.org/' + window.API_VERSION + '/people/me',
                crossDomain: true,
                dataType: 'json',
                data: JSON.stringify(data),
            })
        .done( response => {<commit_msg>validate email<commit_after>export const TOGGLE_PROFILE_VIEW = 'TOGGLE_PROFILE_VIEW';
export const TOGGLE_EVENT = 'TOGGLE_EVENT';
export const REQUEST_LOGIN = 'REQUEST_LOGIN';
export const RECEIVE_LOGIN = 'RECEIVE_LOGIN';
export const FAIL_LOGIN = 'FAIL_LOGIN';
export const REQUEST_EVENTS = 'REQUEST_EVENTS';
export const RECEIVE_EVENTS = 'RECEIVE_EVENTS';
export const FAIL_TO_GET_EVENTS = 'FAIL_TO_GET_EVENTS';
export const REQUEST_VENUE = 'REQUEST_VENUE';
export const RECEIVE_VENUE = 'RECEIVE_VENUE';
export const RECEIVE_ALL_VENUES = 'RECEIVE_ALL_VENUES';
export const FAIL_TO_RECEIVE_VENUE = 'FAIL_TO_RECEIVE_VENUE';
export const REQUEST_SKILLS = 'REQUEST_SKILLS';
export const RECEIVE_SKILLS = 'RECEIVE_SKILLS';
export const FAIL_TO_GET_SKILLS = 'FAIL_TO_GET_SKILLS';
export const RSVPD_TO_EVENT = 'RSVPD_TO_EVENT';
export const UPDATE_EMAIL = 'UPDATE_EMAIL';
export const UPDATE_NNUMBER = 'UPDATE_NNUMBER';
export const SEND_PERSON = 'SEND_PERSON';

export function fetchAll() {
    return (dispatch, getState) => {
        dispatch(fetchPerson()).then(() => dispatch(fetchEvents())
            .then(() => Promise.all(
                getState().eventActions.events.map((event, i) => dispatch(fetchVenue(event.relationships.venue.data.id, i))))
                .then(() => dispatch(fetchSkills())
            )
        ))
    }
}

export function updateEmail(email) {
    return {
        type: UPDATE_EMAIL,
        email
    }
}

export function updateNNumber(nNumber) {
    return {
        type: UPDATE_NNUMBER,
        nNumber
    }
}

function sendPerson() {
    return {
        type: SEND_PERSON
    }
}

export function postPerson() {
    return (dispatch, getState) => {
        dispatch(sendPerson());
        const nNumber = getState().loginActions.person.attributes.nNumber;
        const person = Object.assign({}, getState().loginActions.person, {
            type: 'people',
            id: getState().loginActions.person.id,
            attributes: {
                contact: getState().loginActions.person.attributes.contact
            }
        });
        if (nNumber) if (nNumber.length > 0) person.attributes.nNumber = nNumber;
        const data = {
            data: person,
        };
        $.ajax({
                type: 'PATCH',
                acccepts: 'application/vnd.api+json',
                contentType: 'application/vnd.api+json',
                url: 'https://api.tnyu.org/' + window.API_VERSION + '/people/me',
                crossDomain: true,
                dataType: 'json',
                data: JSON.stringify(data),
            })
        .done( response => {
{'fraction_non_alphanumeric': 0.11489850631941785, 'fraction_numerical': 0.00038299502106472615, 'mean_word_length': 2.784782608695652, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 2, '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': '5720900', 'n_tokens_mistral': 1679, 'n_tokens_neox': 1606, 'n_words': 323}