diff --git a/src/components/EnrollmentHeadPanel.js b/src/components/EnrollmentHeadPanel.js index 2baaf03..9db1b31 100644 --- a/src/components/EnrollmentHeadPanel.js +++ b/src/components/EnrollmentHeadPanel.js @@ -117,6 +117,7 @@ class EnrollmentHeadPanel extends FormPanel { updateAttributes={this.updateJsonExt} getDefaultAppliedCustomFilters={this.getDefaultAppliedCustomFilters} additionalParams={enrollment?.benefitPlan ? { benefitPlan: `${decodeId(enrollment.benefitPlan.id)}` } : null} + edited={this.props.edited} /> diff --git a/src/components/dialogs/AdvancedCriteriaForm.js b/src/components/dialogs/AdvancedCriteriaForm.js index 54f981c..984e0dd 100644 --- a/src/components/dialogs/AdvancedCriteriaForm.js +++ b/src/components/dialogs/AdvancedCriteriaForm.js @@ -50,6 +50,7 @@ function AdvancedCriteriaForm({ clearConfirm, coreConfirm, rights, + edited, }) { // eslint-disable-next-line no-unused-vars const [currentFilter, setCurrentFilter] = useState({ @@ -58,6 +59,22 @@ function AdvancedCriteriaForm({ const [filters, setFilters] = useState(getDefaultAppliedCustomFilters()); const [filtersToApply, setFiltersToApply] = useState(null); + const getBenefitPlanDefaultCriteria = () => { + const { jsonExt } = edited?.benefitPlan ?? {}; + try { + const jsonData = JSON.parse(jsonExt); + return jsonData.advanced_criteria || []; + } catch (error) { + return []; + } + }; + + useEffect(() => { + if (!getDefaultAppliedCustomFilters().length) { + setFilters(getBenefitPlanDefaultCriteria()); + } + }, [edited]); + const createParams = (moduleName, objectTypeName, uuidOfObject = null, additionalParams = null) => { const params = [ `moduleName: "${moduleName}"`, diff --git a/src/index.js b/src/index.js index 9112400..a9df257 100644 --- a/src/index.js +++ b/src/index.js @@ -40,6 +40,7 @@ import { GROUP_LABEL, INDIVIDUAL_LABEL } from './constants'; import { GroupCreateTaskItemFormatters, GroupCreateTaskTableHeaders } from './components/tasks/GroupCreateTasks'; import IndividualsUploadDialog from './components/dialogs/IndividualsUploadDialog'; import { BenefitsTabLabel, BenefitsTabPanel } from './components/BenefitsTab'; +import AdvancedCriteriaRowValue from './components/dialogs/AdvancedCriteriaRowValue'; const ROUTE_INDIVIDUALS = 'individuals'; const ROUTE_INDIVIDUAL = 'individuals/individual'; @@ -75,6 +76,7 @@ const DEFAULT_CONFIG = { { key: 'individual.IndividualHistorySearcher', ref: IndividualHistorySearcher }, { key: 'individual.GroupHistorySearcher', ref: GroupHistorySearcher }, { key: 'individual.IndividualsUploadDialog', ref: IndividualsUploadDialog }, + { key: 'individual.AdvancedCriteriaRowValue', ref: AdvancedCriteriaRowValue }, ], 'individual.IndividualsUploadDialog': IndividualsUploadDialog, 'individual.TabPanel.label': [