Skip to content

Commit

Permalink
Fixes policy admin state duplication and unresponsive ui
Browse files Browse the repository at this point in the history
  • Loading branch information
savindi7 committed Feb 18, 2025
1 parent ee79e32 commit 09b878d
Showing 1 changed file with 8 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,51 +108,26 @@ const PolicyAdministrationPageLayout: FunctionComponent<PolicyAdministrationPage
if (!inactivePolicyArray) {
return;
}

const activePolicyIds: string[] = activePolicies.map(
((activePolicy: PolicyInterface) => activePolicy.policyId)
);

const filteredInactivePolicies: PolicyInterface[] = (inactivePolicyArray.policySet ?? [])
.filter((policy: PolicyInterface) =>
policy !== null && !activePolicyIds.includes(policy.policyId)
);

if (pageInactive === 0) {
setInactivePolicies(filteredInactivePolicies);
} else {
setInactivePolicies(
(prev: PolicyInterface[]): PolicyInterface[] => [ ...prev, ...filteredInactivePolicies ]
);
}

const filteredInactivePolicies: PolicyInterface[] = (inactivePolicyArray.policySet ?? []).filter
((policy: PolicyInterface) => policy !== null || []);

Check failure on line 112 in features/admin.policy-administration.v1/components/policy-administration-page-layout.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint (STATIC ANALYSIS) (lts/*, 8.7.4)

Unexpected newline between function and ( of function call
setInactivePolicies(filteredInactivePolicies);

Check warning on line 113 in features/admin.policy-administration.v1/components/policy-administration-page-layout.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint (STATIC ANALYSIS) (lts/*, 8.7.4)

Expected blank line before this statement
if ((pageInactive + 1) >= (inactivePolicyArray.numberOfPages ?? 1)) {
setHasMoreInactivePolicies(false);
}

}, [ inactivePolicyArray, activePolicyArray ]);

}, [ inactivePolicyArray]);

Check warning on line 118 in features/admin.policy-administration.v1/components/policy-administration-page-layout.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint (STATIC ANALYSIS) (lts/*, 8.7.4)

A space is required before ']'
useEffect(() => {
if (!activePolicyArray){
if (!activePolicyArray) {
return;
}

const rawActivePolicies: PolicyInterface[] = activePolicyArray.policySet?.filter(
(policy: PolicyInterface) => policy !== null) || [];

if (pageActive === 0) {
setActivePolicies(rawActivePolicies);
} else {
setActivePolicies((prev: PolicyInterface[]): PolicyInterface[] => [ ...prev, ...rawActivePolicies ]);
}

const filteredActivePolicies: PolicyInterface[] = activePolicyArray.policySet?.filter(
(policy: PolicyInterface) => policy !== null || []);
setActivePolicies(filteredActivePolicies);

Check warning on line 125 in features/admin.policy-administration.v1/components/policy-administration-page-layout.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint (STATIC ANALYSIS) (lts/*, 8.7.4)

Expected blank line before this statement
if ((pageActive + 1) >= (activePolicyArray.numberOfPages ?? 1)) {
setHasMoreActivePolicies(false);
}

}, [ activePolicyArray ]);


useEffect(() => {
setPageInactive(0);
setHasMoreInactivePolicies(true);
Expand Down Expand Up @@ -184,7 +159,6 @@ const PolicyAdministrationPageLayout: FunctionComponent<PolicyAdministrationPage
setPageInactive((prevPage: number) => prevPage + 1);
};


const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
setSubmittedSearchQuery(searchQuery);
Expand Down

0 comments on commit 09b878d

Please sign in to comment.