diff --git a/src/Configuration/Customers/CustomerDetailView/CustomerPlanContainer.jsx b/src/Configuration/Customers/CustomerDetailView/CustomerPlanContainer.jsx
index b96e245b1..4896796ed 100644
--- a/src/Configuration/Customers/CustomerDetailView/CustomerPlanContainer.jsx
+++ b/src/Configuration/Customers/CustomerDetailView/CustomerPlanContainer.jsx
@@ -8,8 +8,6 @@ const CustomerPlanContainer = ({
slug,
activePolicies,
activeSubscriptions,
- countOfActivePlans,
- countOfAllPlans,
inactivePolicies,
inactiveSubscriptions,
isLoading,
@@ -33,6 +31,10 @@ const CustomerPlanContainer = ({
));
+ const countOfActivePlans = activeSubscriptions.length + activePolicies.length;
+ const countOfInactivePlans = inactiveSubscriptions.length + inactivePolicies.length;
+ const countOfAllPlans = countOfActivePlans + countOfInactivePlans;
+
return (
{!isLoading ? (
diff --git a/src/Configuration/Customers/CustomerDetailView/CustomerViewContainer.jsx b/src/Configuration/Customers/CustomerDetailView/CustomerViewContainer.jsx
index 4e3d2c344..23716a271 100644
--- a/src/Configuration/Customers/CustomerDetailView/CustomerViewContainer.jsx
+++ b/src/Configuration/Customers/CustomerDetailView/CustomerViewContainer.jsx
@@ -38,7 +38,7 @@ const CustomerViewContainer = () => {
useEffect(() => {
fetchData();
- }, []);
+ }, [fetchData]);
const renderPlanContainer = () => {
if (!isLoading && !associatedPlans.isLoading && associatedPlans.countOfAllPlans) {
diff --git a/src/Configuration/Customers/data/hooks/useAllAssociatedPlans.js b/src/Configuration/Customers/data/hooks/useAllAssociatedPlans.js
index 7f50a0cb0..38edf67e8 100644
--- a/src/Configuration/Customers/data/hooks/useAllAssociatedPlans.js
+++ b/src/Configuration/Customers/data/hooks/useAllAssociatedPlans.js
@@ -11,8 +11,6 @@ const useAllAssociatedPlans = (enterpriseId) => {
const [activeSubscriptions, setActiveSubscriptions] = useState([]);
const [activePolicies, setActivePolicies] = useState([]);
const [inactivePolicies, setInactivePolicies] = useState([]);
- const [countOfActivePlans, setCountOfActivePlans] = useState(0);
- const [countOfAllPlans, setCountOfAllPlans] = useState(0);
const fetchData = useCallback(
async () => {
@@ -39,19 +37,11 @@ const useAllAssociatedPlans = (enterpriseId) => {
useEffect(() => {
fetchData();
- if (!isLoading) {
- const activePlanCount = activeSubscriptions.length + activePolicies.length;
- const inactivePlanCount = inactiveSubscriptions.length + inactivePolicies.length;
- setCountOfActivePlans(prev => prev + activePlanCount);
- setCountOfAllPlans(prev => prev + activePlanCount + inactivePlanCount);
- }
- }, [fetchData, isLoading]);
+ }, [fetchData]);
return {
activePolicies,
activeSubscriptions,
- countOfActivePlans,
- countOfAllPlans,
inactivePolicies,
inactiveSubscriptions,
isLoading,