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 55a0722..5b5db48 100644 --- a/src/components/dialogs/AdvancedCriteriaForm.js +++ b/src/components/dialogs/AdvancedCriteriaForm.js @@ -48,6 +48,7 @@ function AdvancedCriteriaForm({ confirmed, clearConfirm, coreConfirm, + edited, }) { // eslint-disable-next-line no-unused-vars const [currentFilter, setCurrentFilter] = useState({ @@ -55,6 +56,22 @@ function AdvancedCriteriaForm({ }); const [filters, setFilters] = useState(getDefaultAppliedCustomFilters()); + 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}"`,