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
2a66ae87
Commit
2a66ae87
authored
3 years ago
by
Tore.Brede
Browse files
Options
Downloads
Patches
Plain Diff
GREG-113: Better handling of data from server. Handling date of birth
parent
420564e7
No related branches found
No related tags found
1 merge request
!166
GREG-113 guest date of birth
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/routes/guest/register/index.tsx
+30
-4
30 additions, 4 deletions
frontend/src/routes/guest/register/index.tsx
with
30 additions
and
4 deletions
frontend/src/routes/guest/register/index.tsx
+
30
−
4
View file @
2a66ae87
...
...
@@ -10,6 +10,7 @@ import {
getCountries
,
getCountryCallingCode
,
}
from
'
libphonenumber-js
'
import
format
from
'
date-fns/format
'
import
OverviewGuestButton
from
'
../../components/overviewGuestButton
'
import
GuestRegisterStep
from
'
./registerPage
'
import
{
GuestRegisterCallableMethods
}
from
'
./guestRegisterCallableMethods
'
...
...
@@ -62,6 +63,7 @@ export default function GuestRegister() {
passport
:
''
,
passportNationality
:
''
,
countryForCallingCode
:
''
,
dateOfBirth
:
undefined
,
authentication_method
:
AuthenticationMethod
.
Invite
,
})
...
...
@@ -91,7 +93,25 @@ export default function GuestRegister() {
}
}
let
passportNumber
=
''
let
passportCountry
=
''
if
(
jsonResponse
.
person
.
passport
)
{
const
index
=
jsonResponse
.
person
.
passport
.
indexOf
(
'
-
'
)
if
(
index
!==
-
1
)
{
passportCountry
=
jsonResponse
.
person
.
passport
.
substring
(
0
,
index
)
passportNumber
=
jsonResponse
.
person
.
passport
.
substring
(
index
+
1
,
jsonResponse
.
person
.
passport
.
length
)
}
}
setGuestFormData
({
fnr
:
jsonResponse
.
person
.
fnr
,
passportNationality
:
passportCountry
,
passport
:
passportNumber
,
first_name
:
jsonResponse
.
person
.
first_name
,
last_name
:
jsonResponse
.
person
.
last_name
,
ou_name_en
:
jsonResponse
.
role
.
ou_name_en
,
...
...
@@ -106,12 +126,10 @@ export default function GuestRegister() {
feide_id
:
jsonResponse
.
person
.
feide_id
,
mobile_phone_country_code
:
countryCode
,
mobile_phone
:
nationalNumber
,
fnr
:
jsonResponse
.
fnr
,
passport
:
jsonResponse
.
passport
,
// TODO Separate out nationality based on what is in the server response
passportNationality
:
''
,
countryForCallingCode
:
extractedCountryCode
,
dateOfBirth
:
jsonResponse
.
person
.
date_of_birth
,
authentication_method
:
authenticationMethod
,
})
})
...
...
@@ -143,6 +161,7 @@ export default function GuestRegister() {
):
void
=>
{
// TODO Should go to consent page here, if there are consents defined in the database. Submit should happen after after consent page
// Only add fields to the objects that the user can change (this is also checked on the server side)
const
payload
:
any
=
{}
payload
.
person
=
{}
payload
.
person
.
mobile_phone
=
`+
${
getCountryCallingCode
(
...
...
@@ -164,6 +183,13 @@ export default function GuestRegister() {
payload
.
person
.
fnr
=
updateFormData
.
nationalIdNumber
}
if
(
updateFormData
.
dateOfBirth
)
{
payload
.
person
.
date_of_birth
=
format
(
updateFormData
.
dateOfBirth
as
Date
,
'
yyyy-MM-dd
'
)
}
fetch
(
'
/api/ui/v1/invited/
'
,
submitJsonOpts
(
'
POST
'
,
payload
))
.
then
((
response
)
=>
{
if
(
response
.
ok
)
{
...
...
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