"use client"; import { usePriceModalStore } from "@/zustand/useProceModalStore"; import { Check, Instagram, Send, Share2 } from "lucide-react"; import { useTranslations } from "next-intl"; import { useParams } from "next/navigation"; import { useState } from "react"; interface RightSideProps { id: number; title: string; articular: string; status: string; description: string; price: string; image: string; } export function RightSide({ title, articular, status, description, price, id, image, }: 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}/catalog_page/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({ id, name: title, image, inStock: status === "Sotuvda mavjud", }); }; // Status color logic const isInStock = status === "Sotuvda mavjud"; const statusColor = isInStock ? "bg-green-600/20 text-green-400 border border-green-600/30" : "bg-red-600/20 text-red-400 border border-red-600/30"; return (
{/* Title */}

{title}

{/* Article ID */}
Artikul: {articular}
{/* Status Badge */}
{status}
{/* Description */}

{description}

{/* Price Section */}
{/* Action Button */} {/* Social Share */}
); }