Добавлены новые зависимости: "react-select" и "@floating-ui/core". Реализована локализация с использованием i18next, добавлены переводы для английского и русского языков. Обновлены компоненты для поддержки локализации, включая AppHeader, Attendance, Dashboard и другие. Улучшена логика отображения данных и взаимодействия с пользователем.

This commit is contained in:
2025-03-23 11:41:29 +03:00
parent d5b5838e51
commit d3a7f70d12
27 changed files with 995 additions and 191 deletions

View File

@@ -20,6 +20,7 @@ import {
} from '@chakra-ui/react'
import { useForm, Controller } from 'react-hook-form'
import { AddIcon } from '@chakra-ui/icons'
import { useTranslation } from 'react-i18next'
import { ErrorSpan } from '../style'
import { useAppSelector } from '../../__data__/store'
@@ -40,6 +41,7 @@ export const CoursesList = () => {
const [createUpdateCourse, crucQuery] = api.useCreateUpdateCourseMutation()
const [showForm, setShowForm] = useState(false)
const toastRef = useRef(null)
const { t } = useTranslation()
const { colorMode } = useColorMode();
@@ -52,13 +54,13 @@ export const CoursesList = () => {
} = useForm<NewCourseForm>({
defaultValues: {
startDt: dayjs().format('YYYY-MM-DD'),
name: 'Название',
name: t('journal.pl.course.defaultName'),
},
})
const onSubmit = ({ startDt, name }) => {
toastRef.current = toast({
title: 'Отправляем',
title: t('journal.pl.course.sending'),
status: 'loading',
duration: 9000,
})
@@ -70,8 +72,8 @@ export const CoursesList = () => {
const values = getValues()
if (toastRef.current) {
toast.update(toastRef.current, {
title: 'Курс создан.',
description: `Курс ${values.name} успешно создан`,
title: t('journal.pl.course.created'),
description: t('journal.pl.course.successMessage', { name: values.name }),
status: 'success',
duration: 9000,
isClosable: true,
@@ -79,7 +81,7 @@ export const CoursesList = () => {
}
reset()
}
}, [crucQuery.isSuccess])
}, [crucQuery.isSuccess, t])
if (isLoading) {
return (
@@ -95,7 +97,7 @@ export const CoursesList = () => {
<Card align="left">
<CardHeader display="flex">
<Heading as="h2" mt="0">
Создание курса
{t('journal.pl.course.createTitle')}
</Heading>
<CloseButton ml="auto" onClick={() => setShowForm(false)} />
</CardHeader>
@@ -105,17 +107,17 @@ export const CoursesList = () => {
<Controller
control={control}
name="startDt"
rules={{ required: 'Обязательное поле' }}
rules={{ required: t('journal.pl.common.requiredField') }}
render={({ field }) => (
<FormControl
isRequired
isInvalid={Boolean(errors.startDt)}
>
<FormLabel>Дата начала</FormLabel>
<FormLabel>{t('journal.pl.common.startDate')}</FormLabel>
<Input
{...field}
required={false}
placeholder="Select Date and Time"
placeholder={t('journal.pl.common.selectDateTime')}
size="md"
type="date"
/>
@@ -125,7 +127,7 @@ export const CoursesList = () => {
</FormErrorMessage>
) : (
<FormHelperText>
Укажите дату начала курса
{t('journal.pl.course.specifyStartDate')}
</FormHelperText>
)}
</FormControl>
@@ -135,18 +137,18 @@ export const CoursesList = () => {
control={control}
name="name"
rules={{
required: 'Обязательное поле',
required: t('journal.pl.common.requiredField'),
}}
render={({ field }) => (
<FormControl
isRequired
isInvalid={Boolean(errors.name)}
>
<FormLabel>Название новой лекции:</FormLabel>
<FormLabel>{t('journal.pl.course.newLectureName')}:</FormLabel>
<Input
{...field}
required={false}
placeholder="КФУ-24-2"
placeholder={t('journal.pl.course.namePlaceholder')}
size="md"
/>
{errors.name && (
@@ -165,7 +167,7 @@ export const CoursesList = () => {
leftIcon={<AddIcon />}
colorScheme="blue"
>
Создать
{t('journal.pl.common.create')}
</Button>
</Box>
</VStack>
@@ -183,7 +185,7 @@ export const CoursesList = () => {
colorScheme="green"
onClick={() => setShowForm(true)}
>
Добавить
{t('journal.pl.common.add')}
</Button>
</Box>
)}