diff --git a/app/[locale]/services/detail/page.tsx b/app/[locale]/services/detail/page.tsx index 5f9bcac..43985f7 100644 --- a/app/[locale]/services/detail/page.tsx +++ b/app/[locale]/services/detail/page.tsx @@ -9,19 +9,34 @@ import { SystemFeature, } from "@/lib/api/demoapi/operationalSystems"; import { Breadcrumb } from "@/components/breadCrumb"; +import { useServiceDetail } from "@/store/useService"; +import { useQuery } from "@tanstack/react-query"; +import httpClient from "@/request/api"; +import { endPoints } from "@/request/links"; export default function OperationalSystemsPage() { const t = useTranslations("operationalSystems"); - const [data, setData] = useState(null); - const [loading, setLoading] = useState(true); - const [error, setError] = useState(false); + const serviceId = useServiceDetail((state) => state.serviceId); + console.log("service id: ", serviceId); + + const { + data, + isLoading: loading, + isError: error, + } = useQuery({ + queryKey: ["firesafety", serviceId], + queryFn: () => httpClient(endPoints.services.detail(serviceId || 0)), + select: (data) => data?.data?.data, + }); + + console.log("service detail: ", data); // Demo data - fallback ma'lumotlar const demoData: SystemFeature[] = [ { id: "1", title: t("systems.sprinkler.title"), - shortDesc:t("systems.sprinkler.short-desc"), + shortDesc: t("systems.sprinkler.short-desc"), description: t("systems.sprinkler.description"), features: [ t("systems.sprinkler.features.0"), @@ -33,33 +48,6 @@ export default function OperationalSystemsPage() { }, ]; - const fetchData = async () => { - try { - setLoading(true); - setError(false); - - const result = await getOperationalSystems(); - - // Agar backend ma'lumot qaytarsa - if (result && result.length > 0) { - setData(result); - } else { - // Backend bo'sh ma'lumot qaytarsa, demo ma'lumotlarni ishlatamiz - setData(demoData); - } - } catch (err) { - setError(true); - // Xatolik bo'lsa, demo ma'lumotlarni ishlatamiz - setData(demoData); - } finally { - setLoading(false); - } - }; - - useEffect(() => { - fetchData(); - }, []); - // Animation variants const containerVariants = { hidden: { opacity: 0 }, @@ -128,14 +116,6 @@ export default function OperationalSystemsPage() { >
⚠️

{t("error")}

- - {t("retry")} - ); @@ -143,43 +123,12 @@ export default function OperationalSystemsPage() { return (
- {/* Header */} - {/* - -

- {t('title')} -

-

- {t('subtitle')} -

-
- - - Fire hose - -
*/}
{/* Main Content */} - {!data || data.length === 0 ? ( + {!data || data.legth === 0 ? ( - {data.map((system, index) => ( + + {/* Image Section */} - {/* Image Section */} - - {system.title} -
- - - {/* Content Section */} -
- - {system.title} - - - - {system.shortDesc} - - - - {system.description} - - -
- -
    - {system.features.map((feature, featureIndex) => ( - - - {feature} - - - ))} -
-
-
+ {data.title} +
- ))} + + {/* Content Section */} +
+ + {data.title} + + + + {data.subtitle} + + + + {data?.description} + + + {/*
+
    + {system.features.map((feature, featureIndex) => ( + + + {feature} + + + ))} +
+
*/} +
+ )}
diff --git a/components/pages/products/product/productCard.tsx b/components/pages/products/product/productCard.tsx index 91dc0cf..cef3714 100644 --- a/components/pages/products/product/productCard.tsx +++ b/components/pages/products/product/productCard.tsx @@ -33,7 +33,7 @@ export default function ProductCard({ {/* Content Container */}
-

+

{title}

diff --git a/components/pages/products/slug/rightSide.tsx b/components/pages/products/slug/rightSide.tsx index 99ed69b..9bb5c6c 100644 --- a/components/pages/products/slug/rightSide.tsx +++ b/components/pages/products/slug/rightSide.tsx @@ -1,6 +1,10 @@ +"use client"; + import { usePriceModalStore } from "@/store/useProceModalStore"; import { Instagram, Send, Share2 } from "lucide-react"; import { useTranslations } from "next-intl"; +import { useParams } from "next/navigation"; +import { useState } from "react"; interface RightSideProps { id: number; @@ -23,6 +27,45 @@ export function RightSide({ }: RightSideProps) { const openModal = usePriceModalStore((state) => state.openModal); const t = useTranslations(); + const params = useParams(); + const locale = params.locale || "uz"; + const [copied, setCopied] = useState(false); + + const handleShare = async () => { + const productUrl = `${window.location.origin}/${locale}/products/special_product?productId=${id}`; + + try { + // Modern Web Share API dan foydalanish (mobil qurilmalar uchun) + if (navigator.share) { + await navigator.share({ + title: title, + text: `${title} - ${description.slice(0, 100)}...`, + url: productUrl, + }); + } else { + // Desktop uchun clipboard ga copy qilish + await navigator.clipboard.writeText(productUrl); + setCopied(true); + + // 2 soniyadan keyin "Copied" holatini o'chirish + setTimeout(() => { + setCopied(false); + }, 2000); + } + } catch (error) { + console.error("Share error:", error); + // Fallback - clipboard ga copy qilish + try { + await navigator.clipboard.writeText(productUrl); + setCopied(true); + setTimeout(() => { + setCopied(false); + }, 2000); + } catch (clipboardError) { + console.error("Clipboard error:", clipboardError); + } + } + }; const handleGetPrice = () => { openModal({ @@ -54,7 +97,9 @@ export function RightSide({ {/* Status Badge */}
- + {status}
@@ -85,21 +130,25 @@ export function RightSide({ {/* Social Share */} -
-
- - {t("products.share")}: -
-
); -} \ No newline at end of file +} diff --git a/components/pages/services/ourService.tsx b/components/pages/services/ourService.tsx index 9b0825a..24637cd 100644 --- a/components/pages/services/ourService.tsx +++ b/components/pages/services/ourService.tsx @@ -1,4 +1,4 @@ -"use client" +"use client"; import DotAnimatsiya from "@/components/dot/DotAnimatsiya"; import httpClient from "@/request/api"; import { endPoints } from "@/request/links"; @@ -10,15 +10,18 @@ import Link from "next/link"; import { motion } from "framer-motion"; import { ServicesLoading } from "./loading"; import { EmptyServices } from "./empty"; +import { useServiceDetail } from "@/store/useService"; export function OurService() { const t = useTranslations(); const locale = useLocale(); + const setServiceId = useServiceDetail((state) => state.setServiceId); - // get request + // get request const { data, isLoading, isError } = useQuery({ - queryKey: ['firesafety'], - queryFn: () => httpClient(endPoints.services.all) + queryKey: ["firesafety"], + queryFn: () => httpClient(endPoints.services.all), + select: (data) => data?.data?.data?.results, }); console.log("service data: ", data); @@ -84,44 +87,52 @@ export function OurService() { animate="visible" > {/* cards */} -
- +
+ setServiceId(data[0].id)} + >

- {t("home.services.services.operation.title")} + {data[0].title}

- {t("home.services.services.operation.description")} + {data[0].subtitle}

images
- + setServiceId(data[1].id)} + variants={cardVariants} + className="sm:w-[45%] w-full" + >

- {t("home.services.services.suppression.title")} + {data[1].title}

- {t("home.services.services.suppression.description")} + {data[1].subtitle}

images
- + setServiceId(data[2].id)} + className="sm:w-[40%] w-full -mt-5" + > images

- {t("home.services.services.safety.title")} + {data[2].title}

- {t("home.services.services.safety.description")} + {data[2].subtitle}

images

{t("home.services.viewMoreServices")} @@ -203,4 +222,4 @@ export function OurService() {

); -} \ No newline at end of file +} diff --git a/components/pages/subCategory/card.tsx b/components/pages/subCategory/card.tsx index a4530cc..f65ed4a 100644 --- a/components/pages/subCategory/card.tsx +++ b/components/pages/subCategory/card.tsx @@ -50,7 +50,7 @@ export default function Card({ {/* Content Container */}
-

+

{title}

diff --git a/messages/en.json b/messages/en.json index 6f05adf..f992586 100644 --- a/messages/en.json +++ b/messages/en.json @@ -165,7 +165,8 @@ "send": "Send Message", "share": "Share", "features": "Features", - "feature": "Feature" + "feature": "Feature", + "copied": "Link copied!" }, "faq": { "banner": { diff --git a/messages/ru.json b/messages/ru.json index 6192aff..79728f9 100644 --- a/messages/ru.json +++ b/messages/ru.json @@ -165,7 +165,8 @@ "send": "Отправить сообщение", "share": "Поделиться", "features": "Характеристики", - "feature": "Характеристика" + "feature": "Характеристика", + "copied": "Ссылка скопирована!" }, "faq": { "banner": { diff --git a/messages/uz.json b/messages/uz.json index 704aa2b..1654f6a 100644 --- a/messages/uz.json +++ b/messages/uz.json @@ -146,9 +146,9 @@ } }, "products": { - "noData":{ - "title":"Katalog topilmadi", - "description":"Hozircha kategoriyalar mavjud emas. Keyinroq urinib ko'ring" + "noData": { + "title": "Katalog topilmadi", + "description": "Hozircha kategoriyalar mavjud emas. Keyinroq urinib ko'ring" }, "catalog": { "blockdescription": "Avtomatik yong‘in o‘chirish tizimlari va ichki yong‘inga qarshi suv ta’minoti uchun polipropilen quvurlar va fitinglar", @@ -161,11 +161,12 @@ "description": "Biz nafaqat uskunalar yetkazib beramiz, balki har bir mijozning muvaffaqiyatli hamkoriga aylanamiz." }, "ourproducts": "Bizning mahsulotlarimiz", - "price":"Narx", - "send":"Xabar yuborish", - "share":"Ulashish", - "features":"Xususiyatlar", - "feature":"Xususiyat" + "price": "Narx", + "send": "Xabar yuborish", + "share": "Ulashish", + "features": "Xususiyatlar", + "feature": "Xususiyat", + "copied": "Link nusxalandi!" }, "faq": { "banner": { @@ -233,8 +234,8 @@ }, "address": "Toshkent shahri , Yunusabod tumani , Niyozbek yo'li 3 tor ko'chasi , 39 uy", "create": "{name} - Jamoasi tomonidan ishlab chiqilgan", - "terms":"Foydalanish shartlari", - "privacy":"Maxfiylik siyosati" + "terms": "Foydalanish shartlari", + "privacy": "Maxfiylik siyosati" }, "operationalSystems": { "title": "Operatsion tizimlar", diff --git a/request/links.ts b/request/links.ts index e69c19a..2afd773 100644 --- a/request/links.ts +++ b/request/links.ts @@ -7,7 +7,7 @@ export const endPoints = { }, services: { all: "firesafety/", - detail: (id: number) => `/api/firesafety/${id}`, + detail: (id: number) => `firesafety/${id}`, }, product: { byCategory: (categoryId: number) => `product/?category=${categoryId}`,