diff --git a/.github/workflows/dhis2-verify-app.yml b/.github/workflows/dhis2-verify-app.yml index 7931c7bca..2d8aa4ca0 100644 --- a/.github/workflows/dhis2-verify-app.yml +++ b/.github/workflows/dhis2-verify-app.yml @@ -52,7 +52,7 @@ jobs: - name: Build run: yarn d2-app-scripts build - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: app-build path: | @@ -179,7 +179,7 @@ jobs: with: node-version: 14.x - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v4 with: name: app-build diff --git a/src/context-selection/period-selector-bar-item/period-selector-bar-item.js b/src/context-selection/period-selector-bar-item/period-selector-bar-item.js index 7c2db838b..38f6b16bb 100644 --- a/src/context-selection/period-selector-bar-item/period-selector-bar-item.js +++ b/src/context-selection/period-selector-bar-item/period-selector-bar-item.js @@ -11,7 +11,7 @@ import { usePeriodId, periodTypesMapping, yearlyFixedPeriodTypes, - isDateALessThanDateB, + isDateAGreaterThanDateB, } from '../../shared/index.js' import DisabledTooltip from './disabled-tooltip.js' import PeriodMenu from './period-menu.js' @@ -36,11 +36,13 @@ const getMaxYear = (dateLimit) => { // periods run up to, but not including dateLimit, so if limit is 1 January, max year is previous year // otherwise, max year is the year from the date limit const dateLimitYear = getYear(dateLimit) + try { const [year, month, day] = dateLimit.split('-') if (Number(month) === 1 && Number(day) === 1) { return Number(year) - 1 } + return dateLimitYear } catch (e) { console.error(e) return dateLimitYear @@ -50,7 +52,10 @@ const getMaxYear = (dateLimit) => { export const PeriodSelectorBarItem = () => { const { systemInfo = {} } = useConfig() const { calendar = 'gregory' } = systemInfo - const { eraYear: currentFullYear } = getNowInCalendar(calendar) + const { eraYear: nowEraYear, year: nowYear } = getNowInCalendar(calendar) + const currentFullYear = ['ethiopian', 'ethiopic'].includes(calendar) + ? nowEraYear + : nowYear const [periodOpen, setPeriodOpen] = useState(false) const [periodId, setPeriodId] = usePeriodId() @@ -117,7 +122,7 @@ export const PeriodSelectorBarItem = () => { // date comparison if ( - isDateALessThanDateB(endDate, dateLimit, { + isDateAGreaterThanDateB(endDate, dateLimit, { inclusive: true, calendar, }) diff --git a/src/context-selection/period-selector-bar-item/use-periods.js b/src/context-selection/period-selector-bar-item/use-periods.js index 503a5cc41..9678cc018 100644 --- a/src/context-selection/period-selector-bar-item/use-periods.js +++ b/src/context-selection/period-selector-bar-item/use-periods.js @@ -73,11 +73,14 @@ export default function usePeriods({ // date comparison if ( lastPeriodOfPrevYear && - // `${year}-01-01` <= lastPeriodOfPrevYear.endDate - isDateALessThanDateB(`${year}`, lastPeriodOfPrevYear.endDate, { - inclusive: true, - calendar, - }) + isDateALessThanDateB( + `${year}-01-01`, + lastPeriodOfPrevYear.endDate, + { + inclusive: true, + calendar, + } + ) ) { const [lastPeriodOfPrevYear] = generateFixedPeriods({ ...generateFixedPeriodsPayload, @@ -95,7 +98,7 @@ export default function usePeriods({ firstPeriodNextYear && // `${year + 1}-01-01` > firstPeriodNextYear.startDate isDateAGreaterThanDateB( - `${year + 1}`, + `${year + 1}-01-01`, firstPeriodNextYear.startDate, { inclusive: false, calendar } ) diff --git a/src/context-selection/period-selector-bar-item/year-navigator.js b/src/context-selection/period-selector-bar-item/year-navigator.js index 16e8f124d..8755206de 100644 --- a/src/context-selection/period-selector-bar-item/year-navigator.js +++ b/src/context-selection/period-selector-bar-item/year-navigator.js @@ -10,6 +10,7 @@ export default function YearNavigator({ onYearChange, calendar, }) { + // console.log('maxYear', maxYear) const startYear = startingYears[calendar] ?? startingYears.default return (