Рефакторинг импорта dayjs и добавление утилиты форматирования дат. Все компоненты, использующие dayjs, теперь используют новую функцию formatDate для форматирования дат с учетом локали. Также добавлена поддержка обновления локали dayjs при изменении языка в i18next.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React, { useCallback, useEffect, useState, useMemo } from 'react'
|
||||
import { formatDate } from '../../utils/dayjs-config'
|
||||
import dayjs from 'dayjs'
|
||||
import { Link as ConnectedLink, generatePath } from 'react-router-dom'
|
||||
import { getNavigationValue } from '@brojs/cli'
|
||||
@@ -231,7 +232,7 @@ export const CourseCard = ({ course }: { course: Course }) => {
|
||||
<Badge colorScheme="blue">
|
||||
<HStack spacing={1}>
|
||||
<CalendarIcon boxSize="3" />
|
||||
<Text>{dayjs(course.startDt).format('DD.MM.YYYY')}</Text>
|
||||
<Text>{formatDate(course.startDt, 'DD.MM.YYYY')}</Text>
|
||||
</HStack>
|
||||
</Badge>
|
||||
<Badge colorScheme="purple">
|
||||
@@ -243,7 +244,7 @@ export const CourseCard = ({ course }: { course: Course }) => {
|
||||
<Badge colorScheme="blue">
|
||||
<HStack spacing={1}>
|
||||
<CalendarIcon boxSize="3" />
|
||||
<Text>{dayjs(course.startDt).format('DD.MM.YYYY')}</Text>
|
||||
<Text>{formatDate(course.startDt, 'DD.MM.YYYY')}</Text>
|
||||
</HStack>
|
||||
</Badge>
|
||||
<Badge colorScheme="purple">
|
||||
@@ -311,10 +312,12 @@ export const CourseCard = ({ course }: { course: Course }) => {
|
||||
{populatedCourse.data?.lessons
|
||||
.filter(lesson => dayjs(lesson.date).isAfter(dayjs()))
|
||||
.sort((a, b) => dayjs(a.date).valueOf() - dayjs(b.date).valueOf())[0]?.date
|
||||
? dayjs(populatedCourse.data?.lessons
|
||||
.filter(lesson => dayjs(lesson.date).isAfter(dayjs()))
|
||||
.sort((a, b) => dayjs(a.date).valueOf() - dayjs(b.date).valueOf())[0]?.date)
|
||||
.format('DD.MM.YYYY')
|
||||
? formatDate(
|
||||
populatedCourse.data?.lessons
|
||||
.filter(lesson => dayjs(lesson.date).isAfter(dayjs()))
|
||||
.sort((a, b) => dayjs(a.date).valueOf() - dayjs(b.date).valueOf())[0]?.date,
|
||||
'DD.MM.YYYY'
|
||||
)
|
||||
: t('journal.pl.common.noData')
|
||||
}
|
||||
</Text>
|
||||
@@ -455,7 +458,7 @@ export const CourseCard = ({ course }: { course: Course }) => {
|
||||
<HStack spacing={2} mt={1} flexWrap="wrap">
|
||||
<Tag size="sm" colorScheme={isPast ? "green" : "blue"} borderRadius="full">
|
||||
<TagLeftIcon as={CalendarIcon} boxSize='10px' />
|
||||
<TagLabel>{dayjs(lesson.date).format('DD.MM.YYYY')}</TagLabel>
|
||||
<TagLabel>{formatDate(lesson.date, 'DD.MM.YYYY')}</TagLabel>
|
||||
</Tag>
|
||||
{isPast && lessonAttendance && (
|
||||
<Tag
|
||||
|
||||
Reference in New Issue
Block a user