11import { getNowInCalendar } from '@dhis2/multi-calendar-dates'
22import { IconInfo16 , NoticeBox , TabBar , Tab , Transfer } from '@dhis2/ui'
33import PropTypes from 'prop-types'
4- import React , { useRef , useState , useMemo } from 'react'
4+ import React , { useCallback , useRef , useState , useMemo } from 'react'
55import PeriodIcon from '../../assets/DimensionItemIcons/PeriodIcon.js' //TODO: Reimplement the icon.js
66import i18n from '../../locales/index.js'
77import {
@@ -20,7 +20,15 @@ import {
2020 filterEnabledRelativePeriodTypes ,
2121} from './utils/enabledPeriodTypes.js'
2222import { getFixedPeriodsOptions } from './utils/fixedPeriods.js'
23- import { MONTHLY , QUARTERLY , filterPeriodTypesById } from './utils/index.js'
23+ import {
24+ FYFEB ,
25+ FYAUG ,
26+ FYSEP ,
27+ MONTHLY ,
28+ QUARTERLY ,
29+ WEEKLYFRI ,
30+ filterPeriodTypesById ,
31+ } from './utils/index.js'
2432import { getRelativePeriodsOptions } from './utils/relativePeriods.js'
2533
2634const RightHeader = ( { infoBoxMessage } ) => (
@@ -91,15 +99,20 @@ const PeriodTransfer = ({
9199 } else {
92100 const allFixed = getFixedPeriodsOptions ( periodsSettings )
93101 const allRelative = getRelativePeriodsOptions ( )
102+ const v43PeriodTypes = [ WEEKLYFRI , FYFEB , FYAUG , FYSEP ]
103+ const allExcludedPeriodTypes = [
104+ ...excludedPeriodTypes ,
105+ ...v43PeriodTypes ,
106+ ]
94107
95108 return {
96109 filteredFixedOptions : filterPeriodTypesById (
97110 allFixed ,
98- excludedPeriodTypes
111+ allExcludedPeriodTypes
99112 ) ,
100113 filteredRelativeOptions : filterPeriodTypesById (
101114 allRelative ,
102- excludedPeriodTypes
115+ allExcludedPeriodTypes
103116 ) ,
104117 }
105118 }
@@ -139,11 +152,14 @@ const PeriodTransfer = ({
139152 // there is still a pending decision in Temporal regarding which era to use by default: https://github.com/js-temporal/temporal-polyfill/blob/9350ee7dd0d29f329fc097debf923a517c32f813/lib/calendar.ts#L1964
140153 const defaultFixedPeriodYear = now . eraYear || now . year
141154
142- const fixedPeriodConfig = ( year ) => ( {
143- offset : year - defaultFixedPeriodYear ,
144- filterFuturePeriods : false ,
145- reversePeriods : false ,
146- } )
155+ const fixedPeriodConfig = useCallback (
156+ ( year ) => ( {
157+ offset : year - defaultFixedPeriodYear ,
158+ filterFuturePeriods : false ,
159+ reversePeriods : false ,
160+ } ) ,
161+ [ defaultFixedPeriodYear ]
162+ )
147163
148164 const [ userPeriods , setUserPeriods ] = useState ( null )
149165 const [ isRelative , setIsRelative ] = useState ( true )
@@ -215,6 +231,7 @@ const PeriodTransfer = ({
215231 filteredRelativeOptions ,
216232 filteredFixedOptions ,
217233 fixedFilter . year ,
234+ fixedPeriodConfig ,
218235 ] )
219236
220237 const allPeriods = userPeriods ?? derivedPeriods
0 commit comments