Skip to content
Snippets Groups Projects
Commit b4c99f6a authored by Tore.Brede's avatar Tore.Brede
Browse files

Fixing linting errors

parent 3d10512c
No related branches found
No related tags found
1 merge request!113GREG-85: Guest registration page
Pipeline #97486 failed
...@@ -6,7 +6,6 @@ import { useHistory } from 'react-router-dom' ...@@ -6,7 +6,6 @@ import { useHistory } from 'react-router-dom'
import ArrowBackIcon from '@mui/icons-material/ArrowBack' import ArrowBackIcon from '@mui/icons-material/ArrowBack'
import ArrowForwardIcon from '@mui/icons-material/ArrowForward' import ArrowForwardIcon from '@mui/icons-material/ArrowForward'
export default function OverviewGuestButton() { export default function OverviewGuestButton() {
const { t } = useTranslation(['common']) const { t } = useTranslation(['common'])
const history = useHistory() const history = useHistory()
...@@ -16,34 +15,43 @@ export default function OverviewGuestButton() { ...@@ -16,34 +15,43 @@ export default function OverviewGuestButton() {
} }
return ( return (
<Box sx={{ display: 'flex', flexDirection: 'row', alignItems: 'baseline', justifyContent: 'space-evenly' }}> <Box
sx={{
{/*TODO Where should the back arrow point to?*/} display: 'flex',
<ArrowBackIcon> flexDirection: 'row',
alignItems: 'baseline',
</ArrowBackIcon> justifyContent: 'space-evenly',
}}
<Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}> >
{/* TODO Where should the back arrow point to? */}
<ArrowBackIcon />
<Box
sx={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}
>
<IconButton onClick={goToGuestOverview}> <IconButton onClick={goToGuestOverview}>
<PersonIcon <PersonIcon
fontSize='large' fontSize="large"
sx={{ sx={{
borderRadius: '2rem', borderRadius: '2rem',
borderStyle: 'solid', borderStyle: 'solid',
borderColor: 'primary.main', borderColor: 'primary.main',
fill: 'white', fill: 'white',
backgroundColor: 'primary.main', backgroundColor: 'primary.main',
}} /> }}
/>
</IconButton> </IconButton>
<Box sx={{ <Box
typography: 'caption', sx={{
}}> typography: 'caption',
}}
>
{t('yourGuestAccount')} {t('yourGuestAccount')}
</Box> </Box>
</Box> </Box>
<IconButton disabled> <IconButton disabled>
<ArrowForwardIcon visibility='hidden' /> <ArrowForwardIcon visibility="hidden" />
</IconButton> </IconButton>
</Box> </Box>
) )
......
...@@ -25,12 +25,15 @@ enum SubmitState { ...@@ -25,12 +25,15 @@ enum SubmitState {
export default function GuestRegister() { export default function GuestRegister() {
const { t } = useTranslation(['common']) const { t } = useTranslation(['common'])
const history = useHistory() const history = useHistory()
const [errorState, setErrorState] = useState<string | null>(null) // TODO On submit successful the user should be directed to some page telling h
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [submitState, setSubmitState] = useState<SubmitState>( const [submitState, setSubmitState] = useState<SubmitState>(
SubmitState.NotSubmitted SubmitState.NotSubmitted
) )
const guestRegisterRef = useRef<GuestRegisterCallableMethods>(null) const guestRegisterRef = useRef<GuestRegisterCallableMethods>(null)
const REGISTER_STEP = 0 const REGISTER_STEP = 0
// TODO Set step when user moves between pages
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [activeStep, setActiveStep] = useState(0) const [activeStep, setActiveStep] = useState(0)
const [guestFormData, setGuestFormData] = const [guestFormData, setGuestFormData] =
...@@ -57,14 +60,8 @@ export default function GuestRegister() { ...@@ -57,14 +60,8 @@ export default function GuestRegister() {
if (response.ok) { if (response.ok) {
response.json().then((jsonResponse) => { response.json().then((jsonResponse) => {
const userInformationSource = // TODO Set up so that information about the authentication method is included in the response from the server (if the user is logged in by Feide)
jsonResponse.meta.user_information_source const userSource = AuthenticationMethod.NationalIdNumberOrPassport
// TODO Set up so that information about the authentication method is included in the reponse from the server (if the user is logged in by Feide)
const userSource =
userInformationSource === 'feide'
? AuthenticationMethod.Feide
: AuthenticationMethod.NationalIdNumberOrPassport
setGuestFormData({ setGuestFormData({
first_name: jsonResponse.person.first_name, first_name: jsonResponse.person.first_name,
...@@ -173,7 +170,7 @@ export default function GuestRegister() { ...@@ -173,7 +170,7 @@ export default function GuestRegister() {
<Button onClick={handleCancel}>{t('button.cancel')}</Button> <Button onClick={handleCancel}>{t('button.cancel')}</Button>
{/*TODO This button is only for testing while developing*/} {/* TODO This button is only for testing while developing */}
<Button onClick={handleSave}>{t('button.save')}</Button> <Button onClick={handleSave}>{t('button.save')}</Button>
</Box> </Box>
</Page> </Page>
......
...@@ -7,7 +7,9 @@ import { EnteredGuestData } from './enteredGuestData' ...@@ -7,7 +7,9 @@ import { EnteredGuestData } from './enteredGuestData'
import AuthenticationMethod from './authenticationMethod' import AuthenticationMethod from './authenticationMethod'
test('Guest register page showing passport field on manual registration', async () => { test('Guest register page showing passport field on manual registration', async () => {
const nextHandler = (enteredGuestData: EnteredGuestData) => {} const nextHandler = (enteredGuestData: EnteredGuestData) => {
console.log(`Entered data: ${enteredGuestData}`)
}
const guestData = { const guestData = {
first_name: '', first_name: '',
last_name: '', last_name: '',
......
...@@ -15,13 +15,12 @@ import { ...@@ -15,13 +15,12 @@ import {
getCountries, getCountries,
getCountryCallingCode, getCountryCallingCode,
} from 'libphonenumber-js' } from 'libphonenumber-js'
import { ContactInformationBySponsor } from './guestDataForm'
import { getName } from 'i18n-iso-countries' import { getName } from 'i18n-iso-countries'
import { ContactInformationBySponsor } from './guestDataForm'
import { EnteredGuestData } from './enteredGuestData' import { EnteredGuestData } from './enteredGuestData'
import { GuestRegisterCallableMethods } from './guestRegisterCallableMethods' import { GuestRegisterCallableMethods } from './guestRegisterCallableMethods'
import { isValidFnr, isValidMobilePhoneNumber } from '../../../utils' import { isValidFnr, isValidMobilePhoneNumber } from '../../../utils'
import AuthenticationMethod from './authenticationMethod' import AuthenticationMethod from './authenticationMethod'
import { CountryCallingCodes } from 'libphonenumber-js/types'
interface GuestRegisterProperties { interface GuestRegisterProperties {
nextHandler(guestData: EnteredGuestData): void nextHandler(guestData: EnteredGuestData): void
...@@ -45,9 +44,9 @@ const GuestRegisterStep = forwardRef( ...@@ -45,9 +44,9 @@ const GuestRegisterStep = forwardRef(
const handleCountryCodeChange = (event: SelectChangeEvent) => { const handleCountryCodeChange = (event: SelectChangeEvent) => {
if (event.target.value) { if (event.target.value) {
const countryCodeType = getCountries().find((value) => { const countryCodeType = getCountries().find(
return value.toString() === event.target.value (value) => value.toString() === event.target.value
}) )
if (countryCodeType) { if (countryCodeType) {
setCountryCode(getCountryCallingCode(countryCodeType)) setCountryCode(getCountryCallingCode(countryCodeType))
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment