refactor(#509): removed first and last names in registration (#194)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Mirlan 5 years ago committed by GitHub
parent 7eea131fb5
commit f188724314
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/features/Register/components/RegistrationStep/hooks/useSubmitHandler.tsx
  2. 10
      src/features/Register/components/RegistrationStep/hooks/useValidateForm.tsx
  3. 16
      src/features/Register/components/RegistrationStep/index.tsx
  4. 6
      src/requests/register.tsx

@ -20,15 +20,11 @@ export const useSubmitHandler = () => {
event.preventDefault()
if (validateForm()) {
const firstname = readTrimmedValue(formIds.firstname)
const lastname = readTrimmedValue(formIds.lastname)
const email = readTrimmedValue(formIds.email)
const password = readTrimmedValue(formIds.password)
register({
email,
firstname,
lastname,
password,
})
}

@ -17,18 +17,8 @@ export const useValidateForm = () => {
const validateForm = () => {
let hasError = false
const firstname = readTrimmedValue(formIds.firstname)
const lastname = readTrimmedValue(formIds.lastname)
const email = readTrimmedValue(formIds.email)
const password = readTrimmedValue(formIds.password)
if (!firstname) {
updateFormError(formIds.firstname, 'error_fill_out_this_field')
hasError = true
}
if (!lastname) {
updateFormError(formIds.lastname, 'error_fill_out_this_field')
hasError = true
}
if (!email) {
updateFormError(formIds.email, 'error_empty_email')
hasError = true

@ -14,7 +14,7 @@ import { FormStore } from 'features/FormStore'
import { useRegistrationForm } from './hooks'
const labelWidth = 116
const labelWidth = 76
const Registration = () => {
const {
@ -30,20 +30,6 @@ const Registration = () => {
<BlockTitle>
<T9n t='step_title_registration' />
</BlockTitle>
<Input
value={readFormValue(formIds.firstname)}
error={readFormError(formIds.firstname)}
labelLexic='form_firstname'
labelWidth={labelWidth}
onChange={updateFormValue(formIds.firstname)}
/>
<Input
value={readFormValue(formIds.lastname)}
error={readFormError(formIds.lastname)}
labelLexic='form_lastname'
labelWidth={labelWidth}
onChange={updateFormValue(formIds.lastname)}
/>
<Input
value={readFormValue(formIds.email)}
error={readFormError(formIds.email)}

@ -15,23 +15,17 @@ type Response = {
type Args = {
email: string,
firstname: string,
lastname: string,
password: string,
}
export const register = async ({
email,
firstname,
lastname,
password,
}: Args) => {
const config = {
body: {
params: {
_p_email: email,
_p_firstname: firstname,
_p_lastname: lastname,
_p_password: password,
},
proc,

Loading…
Cancel
Save