Skip to content

Commit

Permalink
CM-737: make AppliedCriteriaRow public reference (#53)
Browse files Browse the repository at this point in the history
* CM-737: make AppliedCriteriaRow public reference

* CM-737: get default criteria

---------

Co-authored-by: Jan <[email protected]>
  • Loading branch information
jdolkowski and Jan authored Mar 6, 2024
1 parent a41cd8c commit cba0e82
Show file tree
Hide file tree
Showing 3 changed files with 20 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 @@ -50,6 +50,7 @@ function AdvancedCriteriaForm({
clearConfirm,
coreConfirm,
rights,
edited,
}) {
// eslint-disable-next-line no-unused-vars
const [currentFilter, setCurrentFilter] = useState({
Expand All @@ -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}"`,
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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': [
Expand Down

0 comments on commit cba0e82

Please sign in to comment.