From 4d79059b7a13944d9e36880d14dbd951f2e8eec9 Mon Sep 17 00:00:00 2001 From: Krishnan Subramanian <84348052+krishnan-aot@users.noreply.github.com> Date: Thu, 4 Jan 2024 10:31:10 -0800 Subject: [PATCH] ORV2-1762 Financial report - pass userguid instead of username (#1027) --- .../forms/PaymentAndRefundDetail.tsx | 8 ++++-- .../forms/subcomponents/UserSelect.tsx | 26 +++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/frontend/src/features/idir/reporting/forms/PaymentAndRefundDetail.tsx b/frontend/src/features/idir/reporting/forms/PaymentAndRefundDetail.tsx index 62b903dd5..024042ba6 100644 --- a/frontend/src/features/idir/reporting/forms/PaymentAndRefundDetail.tsx +++ b/frontend/src/features/idir/reporting/forms/PaymentAndRefundDetail.tsx @@ -78,7 +78,9 @@ export const PaymentAndRefundDetail = () => { toDateTime: dayjs().set("h", 20).set("m", 59).set("s", 59).set("ms", 999), paymentMethods: Object.keys(CONSOLIDATED_PAYMENT_METHODS), permitType: Object.keys(permitTypes ?? []), - users: Object.keys(permitIssuers ?? {}), + // permitIssuers is a record. + // So, Object.values is what we need. + users: Object.values(permitIssuers ?? {}), }, reValidateMode: "onBlur", }); @@ -108,7 +110,9 @@ export const PaymentAndRefundDetail = () => { useEffect(() => { if (permitIssuers) { - setValue("users", Object.keys(permitIssuers)); + // permitIssuers is a record. + // So, Object.values is what we need. + setValue("users", Object.values(permitIssuers)); } }, [ispermitIssuersQueryLoading]); diff --git a/frontend/src/features/idir/reporting/forms/subcomponents/UserSelect.tsx b/frontend/src/features/idir/reporting/forms/subcomponents/UserSelect.tsx index 4f1a106a7..60edafb85 100644 --- a/frontend/src/features/idir/reporting/forms/subcomponents/UserSelect.tsx +++ b/frontend/src/features/idir/reporting/forms/subcomponents/UserSelect.tsx @@ -43,11 +43,13 @@ export const UserSelect = ({ permitIssuers }: UserSelectProps) => { target: { value }, } = event; if (permitIssuers) { - const userNames = Object.keys(permitIssuers); - const totalUsers = userNames.length; + // permitIssuers is a record. + // So, Object.values is what we need. + const userGUIDs = Object.values(permitIssuers); + const totalUsers = userGUIDs.length; let newState: string[]; if (value[value.length - 1] === "ALL") { - newState = selectedUsers?.length === totalUsers ? [] : userNames; + newState = selectedUsers?.length === totalUsers ? [] : userGUIDs; } else { newState = value as string[]; } @@ -93,14 +95,16 @@ export const UserSelect = ({ permitIssuers }: UserSelectProps) => { {permitIssuers - ? Object.keys(permitIssuers).map((key) => ( - - -1} - /> - - - )) + ? Object.entries(permitIssuers).map(([key, value]) => { + return ( + + -1} + /> + + + ); + }) : []}