Skip to content

Commit

Permalink
ORV2-1762 Financial report - pass userguid instead of username (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnan-aot authored Jan 4, 2024
1 parent db34d08 commit 4d79059
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <userName, userGUID> record.
// So, Object.values is what we need.
users: Object.values(permitIssuers ?? {}),
},
reValidateMode: "onBlur",
});
Expand Down Expand Up @@ -108,7 +110,9 @@ export const PaymentAndRefundDetail = () => {

useEffect(() => {
if (permitIssuers) {
setValue("users", Object.keys(permitIssuers));
// permitIssuers is a <userName, userGUID> record.
// So, Object.values is what we need.
setValue("users", Object.values(permitIssuers));
}
}, [ispermitIssuersQueryLoading]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <userName, userGUID> 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[];
}
Expand Down Expand Up @@ -93,14 +95,16 @@ export const UserSelect = ({ permitIssuers }: UserSelectProps) => {
<ListItemText primary={"All Users"} />
</MenuItem>
{permitIssuers
? Object.keys(permitIssuers).map((key) => (
<MenuItem key={key} value={key}>
<Checkbox
checked={selectedUsers && selectedUsers.indexOf(key) > -1}
/>
<ListItemText primary={key} />
</MenuItem>
))
? Object.entries(permitIssuers).map(([key, value]) => {
return (
<MenuItem key={key} value={value}>
<Checkbox
checked={selectedUsers && selectedUsers.indexOf(value) > -1}
/>
<ListItemText primary={key} />
</MenuItem>
);
})
: []}
</Select>
</FormControl>
Expand Down

0 comments on commit 4d79059

Please sign in to comment.