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
d2030a63
Commit
d2030a63
authored
3 years ago
by
Jonas Braathen
Browse files
Options
Downloads
Patches
Plain Diff
Make consent step configurable. Workaround state changes being async.
parent
c851b780
No related branches found
No related tags found
1 merge request
!173
Consents
Pipeline
#101456
passed
3 years ago
Stage: venv update
Stage: tests and linting
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
frontend/.env
+2
-0
2 additions, 0 deletions
frontend/.env
frontend/src/appConfig.ts
+4
-0
4 additions, 0 deletions
frontend/src/appConfig.ts
frontend/src/routes/guest/register/index.tsx
+22
-11
22 additions, 11 deletions
frontend/src/routes/guest/register/index.tsx
with
28 additions
and
11 deletions
frontend/.env
+
2
−
0
View file @
d2030a63
REACT_APP_VERSION=$npm_package_version
REACT_APP_VERSION=$npm_package_version
REACT_APP_NAME=$npm_package_name
REACT_APP_NAME=$npm_package_name
REACT_APP_GUEST_CONSENT_STEP_ENABLED=true
REACT_APP_SUPPORT_MAIL=test@example.org
REACT_APP_SUPPORT_MAIL=test@example.org
REACT_APP_INST=uio
REACT_APP_INST=uio
REACT_APP_SUPPORT_URL=https://example.org
REACT_APP_SUPPORT_URL=https://example.org
...
...
This diff is collapsed.
Click to expand it.
frontend/src/appConfig.ts
+
4
−
0
View file @
d2030a63
...
@@ -23,6 +23,10 @@ export const appInst: string = env.REACT_APP_INST as string
...
@@ -23,6 +23,10 @@ export const appInst: string = env.REACT_APP_INST as string
export
const
appStagingWarning
:
boolean
=
export
const
appStagingWarning
:
boolean
=
env
.
REACT_APP_STAGING_WARNING
===
'
true
'
env
.
REACT_APP_STAGING_WARNING
===
'
true
'
/* Is there a consent step during guest registration? */
export
const
guestConsentStepEnabled
:
boolean
=
env
.
REACT_APP_GUEST_CONSENT_STEP_ENABLED
===
'
true
'
/* Footer content */
/* Footer content */
export
const
appTechnicalSupportLink
:
string
=
export
const
appTechnicalSupportLink
:
string
=
env
.
REACT_APP_SUPPORT_URL
as
string
env
.
REACT_APP_SUPPORT_URL
as
string
...
...
This diff is collapsed.
Click to expand it.
frontend/src/routes/guest/register/index.tsx
+
22
−
11
View file @
d2030a63
import
React
,
{
Suspense
,
useEffect
,
useRef
,
useState
}
from
'
react
'
import
React
,
{
Suspense
,
useEffect
,
useRef
,
useState
}
from
'
react
'
import
{
useTranslation
}
from
'
react-i18next
'
import
{
useTranslation
}
from
'
react-i18next
'
import
{
Box
,
Button
,
CircularProgress
}
from
'
@mui/material
'
import
Page
from
'
components/page
'
import
{
useHistory
}
from
'
react-router-dom
'
import
{
useHistory
}
from
'
react-router-dom
'
import
{
import
{
CountryCode
,
CountryCode
,
...
@@ -12,7 +8,11 @@ import {
...
@@ -12,7 +8,11 @@ import {
}
from
'
libphonenumber-js
'
}
from
'
libphonenumber-js
'
import
format
from
'
date-fns/format
'
import
format
from
'
date-fns/format
'
import
parse
from
'
date-fns/parse
'
import
parse
from
'
date-fns/parse
'
import
{
Box
,
Button
,
CircularProgress
}
from
'
@mui/material
'
import
{
splitPhoneNumber
,
submitJsonOpts
,
fetchJsonOpts
}
from
'
utils
'
import
{
splitPhoneNumber
,
submitJsonOpts
,
fetchJsonOpts
}
from
'
utils
'
import
{
guestConsentStepEnabled
}
from
'
appConfig
'
import
Page
from
'
components/page
'
import
OverviewGuestButton
from
'
../../components/overviewGuestButton
'
import
OverviewGuestButton
from
'
../../components/overviewGuestButton
'
import
{
GuestRegisterCallableMethods
}
from
'
./guestRegisterCallableMethods
'
import
{
GuestRegisterCallableMethods
}
from
'
./guestRegisterCallableMethods
'
import
{
GuestRegisterData
,
GuestConsentData
}
from
'
./enteredGuestData
'
import
{
GuestRegisterData
,
GuestConsentData
}
from
'
./enteredGuestData
'
...
@@ -84,6 +84,7 @@ export default function GuestRegister() {
...
@@ -84,6 +84,7 @@ export default function GuestRegister() {
useState
<
GuestInviteInformation
|
null
>
(
null
)
useState
<
GuestInviteInformation
|
null
>
(
null
)
const
[
guestRegisterData
,
setGuestRegisterData
]
=
const
[
guestRegisterData
,
setGuestRegisterData
]
=
useState
<
GuestRegisterData
|
null
>
(
null
)
useState
<
GuestRegisterData
|
null
>
(
null
)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const
[
guestConsentData
,
setGuestConsentData
]
=
const
[
guestConsentData
,
setGuestConsentData
]
=
useState
<
GuestConsentData
|
null
>
(
null
)
useState
<
GuestConsentData
|
null
>
(
null
)
...
@@ -236,16 +237,22 @@ export default function GuestRegister() {
...
@@ -236,16 +237,22 @@ export default function GuestRegister() {
return
payload
return
payload
}
}
const
submitPayload
=
()
=>
{
const
submitPayload
=
(
if
(
!
guestRegisterData
)
{
registerData
:
GuestRegisterData
,
consentData
:
GuestConsentData
|
null
)
=>
{
if
(
!
registerData
)
{
setActiveStep
(
Step
.
RegisterStep
)
setActiveStep
(
Step
.
RegisterStep
)
return
return
}
}
if
(
!
guestConsentData
)
{
if
(
guestConsent
StepEnabled
&&
!
consent
Data
)
{
setActiveStep
(
Step
.
ConsentStep
)
setActiveStep
(
Step
.
ConsentStep
)
return
return
}
}
const
payload
:
any
=
makePayload
(
guestRegisterData
,
guestConsentData
)
const
consents
=
guestConsentStepEnabled
?
consentData
??
{
consents
:
[]
}
:
{
consents
:
[]
}
const
payload
:
any
=
makePayload
(
registerData
,
consents
)
console
.
log
(
'
submitting payload
'
,
payload
)
console
.
log
(
'
submitting payload
'
,
payload
)
fetch
(
'
/api/ui/v1/invited/
'
,
submitJsonOpts
(
'
POST
'
,
payload
))
fetch
(
'
/api/ui/v1/invited/
'
,
submitJsonOpts
(
'
POST
'
,
payload
))
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
...
@@ -266,21 +273,25 @@ export default function GuestRegister() {
...
@@ -266,21 +273,25 @@ export default function GuestRegister() {
const
handleForwardFromRegister
=
(
registerData
:
GuestRegisterData
):
void
=>
{
const
handleForwardFromRegister
=
(
registerData
:
GuestRegisterData
):
void
=>
{
console
.
log
(
'
handleForwardFromRegister
'
)
console
.
log
(
'
handleForwardFromRegister
'
)
setGuestRegisterData
(
registerData
)
setGuestRegisterData
(
registerData
)
if
(
!
guestConsentStepEnabled
)
{
submitPayload
(
registerData
,
null
)
return
}
setActiveStep
(
Step
.
ConsentStep
)
setActiveStep
(
Step
.
ConsentStep
)
}
}
const
handleForwardFromConsent
=
(
consentData
:
GuestConsentData
):
void
=>
{
const
handleForwardFromConsent
=
(
consentData
:
GuestConsentData
):
void
=>
{
console
.
log
(
'
handleForwardFromConsent
'
)
console
.
log
(
'
handleForwardFromConsent
consentData is
'
,
consentData
)
setGuestConsentData
(
consentData
)
setGuestConsentData
(
consentData
)
if
(
!
guestRegisterData
)
{
if
(
!
guestRegisterData
)
{
setActiveStep
(
Step
.
RegisterStep
)
setActiveStep
(
Step
.
RegisterStep
)
return
return
}
}
if
(
!
guestC
onsentData
)
{
if
(
!
c
onsentData
)
{
setActiveStep
(
Step
.
ConsentStep
)
setActiveStep
(
Step
.
ConsentStep
)
return
return
}
}
submitPayload
()
submitPayload
(
guestRegisterData
,
consentData
)
}
}
const
handleCancel
=
()
=>
{
const
handleCancel
=
()
=>
{
...
...
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