From bd2fa420e266e13ecc120627444ece95d4cea6a1 Mon Sep 17 00:00:00 2001 From: knguyen2 Date: Tue, 3 Oct 2023 20:23:38 +0000 Subject: [PATCH 1/2] fix: associated catalog selection bug in prod --- .../tests/SubsidyEditView.test.jsx | 2 +- src/Configuration/Provisioning/data/constants.js | 15 --------------- src/Configuration/Provisioning/data/hooks.js | 8 ++++---- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/Configuration/Provisioning/SubsidyEditView/tests/SubsidyEditView.test.jsx b/src/Configuration/Provisioning/SubsidyEditView/tests/SubsidyEditView.test.jsx index 8bcb4019f..061327091 100644 --- a/src/Configuration/Provisioning/SubsidyEditView/tests/SubsidyEditView.test.jsx +++ b/src/Configuration/Provisioning/SubsidyEditView/tests/SubsidyEditView.test.jsx @@ -56,7 +56,7 @@ const mocks = { enterprise_customer: '4a67c952-8eb1-44ba-9ab3-2faa5d0905de', title: '4a67c952-8eb1-44ba-9ab3-2faa5d0905de - Open Courses budget', uuid: '69035754-fa48-4519-92d8-a723ae0f6e58', - enterprise_catalog_query: 29, + enterprise_catalog_query: 2, }], }, }, diff --git a/src/Configuration/Provisioning/data/constants.js b/src/Configuration/Provisioning/data/constants.js index 8ea711322..fba25fa7c 100644 --- a/src/Configuration/Provisioning/data/constants.js +++ b/src/Configuration/Provisioning/data/constants.js @@ -267,21 +267,6 @@ export const INITIAL_CATALOG_QUERIES = { ], }; -export const CATALOG_QUERIES = { - Everything: { - id: 28, - catalogQueryTitle: 'Everything', - }, - 'Executive Education budget': { - id: 29, - catalogQueryTitle: 'Executive Education budget', - }, - 'Open Courses budget': { - id: 30, - catalogQueryTitle: 'Open Courses budget', - }, -}; - export const MAX_PAGE_SIZE = 12; export default PROVISIONING_PAGE_TEXT; diff --git a/src/Configuration/Provisioning/data/hooks.js b/src/Configuration/Provisioning/data/hooks.js index 84e7414d0..66f8bc235 100644 --- a/src/Configuration/Provisioning/data/hooks.js +++ b/src/Configuration/Provisioning/data/hooks.js @@ -6,7 +6,6 @@ import LmsApiService from '../../../data/services/EnterpriseApiService'; import PROVISIONING_PAGE_TEXT, { INITIAL_CATALOG_QUERIES, MAX_PAGE_SIZE, - CATALOG_QUERIES, splitStringBudget, } from './constants'; import { ProvisioningContext } from '../ProvisioningContext'; @@ -239,6 +238,7 @@ export default function useProvisioningContext() { const policiesData = policies.data.results.filter(policy => policy.subsidy_uuid === subsidyUuid).map(policy => { let catalogCategoryTitle; const formattedPolicies = []; + const predefinedQueries = getCamelCasedConfigAttribute('PREDEFINED_CATALOG_QUERIES'); catalogs.forEach(catalog => { if (catalog.uuid === policy.catalog_uuid) { @@ -254,9 +254,9 @@ export default function useProvisioningContext() { title: catalogCategoryTitle, catalogUuid: catalog.uuid, }; - } else if (catalog.enterprise_catalog_query === CATALOG_QUERIES['Open Courses budget'].id - || catalog.enterprise_catalog_query === CATALOG_QUERIES.Everything.id - || catalog.enterprise_catalog_query === CATALOG_QUERIES['Executive Education budget'].id + } else if (catalog.enterprise_catalog_query === predefinedQueries.everything + || catalog.enterprise_catalog_query === predefinedQueries.executiveEducation + || catalog.enterprise_catalog_query === predefinedQueries.openCourses ) { catalogQuery = { id: catalog?.enterprise_catalog_query, From 498831e212dbba3c9c20f38829025b4f39ff4930 Mon Sep 17 00:00:00 2001 From: knguyen2 Date: Tue, 3 Oct 2023 21:32:23 +0000 Subject: [PATCH 2/2] fix: updated code based on reviewer feedback --- src/Configuration/Provisioning/data/hooks.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Configuration/Provisioning/data/hooks.js b/src/Configuration/Provisioning/data/hooks.js index 66f8bc235..760c9a8ed 100644 --- a/src/Configuration/Provisioning/data/hooks.js +++ b/src/Configuration/Provisioning/data/hooks.js @@ -254,10 +254,11 @@ export default function useProvisioningContext() { title: catalogCategoryTitle, catalogUuid: catalog.uuid, }; - } else if (catalog.enterprise_catalog_query === predefinedQueries.everything - || catalog.enterprise_catalog_query === predefinedQueries.executiveEducation - || catalog.enterprise_catalog_query === predefinedQueries.openCourses - ) { + } else if ([ + predefinedQueries.everything, + predefinedQueries.executiveEducation, + predefinedQueries.openCourses, + ].includes(catalog.enterprise_catalog_query)) { catalogQuery = { id: catalog?.enterprise_catalog_query, title: catalogCategoryTitle.split(splitStringBudget)[0],