Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support localization in date filter (#5572)
- Loading branch information
Showing
5 changed files
with
34 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 2 additions & 8 deletions
10
frontend/src/component/common/Table/cells/DateCell/DateCell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
import { VFC } from 'react'; | ||
import { useLocationSettings } from 'hooks/useLocationSettings'; | ||
import { formatDateYMD } from 'utils/formatDate'; | ||
import { parseISO } from 'date-fns'; | ||
import { TextCell } from 'component/common/Table/cells/TextCell/TextCell'; | ||
import { getLocalizedDateString } from '../../../util'; | ||
|
||
interface IDateCellProps { | ||
value?: Date | string | null; | ||
} | ||
|
||
export const DateCell: VFC<IDateCellProps> = ({ value }) => { | ||
const { locationSettings } = useLocationSettings(); | ||
|
||
const date = value | ||
? value instanceof Date | ||
? formatDateYMD(value, locationSettings.locale) | ||
: formatDateYMD(parseISO(value), locationSettings.locale) | ||
: undefined; | ||
const date = getLocalizedDateString(value, locationSettings.locale); | ||
|
||
return <TextCell lineClamp={1}>{date}</TextCell>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters