import { API_URL } from '../../config'
import { SignUp, SignUpResponse } from './types'

const composeSignUpURL = () => (
    API_URL + '/signup?'
)

const composeSignUpBody = (formData: FormData) => {
    formData.append('nickname', formData.get('username') ?? '')

    return formData
}

const processSignUp = (data: SignUpResponse): SignUp => {
    if (!data.Success) {
        throw new Error(data.Message)
    }

    return true
}

export { composeSignUpURL, composeSignUpBody, processSignUp }
