diff --git a/apcd-cms/src/apps/registrations/views.py b/apcd-cms/src/apps/registrations/views.py index a614e052..74ab152c 100644 --- a/apcd-cms/src/apps/registrations/views.py +++ b/apcd-cms/src/apps/registrations/views.py @@ -25,7 +25,7 @@ class RegistrationFormView(TemplateView): def get(self, request): formatted_reg_data = [] renew = False - reg_id = request.GET.get('reg_id', None) + reg_id = request.GET.get('reg_id', None).rstrip('/') # reg_id coming from renew has trailing slash appended, need to remove to pass correct request through if reg_id and (has_groups(request.user, ['APCD_ADMIN', 'SUBMITTER_ADMIN'])): try: response = get_submitter_code(request.user) diff --git a/apcd-cms/src/client/src/components/Forms/Registrations/RegistrationForm.tsx b/apcd-cms/src/client/src/components/Forms/Registrations/RegistrationForm.tsx index 557cbe5a..7f4901ac 100644 --- a/apcd-cms/src/client/src/components/Forms/Registrations/RegistrationForm.tsx +++ b/apcd-cms/src/client/src/components/Forms/Registrations/RegistrationForm.tsx @@ -258,7 +258,7 @@ export const RegistrationForm: React.FC<{ validateOnMount={true} initialValues={ data - ? transformToRegistrationFormValues(data) + ? transformToRegistrationFormValues(data['registration_data'], data['renew']) : inputValues ?? initialValues } initialTouched={initialTouched} diff --git a/apcd-cms/src/client/src/hooks/registrations/index.ts b/apcd-cms/src/client/src/hooks/registrations/index.ts index 7c1f171a..69229c10 100644 --- a/apcd-cms/src/client/src/hooks/registrations/index.ts +++ b/apcd-cms/src/client/src/hooks/registrations/index.ts @@ -1,5 +1,5 @@ export type RegFormData = { - registration_data: RegistrationRow; + registration_data: RegistrationContent; renew: boolean; }; @@ -110,7 +110,7 @@ export type RegistrationFormValues = { }; export function transformToRegistrationFormValues( - registration: RegistrationContent + registration: RegistrationContent, renew?: boolean | undefined ): RegistrationFormValues { const typeValueMap:Record = { // to set database value for field rather than display value @@ -118,10 +118,9 @@ export function transformToRegistrationFormValues( 'Plan Administrator¹ (TPA/ASO)': 'tpa_aso', 'Pharmacy Benefit Manager (PBM)': 'pbm' } - return { on_behalf_of: registration.for_self?.toString() ?? '', - reg_year: registration.year.toString(), + reg_year: (registration.year + (renew ? 1 : 0)).toString(), type: registration.type ? typeValueMap[registration.type] : '', business_name: registration.biz_name, mailing_address: registration.address, diff --git a/apcd-cms/src/client/src/hooks/registrations/useForm.ts b/apcd-cms/src/client/src/hooks/registrations/useForm.ts index 3d7527c9..bbc653e9 100644 --- a/apcd-cms/src/client/src/hooks/registrations/useForm.ts +++ b/apcd-cms/src/client/src/hooks/registrations/useForm.ts @@ -17,10 +17,10 @@ const getRegFormData = async (reg_id: string | null) => { export const useRegFormData = ( reg_id: string | null -): UseQueryResult => { +): UseQueryResult => { const query = useQuery(['reg_form', reg_id], () => getRegFormData(reg_id), { enabled: !!reg_id, - }) as UseQueryResult; + }) as UseQueryResult; return { ...query }; };