Skip to content

Commit

Permalink
fix: add undefined validation
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikhaugstulen committed Oct 29, 2024
1 parent ef57abf commit 3d7c44a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { errorCreator } from 'capture-core-utils';
import { ofType } from 'redux-observable';
import { concatMap, filter, takeUntil } from 'rxjs/operators';
import {
workingListsCommonActionTypes,
addTemplateSuccess,
addTemplateError,
deleteTemplateSuccess,
addTemplateSuccess,
deleteTemplateError,
updateTemplateSuccess,
updateTemplateError,
deleteTemplateSuccess,
updateDefaultTemplate,
updateTemplateError,
updateTemplateSuccess,
workingListsCommonActionTypes,
workingListsCommonActionTypesBatchActionTypes,
} from '../../../WorkingListsCommon';
import { TEI_WORKING_LISTS_TYPE } from '../../constants';
Expand Down Expand Up @@ -55,7 +55,7 @@ export const addTEITemplateEpic = (action$: InputObservable, store: ReduxStore,
...(assignedUserMode && { assignedUserMode }),
...(assignedUsers?.length > 0 && { assignedUsers }),
...(programStatus && { enrollmentStatus: programStatus }),
...(!!followUp && { followUp }),
...(followUp !== undefined && { followUp: JSON.stringify(followUp) }),
...(enrolledAt && { enrollmentCreatedDate: enrolledAt }),
...(occurredAt && { enrollmentIncidentDate: occurredAt }),
...(attributeValueFilters?.length > 0 && { attributeValueFilters }),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// @flow
import moment from 'moment';
import {
filterTypesObject,
dateFilterTypes,
type BooleanFilterData,
type TextFilterData,
type NumericFilterData,
type DateFilterData,
dateFilterTypes,
filterTypesObject,
type NumericFilterData,
type TextFilterData,
} from '../../../../WorkingListsBase';
import type { ApiDataFilterBoolean, ApiDataFilterDateContents } from '../../../types';
import { ADDITIONAL_FILTERS } from '../../../helpers';
Expand Down Expand Up @@ -108,7 +108,7 @@ export const convertMainFilters = ({
}

const mainValue = mainFiltersTable[key](filter);
if (mainValue) {
if (mainValue !== undefined) {
if (key === MAIN_FILTERS.ASSIGNEE) {
return { ...acc, ...mainValue };
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
// @flow
import * as React from 'react';
import { withStyles } from '@material-ui/core/styles';
import i18n from '@dhis2/d2-i18n';
import { Button, Modal, ModalTitle, ModalContent, ModalActions } from '@dhis2/ui';

const getStyles = () => ({
buttonContainer: {
display: 'flex',
justifyContent: 'space-between',
},
});
import { Button, ButtonStrip, Modal, ModalActions, ModalContent, ModalTitle } from '@dhis2/ui';

type Props = {
open: boolean,
onClose: () => void,
onDeleteTemplate: () => void,
templateName: string,
classes: Object,
};

const DeleteConfirmationDialogPlain = (props: Props) => {
export const DeleteConfirmationDialog = (props: Props) => {
const {
open,
onClose,
onDeleteTemplate,
templateName,
classes,
} = props;

if (!open) {
Expand All @@ -41,18 +31,17 @@ const DeleteConfirmationDialogPlain = (props: Props) => {
<ModalContent>
{i18n.t('Do you really want to delete the \'{{templateName}}\' view?', { templateName })}
</ModalContent>
<ModalActions
className={classes.buttonContainer}
>
<Button onClick={onClose}>
{i18n.t('Cancel')}
</Button>
<Button onClick={onDeleteTemplate} primary>
{i18n.t('Confirm')}
</Button>
<ModalActions>
<ButtonStrip>
<Button onClick={onClose}>
{i18n.t('Cancel')}
</Button>
<Button onClick={onDeleteTemplate} primary>
{i18n.t('Confirm')}
</Button>
</ButtonStrip>
</ModalActions>
</Modal>
);
};

export const DeleteConfirmationDialog = withStyles(getStyles)(DeleteConfirmationDialogPlain);
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
// @flow
import * as React from 'react';
import { withStyles } from '@material-ui/core/styles';
import i18n from '@dhis2/d2-i18n';
import { Button, ModalTitle, ModalContent, ModalActions } from '@dhis2/ui';

const getStyles = () => ({
buttonContainer: {
display: 'flex',
justifyContent: 'space-between',
},
});
import { Button, ButtonStrip, ModalActions, ModalContent, ModalTitle } from '@dhis2/ui';

type Props = {
onSaveTemplate: () => void,
onClose: () => void,
classes: Object,
};

const ExistingTemplateContentsPlain = (props: Props) => {
const { onSaveTemplate, onClose, classes } = props;
export const ExistingTemplateContents = (props: Props) => {
const { onSaveTemplate, onClose } = props;
return (
<React.Fragment>
<ModalTitle>{i18n.t('Save')}</ModalTitle>
<ModalContent />
<ModalActions
className={classes.buttonContainer}
>
<Button onClick={onClose}>
{i18n.t('Cancel')}
</Button>
<Button onClick={onSaveTemplate} primary>
{i18n.t('Save')}
</Button>
<ModalActions>
<ButtonStrip>
<Button onClick={onClose}>
{i18n.t('Cancel')}
</Button>
<Button onClick={onSaveTemplate} primary>
{i18n.t('Save')}
</Button>
</ButtonStrip>
</ModalActions>
</React.Fragment>
);
};

export const ExistingTemplateContents = withStyles(getStyles)(ExistingTemplateContentsPlain);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import * as React from 'react';
import { colors, Button, ModalTitle, ModalContent, ModalActions } from '@dhis2/ui';
import { Button, ButtonStrip, colors, ModalActions, ModalContent, ModalTitle } from '@dhis2/ui';
import { withStyles } from '@material-ui/core/styles';
import i18n from '@dhis2/d2-i18n';
import { NewTemplateTextField } from './NewTemplateTextField.component';
Expand Down Expand Up @@ -64,15 +64,15 @@ const NewTemplateContentsPlain = (props: Props) => {
{error}
</div>
</ModalContent>
<ModalActions
className={classes.buttonContainer}
>
<Button onClick={onClose}>
{i18n.t('Cancel')}
</Button>
<Button onClick={handleSave} primary>
{i18n.t('Save')}
</Button>
<ModalActions>
<ButtonStrip>
<Button onClick={onClose}>
{i18n.t('Cancel')}
</Button>
<Button onClick={handleSave} primary>
{i18n.t('Save')}
</Button>
</ButtonStrip>
</ModalActions>
</React.Fragment>
);
Expand Down

0 comments on commit 3d7c44a

Please sign in to comment.