Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dashboard
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
red-giant
dashboard
Commits
37c55739
Verified
Commit
37c55739
authored
3 years ago
by
Defendi Alberto
Browse files
Options
Downloads
Patches
Plain Diff
Simple registration call
parent
d7fe0406
No related branches found
No related tags found
2 merge requests
!56
Refined auth flow and new website pages.
,
!41
Sign up form setup
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/AuthUser/SignUpForm/SignUpForm.tsx
+44
-129
44 additions, 129 deletions
src/components/AuthUser/SignUpForm/SignUpForm.tsx
with
44 additions
and
129 deletions
src/components/AuthUser/SignUpForm/SignUpForm.tsx
+
44
−
129
View file @
37c55739
...
@@ -8,42 +8,53 @@ import axios from 'axios';
...
@@ -8,42 +8,53 @@ import axios from 'axios';
// TODO: Replace notes with big input field
// TODO: Replace notes with big input field
export
const
SignUpForm
:
FC
=
()
=>
{
export
const
SignUpForm
:
FC
=
()
=>
{
type
FormData
=
{
type
FormData
=
{
user
:
{
username
:
string
;
username
:
string
;
password
:
string
;
password
:
string
;
firstName
:
string
;
firstName
:
string
;
lastName
:
string
;
lastName
:
string
;
email
:
string
;
email
:
string
;
};
phoneNumber
:
number
;
homeAddress
:
{
address
:
string
;
};
memberCardIssuer
:
{
name
:
string
;
};
memberCardNumber
:
number
;
notes
:
string
;
};
};
const
{
control
,
errors
,
handleSubmit
}
=
useForm
<
FormData
>
();
const
defaultValues
:
FormData
=
{
username
:
''
,
password
:
''
,
firstName
:
''
,
lastName
:
''
,
email
:
''
,
};
const
{
control
,
errors
,
handleSubmit
}
=
useForm
<
FormData
>
({
defaultValues
,
});
const
onSubmit
:
SubmitHandler
<
FormData
>
=
(
values
:
FormData
)
=>
{
const
onSubmit
:
SubmitHandler
<
FormData
>
=
(
values
:
FormData
)
=>
{
axios
.
post
(
axios
'
/api/web/seniors/
'
,
.
post
(
{
'
/api/web/seniors/
'
,
user
:
values
.
user
,
{
phone_number
:
values
.
phoneNumber
,
user
:
{
home_address
:
values
.
homeAddress
.
address
,
username
:
'
test
'
,
member_card_issuer
:
values
.
memberCardIssuer
,
password
:
values
.
password
,
notes
:
values
.
notes
,
firstName
:
'
a
'
,
},
lastName
:
'
b
'
,
{
email
:
values
.
email
,
headers
:
{
},
'
Content-Type
'
:
'
application/json
'
,
phone_number
:
'
213432234
'
,
home_address
:
{
address
:
'
test street, 3
'
,
},
member_card_issuer
:
{
name
:
'
test issuer
'
,
},
member_card_number
:
'
33333333333
'
,
},
},
},
{
);
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
},
},
)
.
then
((
res
)
=>
console
.
log
(
res
));
};
};
const
classes
=
useStyles
();
const
classes
=
useStyles
();
...
@@ -54,101 +65,6 @@ export const SignUpForm: FC = () => {
...
@@ -54,101 +65,6 @@ export const SignUpForm: FC = () => {
onSubmit
=
{
handleSubmit
(
onSubmit
)
}
onSubmit
=
{
handleSubmit
(
onSubmit
)
}
data-testid
=
"Form"
data-testid
=
"Form"
>
>
<
InputField
name
=
"firstName"
control
=
{
control
}
rules
=
{
{
validate
:
(
value
:
string
)
=>
/^
[
A-Za-z
]
$/
.
test
(
value
),
required
:
{
value
:
true
,
message
:
'
firstName is not valid
'
,
},
}
}
label
=
"First name"
error
=
{
!!
errors
.
user
?.
firstName
}
errorMessage
=
"Insert firstName"
/>
<
InputField
name
=
"lastName"
control
=
{
control
}
rules
=
{
{
validate
:
(
value
:
string
)
=>
/^
[
A-Za-z
]
$/
.
test
(
value
),
required
:
{
value
:
true
,
message
:
'
lastName is not valid
'
,
},
}
}
label
=
"Last name"
error
=
{
!!
errors
.
user
?.
lastName
}
errorMessage
=
"Insert lastName"
/>
<
InputField
name
=
"phoneNumber"
control
=
{
control
}
rules
=
{
{
required
:
{
value
:
true
,
message
:
'
phoneNumber is not valid
'
,
},
}
}
label
=
"Phone number"
error
=
{
!!
errors
.
phoneNumber
}
errorMessage
=
"Insert phoneNumber"
/>
<
InputField
name
=
"memberCardIssuer"
control
=
{
control
}
rules
=
{
{
validate
:
(
value
:
string
)
=>
/^
[
A-Za-z
]
$/
.
test
(
value
),
required
:
{
value
:
true
,
message
:
'
memberCardIssuer is not valid
'
,
},
}
}
label
=
"Member card issuer"
error
=
{
!!
errors
.
memberCardIssuer
?.
name
}
errorMessage
=
"Insert memberCardIssuer"
/>
<
InputField
name
=
"memberCardNumber"
control
=
{
control
}
rules
=
{
{
required
:
{
value
:
true
,
message
:
'
memberCardNumber is not valid
'
,
},
}
}
label
=
"Card number"
error
=
{
!!
errors
.
memberCardNumber
}
errorMessage
=
"Insert memberCardNumber"
/>
<
InputField
name
=
"address"
control
=
{
control
}
rules
=
{
{
validate
:
(
value
:
string
)
=>
/^
[
A-Za-z
]
$/
.
test
(
value
),
required
:
{
value
:
true
,
message
:
'
address is not valid
'
,
},
}
}
label
=
"Home address"
error
=
{
!!
errors
.
homeAddress
?.
address
}
errorMessage
=
"Insert address"
/>
<
InputField
name
=
"notes"
control
=
{
control
}
label
=
"Notes"
error
=
{
!!
errors
.
notes
}
errorMessage
=
"Insert valid password"
/>
<
InputField
<
InputField
name
=
"email"
name
=
"email"
control
=
{
control
}
control
=
{
control
}
...
@@ -161,7 +77,7 @@ export const SignUpForm: FC = () => {
...
@@ -161,7 +77,7 @@ export const SignUpForm: FC = () => {
},
},
}
}
}
}
label
=
"Email"
label
=
"Email"
error
=
{
!!
errors
.
user
?.
email
}
error
=
{
!!
errors
.
email
}
errorMessage
=
"Insert email"
errorMessage
=
"Insert email"
/>
/>
...
@@ -177,10 +93,9 @@ export const SignUpForm: FC = () => {
...
@@ -177,10 +93,9 @@ export const SignUpForm: FC = () => {
},
},
}
}
}
}
label
=
"Password"
label
=
"Password"
error
=
{
!!
errors
.
user
?.
password
}
error
=
{
!!
errors
.
password
}
errorMessage
=
"Insert valid password"
errorMessage
=
"Insert valid password"
/>
/>
<
Button
<
Button
data-testid
=
"Submit"
data-testid
=
"Submit"
type
=
"submit"
type
=
"submit"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment