Skip to content

Commit

Permalink
Merge features from main to apcd feature branch (#393)
Browse files Browse the repository at this point in the history
* Merge features from main to apcd feature branch

* Fix id field

---------

Co-authored-by: Garrett Edmonds <[email protected]>
  • Loading branch information
chandra-tacc and edmondsgarrett authored Dec 6, 2024
1 parent 27eccc2 commit 3eca273
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apcd_cms/src/apps/admin_regis_table/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions apcd_cms/src/apps/utils/apcd_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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']),
Expand Down
4 changes: 3 additions & 1 deletion apcd_cms/src/apps/view_users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -303,6 +305,28 @@ export const RegistrationForm: React.FC<{
) : (
<Form>
<h4>Organization</h4>
{status_options.length > 0 ? (
<FieldWrapper
name="reg_status"
label="Registration Status"
required={true}
>
<Field
as="select"
name="reg_status"
id="reg_status"
className="choicefield"
>
{status_options.map((item, index) => (
<option key={index} value={item}>
{item}
</option>
))}
</Field>
</FieldWrapper>
) : (
<></>
)}
<FieldWrapper
name="on_behalf_of"
label="On behalf of:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { RegistrationForm } from 'apcd-components/Forms/Registrations';
const EditRegistrationModal: React.FC<{
reg_id: number;
isVisible: boolean;
status_options: string[];
onClose: () => void;
}> = ({ reg_id, isVisible, onClose }) => {
}> = ({ reg_id, isVisible, status_options, onClose }) => {
const { data, isLoading, error } = useAdminRegistration(reg_id);

if (isLoading) return <div>Loading...</div>;
Expand Down Expand Up @@ -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}
/>
</ModalBody>
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -182,6 +182,7 @@ export const RegistrationList: React.FC<{
<EditRegistrationModal
reg_id={selectedRegistration.reg_id}
isVisible={isEditModalOpen}
status_options={data?.status_options as string[]}
onClose={() => setIsEditModalOpen(false)}
/>
</>
Expand Down
2 changes: 2 additions & 0 deletions apcd_cms/src/client/src/hooks/registrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export type RegistrationFormValues = {
state: string;
zip_code: string;
reg_id?: number;
reg_status?: string;
entities: {
entity_name: string;
fein: string;
Expand Down Expand Up @@ -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 ?? '',
Expand Down
1 change: 1 addition & 0 deletions apcd_cms/src/client/src/hooks/registrations/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function usePostRegistration() {
},
onSuccess: () => {
const keysToInvalidate = [
'admin-registration',
'admin-registrations',
'submitter-registrations',
];
Expand Down

0 comments on commit 3eca273

Please sign in to comment.