<commit_before>import { routeActions } from 'react-router-redux'
import { createUser, getUser, updateUser } from 'utils/api'
import { status, json } from 'utils/fetch'
import types from '../constants'

const { ADD_SHIPPING_INFO } = types

const addShippingInfo = (consumer, details) => {
    return {
        type: ADD_SHIPPING_INFO,
        initialized: true,
        consumer,
        details
    }
}

let server = SERVER
if (process.env.SERVER) {
    server = process.env.SERVER
}

export const submitForm = (values, dispatch) => {
    let shippingDetails = {
        shipAccount: values.shipAccount,
        shipAccountNum: values.shipAccountNum,
        comments: values.comments
    }
    return new Promise((resolve, reject) => {
        getUser(server, values.email)
        .then(response => {
            if (response.status === 200) {
                return Promise.resolve(true)
            } else if (response.status === 404) {
                return Promise.resolve(false)
            }
            return Promise.reject(new Error('Error'))
        })
        .then(userExists => {
            if (userExists) {
                updateUser(server, values)
                .then(status)
                .then(json)
                .then(consumer => {
                    resolve()
                    dispatch(addShippingInfo(consumer, shippingDetails))
                    dispatch(routeActions.push('/order/payment'))
                })
                .catch(error => {
                    reject({_error: 'User cannot be updated', error})
                })
            } else {
                createUser(server, values)
                .then(status)
                .then(json)
                .then(consumer => {
                    resolve()
                    dispatch(addShippingInfo(consumer, shippingDetails))
                    dispatch(routeActions.push('/order/billing'))
                })<commit_msg>changed the names of some variables<commit_after>import { routeActions } from 'react-router-redux'
import { createUser, getUser, updateUser } from 'utils/api'
import { status, json } from 'utils/fetch'
import types from 'constants'

const { ADD_SHIPPING } = types

const addShipping = (user, details) => {
    return {
        type: ADD_SHIPPING,
        initialized: true,
        user,
        details
    }
}

let server = SERVER
if (process.env.SERVER) {
    server = process.env.SERVER
}

export const submitForm = (values, dispatch) => {
    let details = {
        shipAccount: values.shipAccount,
        shipAccountNum: values.shipAccountNum,
        comments: values.comments
    }
    return new Promise((resolve, reject) => {
        getUser(server, values.email)
        .then(response => {
            if (response.status === 200) {
                return Promise.resolve(true)
            } else if (response.status === 404) {
                return Promise.resolve(false)
            }
            return Promise.reject(new Error('Error'))
        })
        .then(userExists => {
            if (userExists) {
                updateUser(server, values)
                .then(status)
                .then(json)
                .then(user => {
                    resolve()
                    dispatch(addShipping(user, details))
                    dispatch(routeActions.push('/order/payment'))
                })
                .catch(error => {
                    reject({_error: 'User cannot be updated', error})
                })
            } else {
                createUser(server, values)
                .then(status)
                .then(json)
                .then(user => {
                    resolve()
                    dispatch(addShipping(user, details))
                    dispatch(routeActions.push('/order/payment'))
                })
{'fraction_non_alphanumeric': 0.10889530307006035, 'fraction_numerical': 0.003148779847808974, 'mean_word_length': 1.573936529372046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '4600252', 'n_tokens_mistral': 1006, 'n_tokens_neox': 946, 'n_words': 213}