Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
50275205
Verified
Commit
50275205
authored
3 years ago
by
Andreas Ellewsen
Browse files
Options
Downloads
Patches
Plain Diff
Add label to email field
parent
44f7d800
No related branches found
Branches containing commit
No related tags found
1 merge request
!181
Add label to email field
Pipeline
#101640
passed
3 years ago
Stage: venv update
Stage: tests and linting
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/routes/sponsor/guest/guestInfo/index.tsx
+26
-10
26 additions, 10 deletions
frontend/src/routes/sponsor/guest/guestInfo/index.tsx
with
26 additions
and
10 deletions
frontend/src/routes/sponsor/guest/guestInfo/index.tsx
+
26
−
10
View file @
50275205
...
@@ -22,7 +22,7 @@ import {
...
@@ -22,7 +22,7 @@ import {
import
{
Guest
}
from
'
interfaces
'
import
{
Guest
}
from
'
interfaces
'
import
SponsorInfoButtons
from
'
routes/components/sponsorInfoButtons
'
import
SponsorInfoButtons
from
'
routes/components/sponsorInfoButtons
'
import
{
useEffect
,
useState
}
from
'
react
'
import
{
useEffect
,
useState
}
from
'
react
'
import
{
SubmitHandler
,
useForm
}
from
'
react-hook-form
'
import
{
SubmitHandler
,
useForm
,
Controller
}
from
'
react-hook-form
'
import
IdentityLine
from
'
components/identityLine
'
import
IdentityLine
from
'
components/identityLine
'
import
{
isValidEmail
,
submitJsonOpts
}
from
'
utils
'
import
{
isValidEmail
,
submitJsonOpts
}
from
'
utils
'
...
@@ -93,13 +93,19 @@ export default function GuestInfo({
...
@@ -93,13 +93,19 @@ export default function GuestInfo({
const
[
confirmationDialogOpen
,
setConfirmationDialogOpen
]
=
useState
(
false
)
const
[
confirmationDialogOpen
,
setConfirmationDialogOpen
]
=
useState
(
false
)
const
[
emailDirty
,
setEmailDirty
]
=
useState
(
false
)
const
[
emailDirty
,
setEmailDirty
]
=
useState
(
false
)
const
defaultValues
=
{
email
:
guest
.
email
,
}
// Using useForm even though only the e-mail is allow to change at present, since useForm makes setup and validation easier
// Using useForm even though only the e-mail is allow to change at present, since useForm makes setup and validation easier
const
{
const
{
register
,
handleSubmit
,
handleSubmit
,
setValue
,
setValue
,
control
,
formState
:
{
errors
},
formState
:
{
errors
},
}
=
useForm
<
Email
>
({
mode
:
'
onChange
'
})
}
=
useForm
({
mode
:
'
onChange
'
,
defaultValues
,
})
useEffect
(()
=>
{
useEffect
(()
=>
{
setValue
(
'
email
'
,
guest
.
email
)
setValue
(
'
email
'
,
guest
.
email
)
...
@@ -150,6 +156,7 @@ export default function GuestInfo({
...
@@ -150,6 +156,7 @@ export default function GuestInfo({
}
}
const
emailFieldChange
=
(
event
:
any
)
=>
{
const
emailFieldChange
=
(
event
:
any
)
=>
{
setValue
(
'
email
'
,
event
.
target
.
value
)
if
(
event
.
target
.
value
!==
guest
.
email
)
{
if
(
event
.
target
.
value
!==
guest
.
email
)
{
setEmailDirty
(
true
)
setEmailDirty
(
true
)
}
else
{
}
else
{
...
@@ -188,14 +195,23 @@ export default function GuestInfo({
...
@@ -188,14 +195,23 @@ export default function GuestInfo({
justifyContent
:
'
flex-start
'
,
justifyContent
:
'
flex-start
'
,
}
}
}
}
>
>
<
TextField
<
Controller
id
=
"email"
name
=
"email"
error
=
{
!!
errors
.
email
}
control
=
{
control
}
helperText
=
{
errors
.
email
&&
errors
.
email
.
message
}
rules
=
{
{
{
...
register
(
`email`
,
{
validate
:
isValidEmail
,
validate
:
isValidEmail
,
})
}
}
}
onChange
=
{
emailFieldChange
}
render
=
{
({
field
:
{
value
},
...
rest
})
=>
(
<
TextField
id
=
"email"
label
=
{
t
(
'
input.email
'
)
}
error
=
{
!!
errors
.
email
}
helperText
=
{
errors
.
email
&&
errors
.
email
.
message
}
value
=
{
value
}
{
...
rest
}
onChange
=
{
emailFieldChange
}
/>
)
}
/>
/>
{
/* If the guest has not completed the registration process, he should have an invitation he has not responded to */
}
{
/* If the guest has not completed the registration process, he should have an invitation he has not responded to */
}
...
...
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