From f28dc429348e26ee7d53c0259d0aba7f7ddcc598 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Mon, 9 Sep 2024 18:53:01 -0400 Subject: [PATCH] fix: memoized the course run ids passed to useApplicableCatalogs (#1296) * fix: memoized the course run ids passed to useApplicableCatalogs * fix: same fix for coupon requests --- .../subsidy-request-modals/ApproveCouponCodeRequestModal.jsx | 3 ++- .../subsidy-request-modals/ApproveLicenseRequestModal.jsx | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/subsidy-request-modals/ApproveCouponCodeRequestModal.jsx b/src/components/subsidy-request-modals/ApproveCouponCodeRequestModal.jsx index 5c40b0dac2..15dfc404f3 100644 --- a/src/components/subsidy-request-modals/ApproveCouponCodeRequestModal.jsx +++ b/src/components/subsidy-request-modals/ApproveCouponCodeRequestModal.jsx @@ -28,13 +28,14 @@ export const ApproveCouponCodeRequestModal = ({ onSuccess, onClose, }) => { + const courseRunIds = useMemo(() => [courseId], [courseId]); const { applicableCoupons, isLoading: isLoadingApplicableCoupons, error: loadApplicableCouponsError, } = useApplicableCoupons({ enterpriseId: enterpriseCustomerUUID, - courseRunIds: [courseId], + courseRunIds, coupons, }); const [selectedCouponId, setSelectedCouponId] = useState(); diff --git a/src/components/subsidy-request-modals/ApproveLicenseRequestModal.jsx b/src/components/subsidy-request-modals/ApproveLicenseRequestModal.jsx index 73095513da..26e7df95c3 100644 --- a/src/components/subsidy-request-modals/ApproveLicenseRequestModal.jsx +++ b/src/components/subsidy-request-modals/ApproveLicenseRequestModal.jsx @@ -28,13 +28,14 @@ export const ApproveLicenseRequestModal = ({ onClose, }) => { const { data: subscriptions } = useContext(SubscriptionContext); + const courseRunIds = useMemo(() => [courseId], [courseId]); const { applicableSubscriptions, isLoading: isLoadingApplicableSubscriptions, error: loadApplicableSubscriptionsError, } = useApplicableSubscriptions({ enterpriseId: enterpriseCustomerUUID, - courseRunIds: [courseId], + courseRunIds, subscriptions, }); @@ -92,7 +93,7 @@ export const ApproveLicenseRequestModal = ({ defaultMessage="Approve License Request" description="Title for the approve license request modal." /> -)} + )} isOpen={isOpen} hasCloseButton onClose={onClose}