From cfa84d04abb9ae14b964eadcd0fa99ede4ced830 Mon Sep 17 00:00:00 2001 From: "nabijonovdavronbek619@gmail.com" Date: Mon, 27 Apr 2026 12:29:17 +0500 Subject: [PATCH] new things --- app/[lang]/[carType]/[carDeatil]/page.tsx | 43 +++++++----- app/[lang]/layout.tsx | 5 +- components/lib_components/carRentalModal.tsx | 72 +++++++++++++++----- components/pageParts/contact.tsx | 6 +- public/locales/ru/common.json | 17 ++++- public/locales/uz/common.json | 17 ++++- 6 files changed, 117 insertions(+), 43 deletions(-) diff --git a/app/[lang]/[carType]/[carDeatil]/page.tsx b/app/[lang]/[carType]/[carDeatil]/page.tsx index 5e2e07b..b5082de 100644 --- a/app/[lang]/[carType]/[carDeatil]/page.tsx +++ b/app/[lang]/[carType]/[carDeatil]/page.tsx @@ -8,6 +8,7 @@ import { usePathname, useParams } from "next/navigation"; import { logoImg } from "@/assets"; import { useSubCategory } from "@/store/subCategory"; import { minimumValues } from "@/data/minimimValues"; +import { useTranslation } from "react-i18next"; import { LoadingSkeleton } from "@/components/loadingProduct"; import { EmptyState } from "@/components/emptyState"; import { ErrorState } from "@/components/errorState"; @@ -32,6 +33,7 @@ function checkCategory(categoryName: string | undefined, lang: string) { } export default function CarDetailPage() { + const { t } = useTranslation(); const [modalOpen, setModalOpen] = useState(false); const initialSubCategory = useSubCategory( @@ -107,7 +109,8 @@ export default function CarDetailPage() { ); } - const firstData = cars[0]; + const firstData = cars[0]?.data[0]; + console.log("First Data: ", firstData); if (!firstData) { return ( @@ -138,7 +141,7 @@ export default function CarDetailPage() { alt={firstData?.name ? firstData?.name : "image"} width={600} height={200} - className="rounded-lg object-cover border border-gray-200 w-full" + className="rounded-lg object-contain border border-gray-200 w-full" /> @@ -147,7 +150,9 @@ export default function CarDetailPage() {
{isMinimum ?

{text}

: } : - {firstData.price?.toLocaleString("uz-UZ")} + {firstData.price + ? Math.round(Number(firstData.price)).toLocaleString("ru-RU") + : ""}
@@ -181,22 +186,24 @@ export default function CarDetailPage() { {/* Texnik xususiyatlar */} -
-

- Texnik xususiyatlari -

-
- {firstData?.features.map((item: any) => ( -
-

{item?.name}:

-

{item?.value}

-
- ))} + {firstData?.features.length > 0 && ( +
+

+ {t("tech-features")} +

+
+ {firstData?.features?.map((item: any) => ( +
+

{item?.name}:

+

{item?.value}

+
+ ))} +
-
+ )} {/* Ijara modal */} +
@@ -29,7 +28,7 @@ export default async function LangLayout({
-
@@ -107,7 +140,7 @@ export default function CarRentalModal({
setUserName(e.target.value)} - placeholder="Ismingizni kiriting" + placeholder={t("modal-name-placeholder")} />
setPhone(e.target.value)} - placeholder="+998 90 123 45 67" + onChange={handlePhoneChange} + placeholder={t("modal-phone-placeholder")} /> + {phoneError && ( +

{phoneError}

+ )}
- Jami summa:{" "} + {t("modal-total")}{" "} - {total?.toLocaleString()} UZS + {total + ? Math.round(Number(total)).toLocaleString("ru-RU") + : ""} UZS
@@ -158,7 +196,7 @@ export default function CarRentalModal({ type="submit" className="w-full bg-secondary text-white py-2 rounded-lg hover:bg-primary transition font-medium" > - Buyurtma berish + {t("book")}
diff --git a/components/pageParts/contact.tsx b/components/pageParts/contact.tsx index b96169d..2afb608 100644 --- a/components/pageParts/contact.tsx +++ b/components/pageParts/contact.tsx @@ -53,7 +53,7 @@ export default function Contact() { event.preventDefault(); if (!phone || !isValidPhone(phone)) { - alert("Iltimos, telefon raqamingizni to'g'ri kiriting!"); + alert(t("contact-phone-error")); return; } @@ -77,11 +77,11 @@ export default function Contact() { text: message, }); - alert("✅ Muvaffaqiyatli yuborildi!"); + alert(t("contact-success")); setPhone(""); } catch (error) { console.error("Yuborishda xatolik:", error); - alert("❌ Yuborishda xatolik yuz berdi!"); + alert(t("contact-error")); } }; diff --git a/public/locales/ru/common.json b/public/locales/ru/common.json index 980427e..281e9cf 100644 --- a/public/locales/ru/common.json +++ b/public/locales/ru/common.json @@ -188,5 +188,20 @@ "retry": "Повторить", "downloadError": "Ошибка при загрузке данных", "noData": "Специальная техника не найдена", - "noDataDesc": "На данный момент товары отсутствуют. Пожалуйста, попробуйте позже." + "noDataDesc": "На данный момент товары отсутствуют. Пожалуйста, попробуйте позже.", + "tech-features": "Технические характеристики", + "modal-fill-required": "Пожалуйста, заполните все поля!", + "modal-phone-error": "Введите полный номер телефона: +998 XX XXX XX XX", + "modal-success": "Ваш заказ успешно отправлен!", + "modal-error": "Произошла ошибка. Попробуйте ещё раз!", + "modal-hourly-price": "Почасовая цена:", + "modal-name-label": "Ваше имя", + "modal-name-placeholder": "Введите ваше имя", + "modal-phone-label": "Телефон", + "modal-phone-placeholder": "+998 90 123 45 67", + "modal-hours-label": "Количество часов", + "modal-total": "Итоговая сумма:", + "contact-phone-error": "Пожалуйста, введите правильный номер телефона!", + "contact-success": "Успешно отправлено!", + "contact-error": "Произошла ошибка при отправке!" } diff --git a/public/locales/uz/common.json b/public/locales/uz/common.json index 408485a..2065395 100644 --- a/public/locales/uz/common.json +++ b/public/locales/uz/common.json @@ -188,5 +188,20 @@ "retry": "Qayta urinish", "downloadError": "Ma'lumotlarni yuklashda xatolik", "noData": "Mahsus texnikalar topilmadi", - "noDataDesc": "Hozircha mahsulotlar mavjud emas. Iltimos, keyinroq qayta urinib ko'ring." + "noDataDesc": "Hozircha mahsulotlar mavjud emas. Iltimos, keyinroq qayta urinib ko'ring.", + "tech-features": "Texnik xususiyatlari", + "modal-fill-required": "Iltimos, barcha maydonlarni to'ldiring!", + "modal-phone-error": "Telefon raqamini to'liq kiriting: +998 XX XXX XX XX", + "modal-success": "Buyurtmangiz muvaffaqiyatli yuborildi!", + "modal-error": "Xatolik yuz berdi. Qayta urinib ko'ring!", + "modal-hourly-price": "Soatlik narx:", + "modal-name-label": "Ismingiz", + "modal-name-placeholder": "Ismingizni kiriting", + "modal-phone-label": "Telefon", + "modal-phone-placeholder": "+998 90 123 45 67", + "modal-hours-label": "Qancha vaqt (soat)", + "modal-total": "Jami summa:", + "contact-phone-error": "Iltimos, telefon raqamingizni to'g'ri kiriting!", + "contact-success": "Muvaffaqiyatli yuborildi!", + "contact-error": "Yuborishda xatolik yuz berdi!" }