Skip to content

Commit

Permalink
CM-737: get default criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan committed Mar 5, 2024
1 parent 4df597e commit 6dfa0e7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/EnrollmentHeadPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>
</Grid>
</>
Expand Down
17 changes: 17 additions & 0 deletions src/components/dialogs/AdvancedCriteriaForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,30 @@ function AdvancedCriteriaForm({
confirmed,
clearConfirm,
coreConfirm,
edited,
}) {
// eslint-disable-next-line no-unused-vars
const [currentFilter, setCurrentFilter] = useState({
field: '', filter: '', type: '', value: '', amount: '',
});
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}"`,
Expand Down

0 comments on commit 6dfa0e7

Please sign in to comment.