use snake_case field names for registration form
Although not conventional, our API uses snake_case and returns form field exceptions in the same format. Thus to avoid handling variable name conversions it is probably for the better
This commit is contained in:
3 files changed
+13
-12
No files matched your search
+5
-4
@@ -79,7 +79,8 @@ export function requestUserData(authToken: string) {
|
||||
};
|
||||
}
|
||||
|
||||
export function requestRegisterUser({ firstName, lastName, email, phoneNumber, password }: UserRegisterFormValues) {
|
||||
// We use snake_case in order to fetch and display field errors from the API without any additional formatting
|
||||
export function requestRegisterUser({ first_name, last_name, email, phone_number, password }: UserRegisterFormValues) {
|
||||
return (dispatch: AppDispatch) => {
|
||||
dispatch(registerUserRequest());
|
||||
|
||||
@@ -90,10 +91,10 @@ export function requestRegisterUser({ firstName, lastName, email, phoneNumber, p
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
first_name: first_name,
|
||||
last_name: last_name,
|
||||
email,
|
||||
phone_number: phoneNumber,
|
||||
phone_number: phone_number,
|
||||
password,
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -24,15 +24,15 @@ const UserRegister = () => {
|
||||
<View style={styles.card}>
|
||||
<ScrollView>
|
||||
<FormInput
|
||||
name="firstName"
|
||||
name="first_name"
|
||||
label="Fornavn"
|
||||
control={control}
|
||||
errors={errors}
|
||||
autoFocus
|
||||
onSubmitEditing={() => setFocus('lastName')}
|
||||
onSubmitEditing={() => setFocus('last_name')}
|
||||
/>
|
||||
<FormInput
|
||||
name="lastName"
|
||||
name="last_name"
|
||||
label="Etternavn"
|
||||
control={control}
|
||||
errors={errors}
|
||||
@@ -50,10 +50,10 @@ const UserRegister = () => {
|
||||
required: 'Kan ikke være tomt!',
|
||||
validate: (v) => EmailValidator.validate(v) || 'er ikke en gyldig e-post',
|
||||
}}
|
||||
onSubmitEditing={() => setFocus('phoneNumber')}
|
||||
onSubmitEditing={() => setFocus('phone_number')}
|
||||
/>
|
||||
<FormInput
|
||||
name="phoneNumber"
|
||||
name="phone_number"
|
||||
label="Mobilnummer"
|
||||
control={control}
|
||||
errors={errors}
|
||||
|
||||
@@ -7,10 +7,10 @@ import { useAppDispatch, useAppSelector, usePrevious } from 'src/hooks';
|
||||
import { ToastProps } from 'src/types/toast';
|
||||
|
||||
export interface UserRegisterFormValues {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
email: string;
|
||||
phoneNumber: string;
|
||||
phone_number: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user