Skip to content

Commit

Permalink
fix(migration-events): change start and endDate to occuuredBefore and…
Browse files Browse the repository at this point in the history
… occuredAfter
  • Loading branch information
kabaros committed Mar 5, 2024
1 parent 9ccd0b3 commit d4800d7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
12 changes: 9 additions & 3 deletions src/components/Inputs/EndDate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import i18n from '@dhis2/d2-i18n'
import { hasValue, composeValidators } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import { DATE_VALIDATOR } from '../DatePicker/DatePickerField.js'
import { DatePickerField } from '../index.js'
Expand All @@ -9,13 +10,18 @@ const DATATEST = 'input-end-date'
const LABEL = i18n.t('End date')
const VALIDATOR = composeValidators(hasValue, DATE_VALIDATOR)

const EndDate = () => (
const EndDate = ({name, label}) => (
<DatePickerField
name={NAME}
name={name ?? NAME}
validator={VALIDATOR}
label={LABEL}
label={label ?? LABEL}
dataTest={DATATEST}
/>
)

EndDate.propTypes = {
label: PropTypes.string,
name: PropTypes.string
}

export { EndDate }
12 changes: 9 additions & 3 deletions src/components/Inputs/StartDate.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import i18n from '@dhis2/d2-i18n'
import { hasValue, composeValidators } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import { DATE_VALIDATOR } from '../DatePicker/DatePickerField.js'
import { DatePickerField } from '../index.js'


const NAME = 'startDate'
const DATATEST = 'input-start-date'
const LABEL = i18n.t('Start date')
const VALIDATOR = composeValidators(hasValue, DATE_VALIDATOR)

const StartDate = () => (
const StartDate = ({name, label}) => (
<DatePickerField
name={NAME}
name={name ?? NAME}
validator={VALIDATOR}
label={LABEL}
label={label ?? LABEL}
dataTest={DATATEST}
/>
)

StartDate.propTypes = {
label: PropTypes.string,
name: PropTypes.string
}
export { StartDate }
8 changes: 4 additions & 4 deletions src/pages/EventExport/EventExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const initialValues = {
programStage: undefined,
format: defaultFormatOption,
compression: defaultCompressionOption,
startDate: jsDateToISO8601(threeMonthsBeforeToday),
endDate: jsDateToISO8601(today),
occurredAfter: jsDateToISO8601(threeMonthsBeforeToday),
occurredBefore: jsDateToISO8601(today),
includeDeleted: false,
dataElementIdScheme: defaultDataElementIdSchemeOption,
orgUnitIdScheme: defaultOrgUnitIdSchemeOption,
Expand Down Expand Up @@ -101,8 +101,8 @@ const EventExport = () => {
<Dates
label={i18n.t('Date range to export data for')}
>
<StartDate />
<EndDate />
<StartDate name="occurredAfter" />
<EndDate name="occurredBefore" />
</Dates>
<Format availableFormats={formatNoXmlOptions} />
<Compression />
Expand Down
8 changes: 4 additions & 4 deletions src/pages/EventExport/form-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const onExport = (baseUrl, setExportEnabled) => (values) => {
programStage,
format,
compression,
startDate,
endDate,
occurredAfter,
occurredBefore,
includeDeleted,
dataElementIdScheme,
orgUnitIdScheme,
Expand All @@ -38,8 +38,8 @@ const onExport = (baseUrl, setExportEnabled) => (values) => {
`orgUnitIdScheme=${orgUnitIdScheme}`,
`idScheme=${idScheme}`,
`attachment=${filename}`,
`startDate=${startDate}`,
`endDate=${endDate}`,
`occurredAfter=${occurredAfter}`,
`occurredBefore=${occurredBefore}`,
`ouMode=${inclusion}`,
`format=${format}`,
programStage != ALL_VALUE ? `programStage=${programStage}` : '',
Expand Down

0 comments on commit d4800d7

Please sign in to comment.