diff --git a/frontend/src/contexts/featureContext.ts b/frontend/src/contexts/featureContext.ts index 0fd76a4e800c9e5483994834b9ad0a06cb9717f9..238f2bc3a99393edc4e6d7f4a113d4caba9bc6ab 100644 --- a/frontend/src/contexts/featureContext.ts +++ b/frontend/src/contexts/featureContext.ts @@ -5,11 +5,14 @@ export interface IFeatureContext { displayContactAtUnit: boolean // Controls whether the optional field is shown in the register new guest wizard displayComment: boolean + // Should the contact at unit field be shown for the guest when he registers his information? + displayContactAtUnitGuestInput: boolean } export const FeatureContext = createContext<IFeatureContext>({ displayContactAtUnit: true, displayComment: true, + displayContactAtUnitGuestInput: true, }) export const useFeatureContext = () => useContext(FeatureContext) diff --git a/frontend/src/providers/featureProvider.tsx b/frontend/src/providers/featureProvider.tsx index 962e46aa14d866dd640a5ded31bce38c039753c0..6f5e724225ed67e2ced996aa9c7865d7f9db33a6 100644 --- a/frontend/src/providers/featureProvider.tsx +++ b/frontend/src/providers/featureProvider.tsx @@ -13,12 +13,20 @@ function FeatureProvider(props: FeatureProviderProps) { let features: IFeatureContext switch (appInst) { case 'uib': - features = { displayContactAtUnit: false, displayComment: false } + features = { + displayContactAtUnit: false, + displayComment: false, + displayContactAtUnitGuestInput: false, + } break case 'uio': default: - features = { displayContactAtUnit: true, displayComment: true } + features = { + displayContactAtUnit: true, + displayComment: true, + displayContactAtUnitGuestInput: true, + } break } diff --git a/frontend/src/routes/guest/register/guestDataForm.ts b/frontend/src/routes/guest/register/guestDataForm.ts index c1d35dcd19de659ccc018a0166797cf18119ffa4..5c86b6000fccd05c06dd091b5198ef23c3a99c6a 100644 --- a/frontend/src/routes/guest/register/guestDataForm.ts +++ b/frontend/src/routes/guest/register/guestDataForm.ts @@ -14,7 +14,7 @@ export type GuestInviteInformation = { role_name_nb: string role_start: string role_end: string - comment?: string + contact_person_unit?: string feide_id?: string email?: string diff --git a/frontend/src/routes/guest/register/index.tsx b/frontend/src/routes/guest/register/index.tsx index c595bac7361717600f2670694d96eec2852f3782..79b614d52f58020658f07caa37aa69d54b6d89b6 100644 --- a/frontend/src/routes/guest/register/index.tsx +++ b/frontend/src/routes/guest/register/index.tsx @@ -56,7 +56,7 @@ type InvitationData = { role_name_en: string start: string end: string - comments: string + contact_person_unit: string } meta: { session_type: string @@ -149,7 +149,7 @@ export default function GuestRegister() { role_name_nb: data.role.role_name_nb ?? '', role_start: data.role.start ?? '', role_end: data.role.end ?? '', - comment: data.role.comments ?? '', + contact_person_unit: data.role.contact_person_unit ?? '', authentication_method: authenticationMethod, }) diff --git a/frontend/src/routes/guest/register/steps/register.tsx b/frontend/src/routes/guest/register/steps/register.tsx index 9cc70c712169fe2e812b4b3caaef7856ede06bfb..3b4fbb35a67232f2947783647d2a59c6f2b8225f 100644 --- a/frontend/src/routes/guest/register/steps/register.tsx +++ b/frontend/src/routes/guest/register/steps/register.tsx @@ -11,6 +11,7 @@ import { SubmitHandler, Controller, useForm } from 'react-hook-form' import React, { forwardRef, Ref, + useContext, useEffect, useImperativeHandle, useState, @@ -30,9 +31,11 @@ import { GuestInviteInformation } from '../guestDataForm' import { GuestRegisterData } from '../enteredGuestData' import { GuestRegisterCallableMethods } from '../guestRegisterCallableMethods' import AuthenticationMethod from '../authenticationMethod' +import { FeatureContext } from '../../../../contexts' interface GuestRegisterProperties { nextHandler(registerData: GuestRegisterData): void + initialGuestData: GuestInviteInformation registerData: GuestRegisterData | null } @@ -57,6 +60,7 @@ const GuestRegisterStep = forwardRef( string | undefined >(undefined) const [idErrorState, setIdErrorState] = useState<string>('') + const { displayContactAtUnitGuestInput } = useContext(FeatureContext) console.log('register step registerData', registerData) @@ -528,14 +532,14 @@ const GuestRegisterStep = forwardRef( disabled /> - <TextField - id="comment" - label={t('input.comment')} - multiline - rows={5} - value={initialGuestData.comment} - disabled - /> + {displayContactAtUnitGuestInput && ( + <TextField + id="contactPersonUnit" + label={t('input.contactPersonUnit')} + value={initialGuestData.contact_person_unit} + disabled + /> + )} </Stack> </form> </Box> diff --git a/gregui/api/views/invitation.py b/gregui/api/views/invitation.py index 34b6d4fa79bc078e488b1f6e5b70f176761b6da6..f629d427505236e969a34b8c3fb5bcc1e536e24e 100644 --- a/gregui/api/views/invitation.py +++ b/gregui/api/views/invitation.py @@ -235,7 +235,7 @@ class InvitedGuestView(GenericAPIView): "role_name_en": role.type.name_en, "start": role.start_date, "end": role.end_date, - "comments": role.comments, + "contact_person_unit": role.contact_person_unit, }, "meta": {"session_type": session_type}, } diff --git a/gregui/tests/api/views/test_invitation.py b/gregui/tests/api/views/test_invitation.py index 0fb8e4564adfae9e04d43e30b8b8beed83b8dfd0..3fe44484be40671ca3ea00f56dcc4b65eff84c37 100644 --- a/gregui/tests/api/views/test_invitation.py +++ b/gregui/tests/api/views/test_invitation.py @@ -101,7 +101,7 @@ def test_get_invited_info_session_okay( assert data.get("role") == dict( start=None, end="2050-10-15", - comments="", + contact_person_unit="", ou_name_en=unit_foo.name_en, ou_name_nb=unit_foo.name_nb, role_name_en=role_type_foo.name_en,