diff --git a/src/app/api/reviews/create/route.ts b/src/app/api/reviews/create/route.ts index 5f7f8cd..a0be0c4 100644 --- a/src/app/api/reviews/create/route.ts +++ b/src/app/api/reviews/create/route.ts @@ -16,7 +16,7 @@ export const POST = async (req: NextRequest) => { { review: { _name: validatedRequest.name, - _otzyv: validatedRequest.text, + _otzyv: validatedRequest.reviewMessage, _rejting: validatedRequest.rating, }, }, diff --git a/src/features/review-form/model/review-form.schema.ts b/src/features/review-form/model/review-form.schema.ts index f72335e..eea0574 100644 --- a/src/features/review-form/model/review-form.schema.ts +++ b/src/features/review-form/model/review-form.schema.ts @@ -5,7 +5,7 @@ export const reviewSchema = z.object({ .string() .min(2, { message: 'Имя должно содержать не менее 2 символов' }), rating: z.number().min(1, { message: 'Пожалуйста, выберите рейтинг' }).max(5), - text: z + reviewMessage: z .string() .min(10, { message: 'Отзыв должен содержать не менее 10 символов' }), }); diff --git a/src/features/review-form/ui/index.tsx b/src/features/review-form/ui/index.tsx index b2e7cd7..6e0033f 100644 --- a/src/features/review-form/ui/index.tsx +++ b/src/features/review-form/ui/index.tsx @@ -6,6 +6,7 @@ import { useState } from 'react'; import { useForm } from 'react-hook-form'; import { toast } from 'sonner'; +import { useTextController } from '@/shared/language'; import { Button } from '@/shared/shadcn-ui/button'; import { Dialog, @@ -32,6 +33,7 @@ import { useCreateReviewMutation } from '../api/reviews.api'; import { ReviewFormValues, reviewSchema } from '../model/review-form.schema'; export function ReviewForm() { + const { t } = useTextController(); const [openReviewFormDialog, setOpenReviewFormDialog] = useState(false); const [hoveredStar, setHoveredStar] = useState(0); @@ -42,7 +44,7 @@ export function ReviewForm() { defaultValues: { name: '', rating: 0, - text: '', + reviewMessage: '', }, }); @@ -50,22 +52,16 @@ export function ReviewForm() { try { await createReview(data); - toast.success( - 'Спасибо за ваш отзыв! Он будет опубликован после модерации.', - { - duration: 5000, - }, - ); + toast.success(t('about.review-form.dialog.successResponse'), { + duration: 5000, + }); form.reset(); setOpenReviewFormDialog(false); } catch (error) { - toast.error( - 'Произошла ошибка при отправке отзыва. Пожалуйста, попробуйте позже.', - { - duration: 5000, - }, - ); + toast.error(t('about.review-form.dialog.errorResponse'), { + duration: 5000, + }); } }; @@ -110,17 +106,17 @@ export function ReviewForm() {
- Оставьте свой отзыв + {t('about.review-form.dialog.title')} - Поделитесь своим опытом с нашей компанией + {t('about.review-form.dialog.description')} @@ -133,11 +129,15 @@ export function ReviewForm() { control={form.control} name='name' render={({ field }) => ( - - Ваше имя + + + {t('about.review-form.dialog.field.name')} + @@ -152,7 +152,9 @@ export function ReviewForm() { name='rating' render={({ field }) => ( - Ваша оценка + + {t('about.review-form.dialog.field.rating')} + ( - - Ваш отзыв + + + {t('about.review-form.dialog.field.reviewMessage')} +