From 3eca273ec18ebd4476b6a8ee6aa24f8467e66f5d Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Fri, 6 Dec 2024 12:43:28 -0600 Subject: [PATCH] Merge features from main to apcd feature branch (#393) * Merge features from main to apcd feature branch * Fix id field --------- Co-authored-by: Garrett Edmonds <43251554+edmondsgarrett@users.noreply.github.com> --- apcd_cms/src/apps/admin_regis_table/views.py | 2 +- apcd_cms/src/apps/utils/apcd_database.py | 2 ++ apcd_cms/src/apps/view_users/views.py | 4 ++- .../Forms/Registrations/RegistrationForm.tsx | 30 +++++++++++++++++-- .../EditRegistrationModal.tsx | 6 +++- .../RegistrationList/RegistrationList.tsx | 3 +- .../client/src/hooks/registrations/index.ts | 2 ++ .../client/src/hooks/registrations/useForm.ts | 1 + 8 files changed, 43 insertions(+), 7 deletions(-) diff --git a/apcd_cms/src/apps/admin_regis_table/views.py b/apcd_cms/src/apps/admin_regis_table/views.py index 65784685..820d4236 100644 --- a/apcd_cms/src/apps/admin_regis_table/views.py +++ b/apcd_cms/src/apps/admin_regis_table/views.py @@ -119,7 +119,7 @@ def get_registration_list_json(self, registrations_content, *args, **kwargs): context = {} context['header'] = ['Business Name', 'Year', 'Type', 'Location', 'Registration Status', 'Actions'] - context['status_options'] = ['All', 'Received', 'Processing', 'Complete'] + context['status_options'] = ['All', 'Received', 'Processing', 'Complete', 'Withdrawn'] context['org_options'] = ['All'] try: diff --git a/apcd_cms/src/apps/utils/apcd_database.py b/apcd_cms/src/apps/utils/apcd_database.py index 924a3532..4a8865fc 100644 --- a/apcd_cms/src/apps/utils/apcd_database.py +++ b/apcd_cms/src/apps/utils/apcd_database.py @@ -268,6 +268,7 @@ def update_registration(form, reg_id): operation = """UPDATE registrations SET submitting_for_self = %s, + registration_status = %s, org_type = %s, business_name = %s, mail_address = %s, @@ -280,6 +281,7 @@ def update_registration(form, reg_id): RETURNING registration_id""" values = ( True if form['on_behalf_of'] == 'true' else False, + form['reg_status'], form['type'], _clean_value(form['business_name']), _clean_value(form['mailing_address']), diff --git a/apcd_cms/src/apps/view_users/views.py b/apcd_cms/src/apps/view_users/views.py index 1837ca66..9ed5c855 100644 --- a/apcd_cms/src/apps/view_users/views.py +++ b/apcd_cms/src/apps/view_users/views.py @@ -115,6 +115,7 @@ def _set_user(usr): 'status': 'Active' if usr[8] else 'Inactive', 'user_number': usr[9], 'role_name': usr[10], + 'entity_name_no_parens': usr[4].replace("(", "").replace(")", "") if usr[4] else "None", # just for filtering purposes } user_list = [_set_user(user) for user in users] @@ -123,7 +124,8 @@ def _set_user(usr): user_list = [user for user in user_list if user['status'] == status] if org != 'All': - user_list = [user for user in user_list if user['entity_name'] == org] + org_no_parens = org.replace("(", "").replace(")", "") + user_list = [user for user in user_list if user['entity_name_no_parens'] == org_no_parens] return user_list 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 d097709a..e9a6b47d 100644 --- a/apcd_cms/src/client/src/components/Forms/Registrations/RegistrationForm.tsx +++ b/apcd_cms/src/client/src/components/Forms/Registrations/RegistrationForm.tsx @@ -53,15 +53,15 @@ const validationSchema = Yup.object().shape({ types_of_files_dental: Yup.boolean(), total_covered_lives: Yup.number() .typeError('Must be an integer') - .positive() + .min(0) .required('Total covered lives is required'), claims_encounters_volume: Yup.number() .typeError('Must be an integer') - .positive() + .min(0) .required('Claims and Encounters volume is required'), total_claims_value: Yup.number() .typeError('Must be a number') - .positive() + .min(0) .required('Total Claims Value is required') .test( 'maxDigitsAfterDecimal', @@ -187,11 +187,13 @@ export const RegistrationForm: React.FC<{ isEdit?: boolean; inputValues?: RegistrationFormValues; isModal?: boolean; + status_options?: string[]; onSuccessCallback?: () => void; }> = ({ isEdit = false, inputValues, isModal = false, + status_options = [], onSuccessCallback = () => {}, }) => { const [searchParams] = useSearchParams(); @@ -303,6 +305,28 @@ export const RegistrationForm: React.FC<{ ) : (

Organization

+ {status_options.length > 0 ? ( + + + {status_options.map((item, index) => ( + + ))} + + + ) : ( + <> + )} void; -}> = ({ reg_id, isVisible, onClose }) => { +}> = ({ reg_id, isVisible, status_options, onClose }) => { const { data, isLoading, error } = useAdminRegistration(reg_id); if (isLoading) return
Loading...
; @@ -40,6 +41,9 @@ const EditRegistrationModal: React.FC<{ isEdit={true} inputValues={form_values} isModal={true} + status_options={status_options.filter( + (option) => option !== 'All' && option !== 'None' + )} onSuccessCallback={onClose} /> diff --git a/apcd_cms/src/client/src/components/Registrations/RegistrationList/RegistrationList.tsx b/apcd_cms/src/client/src/components/Registrations/RegistrationList/RegistrationList.tsx index ac44c596..8ce5f399 100644 --- a/apcd_cms/src/client/src/components/Registrations/RegistrationList/RegistrationList.tsx +++ b/apcd_cms/src/client/src/components/Registrations/RegistrationList/RegistrationList.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { RegistrationResult, RegistrationRow } from 'hooks/registrations'; +import { RegistrationRow } from 'hooks/registrations'; import LoadingSpinner from 'core-components/LoadingSpinner'; import Paginator from 'core-components/Paginator'; import ViewRegistrationModal from 'apcd-components/Registrations/ViewRegistrationModal/ViewRegistrationModal'; @@ -182,6 +182,7 @@ export const RegistrationList: React.FC<{ setIsEditModalOpen(false)} /> diff --git a/apcd_cms/src/client/src/hooks/registrations/index.ts b/apcd_cms/src/client/src/hooks/registrations/index.ts index 387101d5..1d8d1237 100644 --- a/apcd_cms/src/client/src/hooks/registrations/index.ts +++ b/apcd_cms/src/client/src/hooks/registrations/index.ts @@ -80,6 +80,7 @@ export type RegistrationFormValues = { state: string; zip_code: string; reg_id?: number; + reg_status?: string; entities: { entity_name: string; fein: string; @@ -130,6 +131,7 @@ export function transformToRegistrationFormValues( state: registration.state as string, zip_code: registration.zip.toString(), reg_id: registration.reg_id, + reg_status: registration.status, entities: registration.entities.map((entity) => ({ entity_name: entity.ent_name, fein: entity.fein ?? '', diff --git a/apcd_cms/src/client/src/hooks/registrations/useForm.ts b/apcd_cms/src/client/src/hooks/registrations/useForm.ts index 187f6e55..ef915b5c 100644 --- a/apcd_cms/src/client/src/hooks/registrations/useForm.ts +++ b/apcd_cms/src/client/src/hooks/registrations/useForm.ts @@ -51,6 +51,7 @@ export function usePostRegistration() { }, onSuccess: () => { const keysToInvalidate = [ + 'admin-registration', 'admin-registrations', 'submitter-registrations', ];