Skip to content

Commit

Permalink
feat: specify calendar type from system settings
Browse files Browse the repository at this point in the history
  • Loading branch information
d-rita committed Jun 7, 2024
1 parent 6f19cb6 commit 2033e7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/data-workspace/inputs/date-input.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useConfig } from '@dhis2/app-runtime'
import { CalendarInput } from '@dhis2/ui'
import cx from 'classnames'
import React from 'react'
import { useField } from 'react-final-form'
import { useSetDataValueMutation, useUserInfo } from '../../shared/index.js'
Expand All @@ -22,6 +22,10 @@ export const DateInput = ({
},
} = useUserInfo()

const {
systemInfo: { calendar },
} = useConfig()

const { input, meta } = useField(fieldname, {
subscription: {
value: true,
Expand Down Expand Up @@ -57,7 +61,7 @@ export const DateInput = ({
return (
<CalendarInput
{...input}
className={cx(styles.dateInput)}
className={styles.dateInput}
onFocus={(...args) => {
input.onFocus(...args)
onFocus?.(...args)
Expand All @@ -71,7 +75,7 @@ export const DateInput = ({
disabled={disabled}
readOnly={locked}
date={input.value}
calendar={'gregory'}
calendar={calendar}
onDateSelect={(date) => {
input.onChange(date?.calendarDateString)
}}
Expand Down
1 change: 0 additions & 1 deletion src/data-workspace/inputs/generic-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
} from './validators.js'

const htmlTypeAttrsByValueType = {
[VALUE_TYPES.DATE]: 'date',
[VALUE_TYPES.DATETIME]: 'datetime-local',
[VALUE_TYPES.EMAIL]: 'email',
[VALUE_TYPES.PHONE_NUMBER]: 'tel',
Expand Down

0 comments on commit 2033e7d

Please sign in to comment.