detail page connected to backend , modal form for one product connected to backend
This commit is contained in:
@@ -1,40 +1,87 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { DATA } from "@/lib/demoData";
|
|
||||||
import { Features, RightSide, SliderComp } from "@/components/pages/products";
|
import { Features, RightSide, SliderComp } from "@/components/pages/products";
|
||||||
|
import { useProductPageInfo } from "@/store/useProduct";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import httpClient from "@/request/api";
|
||||||
|
import { endPoints } from "@/request/links";
|
||||||
|
import { AlertCircle } from "lucide-react";
|
||||||
|
import { LoadingSkeleton } from "@/components/pages/products/slug/loading";
|
||||||
|
import { EmptyState } from "@/components/pages/products/slug/empty";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
|
// Types
|
||||||
|
interface ProductImage {
|
||||||
|
id: number;
|
||||||
|
product: number;
|
||||||
|
image: string;
|
||||||
|
is_main: boolean;
|
||||||
|
order: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ProductDetail {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
articular: string;
|
||||||
|
status: string;
|
||||||
|
description: string;
|
||||||
|
size: number;
|
||||||
|
price: string;
|
||||||
|
features: string[];
|
||||||
|
images: ProductImage[];
|
||||||
|
}
|
||||||
|
|
||||||
export default function SlugPage() {
|
export default function SlugPage() {
|
||||||
const statusColor =
|
const productZustand = useProductPageInfo((state) => state.product);
|
||||||
DATA[0].status === "full"
|
|
||||||
? "text-green-500"
|
|
||||||
: DATA[0].status === "empty"
|
|
||||||
? "text-red-600"
|
|
||||||
: "text-yellow-800";
|
|
||||||
|
|
||||||
const statusText =
|
const { data: product, isLoading } = useQuery({
|
||||||
DATA[0].status === "full"
|
queryKey: ["product", productZustand.id],
|
||||||
? "Sotuvda mavjud"
|
queryFn: () => httpClient(endPoints.product.detail(productZustand.id)),
|
||||||
: DATA[0].status === "empty"
|
select: (data) => data?.data?.data as ProductDetail,
|
||||||
? "Sotuvda qolmagan"
|
enabled: !!productZustand.id,
|
||||||
: "Buyurtma asosida";
|
});
|
||||||
|
|
||||||
|
useEffect(()=>console.log("product detail: ",product))
|
||||||
|
|
||||||
|
// Loading State
|
||||||
|
if (isLoading) {
|
||||||
|
return <LoadingSkeleton />;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empty State
|
||||||
|
if (!product) {
|
||||||
|
return <EmptyState />;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract images
|
||||||
|
const productImages = product.images?.map((img) => img.image) || [];
|
||||||
|
const mainImage = product.images?.find((img) => img.is_main)?.image || productImages[0] || "";
|
||||||
|
const features = product.features.map((item:any)=>item.name)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-[#1e1d1c] py-40 px-4 md:px-8">
|
<div className="min-h-screen bg-[#1e1d1c] py-20 md:py-32 lg:py-40 px-4 md:px-8">
|
||||||
<div className="max-w-6xl mx-auto">
|
<div className="max-w-7xl mx-auto">
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 md:gap-12">
|
{/* Main Product Section */}
|
||||||
<SliderComp imgs={DATA[0].images} />
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8 lg:gap-12 mb-12">
|
||||||
|
{/* Left - Image Slider */}
|
||||||
|
<SliderComp imgs={productImages} />
|
||||||
|
|
||||||
|
{/* Right - Product Info */}
|
||||||
<RightSide
|
<RightSide
|
||||||
id={1}
|
id={product.id}
|
||||||
title={DATA[0].title}
|
title={product.name}
|
||||||
name={DATA[0].name}
|
articular={product.articular}
|
||||||
statusColor={statusColor}
|
status={product.status}
|
||||||
statusText={statusText}
|
description={product.description}
|
||||||
description={DATA[0].description}
|
price={product.price}
|
||||||
image={DATA[0].images[0]}
|
image={mainImage}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Features features={DATA[0].features} />
|
|
||||||
|
{/* Features Section */}
|
||||||
|
{product.features && product.features.length > 0 && (
|
||||||
|
<Features features={features} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,9 +16,6 @@ export default function Catalog() {
|
|||||||
queryFn: () => httpClient(endPoints.category.all),
|
queryFn: () => httpClient(endPoints.category.all),
|
||||||
select: (data): CategoryType[] => data?.data?.results,
|
select: (data): CategoryType[] => data?.data?.results,
|
||||||
});
|
});
|
||||||
useEffect(() => {
|
|
||||||
console.log("product catalog data: ", data);
|
|
||||||
}, [data]);
|
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ export default function Filter() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
catalog && setCatalogData(catalog);
|
catalog && setCatalogData(catalog);
|
||||||
size && setSizeData(size);
|
size && setSizeData(size);
|
||||||
console.log("catalog: ", catalog, "size: ", size);
|
|
||||||
}, [size, catalog]);
|
}, [size, catalog]);
|
||||||
|
|
||||||
// Bo'lim uchun ko'rsatiladigan itemlar
|
// Bo'lim uchun ko'rsatiladigan itemlar
|
||||||
@@ -67,7 +66,6 @@ export default function Filter() {
|
|||||||
const visibleSectionNumber = numberExpanded
|
const visibleSectionNumber = numberExpanded
|
||||||
? sizeData
|
? sizeData
|
||||||
: sizeData.slice(0, 10);
|
: sizeData.slice(0, 10);
|
||||||
console.log("filter: ", filter);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3 lg:max-w-70 lg:px-0 px-3 w-full text-white">
|
<div className="space-y-3 lg:max-w-70 lg:px-0 px-3 w-full text-white">
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ import { useQuery } from "@tanstack/react-query";
|
|||||||
import ProductCard from "./productCard";
|
import ProductCard from "./productCard";
|
||||||
import { useCategory } from "@/store/useCategory";
|
import { useCategory } from "@/store/useCategory";
|
||||||
import { useFilter } from "@/lib/filter-zustand";
|
import { useFilter } from "@/lib/filter-zustand";
|
||||||
import { useMemo } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
|
import { useProductPageInfo } from "@/store/useProduct";
|
||||||
|
|
||||||
export default function MainProduct() {
|
export default function MainProduct() {
|
||||||
const category = useCategory((state) => state.category);
|
const category = useCategory((state) => state.category);
|
||||||
const filter = useFilter((state) => state.filter);
|
const filter = useFilter((state) => state.filter);
|
||||||
const getFiltersByType = useFilter((state)=>state.getFiltersByType)
|
const getFiltersByType = useFilter((state) => state.getFiltersByType);
|
||||||
|
const setProduct = useProductPageInfo((state) => state.setProducts);
|
||||||
|
|
||||||
// Query params yaratish
|
// Query params yaratish
|
||||||
const queryParams = useMemo(() => {
|
const queryParams = useMemo(() => {
|
||||||
@@ -38,11 +40,19 @@ export default function MainProduct() {
|
|||||||
}, [category.id, category.have_sub_category, queryParams]);
|
}, [category.id, category.have_sub_category, queryParams]);
|
||||||
|
|
||||||
const { data, isLoading, error } = useQuery({
|
const { data, isLoading, error } = useQuery({
|
||||||
queryKey: ["products", category.id , queryParams],
|
queryKey: ["products", category.id, queryParams],
|
||||||
queryFn: () => httpClient(requestLink),
|
queryFn: () => httpClient(requestLink),
|
||||||
select: (data) => data?.data?.data?.results,
|
select: (data) => {
|
||||||
|
const product = data?.data?.data?.results;
|
||||||
|
return product.map((item: any) => ({
|
||||||
|
id: item.id,
|
||||||
|
name: item.name,
|
||||||
|
image: item.images[0].image,
|
||||||
|
}));
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-5">
|
<div className="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-5">
|
||||||
@@ -74,6 +84,7 @@ export default function MainProduct() {
|
|||||||
{data.map((item: any) => (
|
{data.map((item: any) => (
|
||||||
<ProductCard
|
<ProductCard
|
||||||
key={item.id} // ✅ index o'rniga id ishlatish
|
key={item.id} // ✅ index o'rniga id ishlatish
|
||||||
|
getProduct={() => setProduct(item)}
|
||||||
title={item.name}
|
title={item.name}
|
||||||
image={item.image}
|
image={item.image}
|
||||||
slug={item.slug}
|
slug={item.slug}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import { useLocale } from "next-intl";
|
import { useLocale } from "next-intl";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
@@ -7,17 +6,19 @@ interface ProductCardProps {
|
|||||||
title: string;
|
title: string;
|
||||||
image: string;
|
image: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
|
getProduct: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ProductCard({
|
export default function ProductCard({
|
||||||
title,
|
title,
|
||||||
image,
|
image,
|
||||||
slug,
|
slug,
|
||||||
|
getProduct,
|
||||||
}: ProductCardProps) {
|
}: ProductCardProps) {
|
||||||
const locale = useLocale();
|
const locale = useLocale();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link href={`/${locale}/products/${slug}`}>
|
<Link href={`/${locale}/products/${slug}`} onClick={getProduct}>
|
||||||
<article className="group transition-all duration-300 hover:cursor-pointer max-sm:max-w-100 max-sm:mx-auto max-sm:w-full">
|
<article className="group transition-all duration-300 hover:cursor-pointer max-sm:max-w-100 max-sm:mx-auto max-sm:w-full">
|
||||||
{/* Image Container */}
|
{/* Image Container */}
|
||||||
<div className="relative rounded-2xl h-45 sm:h-55 md:h-65 lg:w-[95%] w-[90%] mx-auto overflow-hidden">
|
<div className="relative rounded-2xl h-45 sm:h-55 md:h-65 lg:w-[95%] w-[90%] mx-auto overflow-hidden">
|
||||||
|
|||||||
36
components/pages/products/slug/empty.tsx
Normal file
36
components/pages/products/slug/empty.tsx
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
// Empty State Component
|
||||||
|
export function EmptyState() {
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen bg-[#1e1d1c] flex items-center justify-center px-4">
|
||||||
|
<div className="text-center max-w-md">
|
||||||
|
<div className="w-24 h-24 mx-auto mb-6 bg-gray-800 rounded-full flex items-center justify-center">
|
||||||
|
<svg
|
||||||
|
className="w-12 h-12 text-gray-600"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeWidth={2}
|
||||||
|
d="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<h2 className="text-2xl font-bold text-white mb-2">
|
||||||
|
Mahsulot topilmadi
|
||||||
|
</h2>
|
||||||
|
<p className="text-gray-400 mb-6">
|
||||||
|
Siz qidirayotgan mahsulot mavjud emas yoki o'chirilgan
|
||||||
|
</p>
|
||||||
|
<a
|
||||||
|
href="/products"
|
||||||
|
className="inline-block bg-red-700 hover:bg-red-800 text-white font-bold py-3 px-6 rounded-lg transition"
|
||||||
|
>
|
||||||
|
Mahsulotlarga qaytish
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,10 +1,19 @@
|
|||||||
export function Features({ features }: { features: string[] }) {
|
export function Features({ features }: { features: string[] }) {
|
||||||
|
if (!features || features.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<table className="w-full rounded-xl overflow-hidden">
|
<div className="mt-12">
|
||||||
|
<h2 className="text-2xl md:text-3xl font-bold text-white mb-6">
|
||||||
|
Xususiyatlar
|
||||||
|
</h2>
|
||||||
|
<div className="rounded-xl overflow-hidden border border-gray-800 shadow-xl">
|
||||||
|
<table className="w-full">
|
||||||
<thead>
|
<thead>
|
||||||
<tr className="border-b border-gray-700 bg-black">
|
<tr className="bg-linear-to-r from-gray-900 to-black border-b border-gray-800">
|
||||||
<th className="px-4 py-4 md:px-6 text-left text-sm md:text-base font-semibold text-white">
|
<th className="px-4 py-4 md:px-6 text-left text-sm md:text-base font-semibold text-white">
|
||||||
Feature
|
Xususiyat
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -12,16 +21,21 @@ export function Features({ features }: { features: string[] }) {
|
|||||||
{features.map((feature, index) => (
|
{features.map((feature, index) => (
|
||||||
<tr
|
<tr
|
||||||
key={index}
|
key={index}
|
||||||
className={` border-gray-700 transition-colors hover:bg-opacity-80 ${
|
className={`border-b border-gray-800 last:border-b-0 transition-colors hover:bg-red-900/10 ${
|
||||||
index % 2 === 0 ? "bg-[#323232]" : "bg-black/20"
|
index % 2 === 0 ? "bg-[#252525]" : "bg-[#1e1e1e]"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<td className="px-4 py-4 md:px-6 text-sm md:text-base text-white font-medium">
|
<td className="px-4 py-4 md:px-6 text-sm md:text-base text-gray-300">
|
||||||
{feature}
|
<div className="flex items-start gap-3">
|
||||||
|
<span className="text-red-700 mt-1">•</span>
|
||||||
|
<span>{feature}</span>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
61
components/pages/products/slug/loading.tsx
Normal file
61
components/pages/products/slug/loading.tsx
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
// Loading Skeleton Component
|
||||||
|
export function LoadingSkeleton() {
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen bg-[#1e1d1c] py-20 md:py-32 lg:py-40 px-4 md:px-8">
|
||||||
|
<div className="max-w-7xl mx-auto">
|
||||||
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8 lg:gap-12 mb-12">
|
||||||
|
{/* Image Skeleton */}
|
||||||
|
<div className="w-full h-96 md:h-125 bg-gray-800 rounded-lg animate-pulse" />
|
||||||
|
|
||||||
|
{/* Info Skeleton */}
|
||||||
|
<div className="flex flex-col justify-center space-y-4">
|
||||||
|
{/* Title */}
|
||||||
|
<div className="h-8 bg-gray-800 rounded animate-pulse w-3/4" />
|
||||||
|
|
||||||
|
{/* Articular */}
|
||||||
|
<div className="h-6 bg-gray-800 rounded animate-pulse w-1/2" />
|
||||||
|
|
||||||
|
{/* Status */}
|
||||||
|
<div className="h-8 bg-gray-800 rounded animate-pulse w-1/3" />
|
||||||
|
|
||||||
|
{/* Description */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="h-4 bg-gray-800 rounded animate-pulse w-full" />
|
||||||
|
<div className="h-4 bg-gray-800 rounded animate-pulse w-5/6" />
|
||||||
|
<div className="h-4 bg-gray-800 rounded animate-pulse w-4/6" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Price */}
|
||||||
|
<div className="h-10 bg-gray-800 rounded animate-pulse w-32" />
|
||||||
|
|
||||||
|
{/* Buttons */}
|
||||||
|
<div className="flex gap-4">
|
||||||
|
<div className="h-12 bg-gray-800 rounded animate-pulse flex-1" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Social */}
|
||||||
|
<div className="flex gap-2">
|
||||||
|
{[1, 2, 3, 4, 5, 6].map((i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="w-10 h-10 bg-gray-800 rounded-lg animate-pulse"
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Features Skeleton */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="h-12 bg-gray-800 rounded-t-xl animate-pulse" />
|
||||||
|
{[1, 2, 3, 4].map((i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="h-16 bg-gray-800/50 rounded animate-pulse"
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,116 +1,106 @@
|
|||||||
import { usePriceModalStore } from "@/store/useProceModalStore";
|
import { usePriceModalStore } from "@/store/useProceModalStore";
|
||||||
import { Facebook } from "lucide-react";
|
import { Facebook, Share2 } from "lucide-react";
|
||||||
|
|
||||||
const socialLinks = [
|
const socialLinks = [
|
||||||
{ name: "telegram", icon: "✈️", color: "#0088cc" },
|
{ name: "telegram", icon: "✈️", color: "#0088cc" },
|
||||||
{ name: "facebook", icon: <Facebook />, color: "#1877F2" },
|
{ name: "facebook", icon: <Facebook size={18} />, color: "#1877F2" },
|
||||||
{ name: "odnoklassniki", icon: "ok", color: "#ED7100" },
|
{ name: "whatsapp", icon: "💬", color: "#25D366" },
|
||||||
{ name: "vkontakte", icon: "VK", color: "#0077FF" },
|
|
||||||
{ name: "twitter", icon: "𝕏", color: "#1DA1F2" },
|
{ name: "twitter", icon: "𝕏", color: "#1DA1F2" },
|
||||||
{ name: "whatsapp", icon: "W", color: "#25D366" },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
interface RightSideProps {
|
interface RightSideProps {
|
||||||
id: number;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
name: string;
|
articular: string;
|
||||||
|
status: string;
|
||||||
description: string;
|
description: string;
|
||||||
statusText: string;
|
price: string;
|
||||||
statusColor: string;
|
|
||||||
image: string;
|
image: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RightSide({
|
export function RightSide({
|
||||||
title,
|
title,
|
||||||
name,
|
articular,
|
||||||
|
status,
|
||||||
description,
|
description,
|
||||||
statusColor,
|
price,
|
||||||
statusText,
|
|
||||||
id,
|
id,
|
||||||
image,
|
image,
|
||||||
}: RightSideProps) {
|
}: RightSideProps) {
|
||||||
const openModal = usePriceModalStore((state) => state.openModal);
|
const openModal = usePriceModalStore((state) => state.openModal);
|
||||||
|
|
||||||
const handleGetPrice = () => {
|
const handleGetPrice = () => {
|
||||||
openModal({
|
openModal({
|
||||||
id: id,
|
id,
|
||||||
name: title,
|
name: title,
|
||||||
image: image,
|
image,
|
||||||
inStock: true,
|
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 (
|
return (
|
||||||
<div className="flex flex-col justify-center">
|
<div className="flex flex-col justify-center space-y-6">
|
||||||
{/* Title */}
|
{/* Title */}
|
||||||
<h1 className="text-xl md:text-2xl lg:text-3xl font-bold text-white mb-4 leading-tight">
|
<h1 className="text-2xl md:text-3xl lg:text-4xl font-bold text-white leading-tight">
|
||||||
{title}
|
{title}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
{/* Article ID */}
|
{/* Article ID */}
|
||||||
<div className="mb-3">
|
<div className="flex items-center gap-2 text-sm md:text-base">
|
||||||
<p className="text-gray-400">
|
<span className="text-gray-400">Artikul:</span>
|
||||||
Artikul:
|
<span className="text-white font-semibold">{articular}</span>
|
||||||
<span className="text-white font-semibold">{name}</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Status Badge */}
|
{/* Status Badge */}
|
||||||
<div className="mb-2">
|
<div>
|
||||||
<span
|
<span className={`inline-block px-4 py-2 rounded-lg text-sm font-semibold ${statusColor}`}>
|
||||||
className={`inline-block py-2 rounded text-sm font-semibold ${statusColor}`}
|
{status}
|
||||||
>
|
|
||||||
{statusText}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* description */}
|
{/* Description */}
|
||||||
<div className="mb-2">
|
<div className="border-l-4 border-red-700 pl-4">
|
||||||
<p className="text-sm font-bold text-white mb-4 leading-tight">
|
<p className="text-sm md:text-base text-gray-300 leading-relaxed">
|
||||||
{description}
|
{description}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Price Section */}
|
{/* Price Section */}
|
||||||
<div className="mb-8">
|
<div className="bg-[#1716169f] rounded-xl p-6 space-y-6">
|
||||||
<h2 className="text-2xl md:text-3xl font-bold text-red-700 mb-6">
|
{/* Price */}
|
||||||
17.00$
|
<div>
|
||||||
|
<p className="text-gray-400 text-sm mb-2">Narx:</p>
|
||||||
|
<h2 className="text-3xl md:text-4xl font-bold text-red-700">
|
||||||
|
${price}
|
||||||
</h2>
|
</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Action Buttons */}
|
{/* Action Button */}
|
||||||
<div className="flex flex-col sm:flex-row gap-4 mb-6">
|
|
||||||
{/* <button
|
|
||||||
onClick={onPriceClick}
|
|
||||||
className="flex-1 bg-red-700 hover:bg-red-800 text-white font-bold py-3 px-6 rounded-lg transition duration-300 transform hover:scale-105"
|
|
||||||
>
|
|
||||||
Narxni bilish
|
|
||||||
</button> */}
|
|
||||||
<button
|
<button
|
||||||
onClick={handleGetPrice}
|
onClick={handleGetPrice}
|
||||||
className="flex-1 border-2 border-red-700 text-red-700 hover:bg-red-50 font-bold py-3 px-6 rounded-lg transition duration-300"
|
className="w-full bg-red-700 hover:bg-red-800 text-white font-bold py-4 px-6 rounded-lg transition-all duration-300 transform hover:scale-105 hover:shadow-lg hover:shadow-red-700/50"
|
||||||
>
|
>
|
||||||
Xabar yuborish
|
Xabar yuborish
|
||||||
</button>
|
</button>
|
||||||
{/* <button
|
|
||||||
onClick={() => setIsFavorite(!isFavorite)}
|
|
||||||
className="p-3 border-2 border-gray-600 rounded-lg hover:border-red-700 transition duration-300"
|
|
||||||
title="Add to favorites"
|
|
||||||
>
|
|
||||||
<Heart
|
|
||||||
size={24}
|
|
||||||
className={
|
|
||||||
isFavorite ? "fill-red-700 text-red-700" : "text-gray-600"
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</button> */}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Social Share Icons */}
|
{/* Social Share */}
|
||||||
<div className="flex gap-3 items-center">
|
<div className="pt-4 border-t border-gray-800">
|
||||||
<div className="flex gap-2">
|
<div className="flex items-center gap-3 mb-3">
|
||||||
|
<Share2 className="w-5 h-5 text-gray-400" />
|
||||||
|
<span className="text-sm text-gray-400">Ulashish:</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
{socialLinks.map((social) => (
|
{socialLinks.map((social) => (
|
||||||
<a
|
<a
|
||||||
key={social.name}
|
key={social.name}
|
||||||
href="#"
|
href="#"
|
||||||
className="w-10 h-10 rounded-lg flex items-center justify-center text-white text-sm font-bold transition duration-300 hover:scale-110"
|
className="w-10 h-10 rounded-lg flex items-center justify-center text-white text-sm font-bold transition-all duration-300 hover:scale-110 hover:shadow-lg"
|
||||||
style={{ backgroundColor: social.color }}
|
style={{ backgroundColor: social.color }}
|
||||||
title={social.name}
|
title={social.name}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,60 +1,133 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { Swiper, SwiperSlide } from "swiper/react";
|
import { Swiper, SwiperSlide } from "swiper/react";
|
||||||
import { Navigation } from "swiper/modules";
|
import { Navigation, Pagination, Thumbs } from "swiper/modules";
|
||||||
|
import { useState } from "react";
|
||||||
|
import type { Swiper as SwiperType } from "swiper";
|
||||||
import "swiper/css";
|
import "swiper/css";
|
||||||
import "swiper/css/navigation";
|
import "swiper/css/navigation";
|
||||||
import { DATA } from "@/lib/demoData";
|
import "swiper/css/pagination";
|
||||||
|
import "swiper/css/thumbs";
|
||||||
|
import Image from "next/image";
|
||||||
|
|
||||||
// The custom CSS selectors for navigation
|
|
||||||
const navigationPrevEl = ".custom-swiper-prev";
|
const navigationPrevEl = ".custom-swiper-prev";
|
||||||
const navigationNextEl = ".custom-swiper-next";
|
const navigationNextEl = ".custom-swiper-next";
|
||||||
|
|
||||||
export function SliderComp({ imgs }: { imgs: string[] }) {
|
export function SliderComp({ imgs }: { imgs: string[] }) {
|
||||||
|
const [thumbsSwiper, setThumbsSwiper] = useState<SwiperType | null>(null);
|
||||||
|
|
||||||
|
// Agar rasm bo'lmasa
|
||||||
|
if (!imgs || imgs.length === 0) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="w-full h-96 md:h-125 bg-gray-800 rounded-lg flex items-center justify-center">
|
||||||
<div className="flex items-center justify-center relative">
|
<div className="text-center">
|
||||||
|
<svg
|
||||||
|
className="w-20 h-20 text-gray-600 mx-auto mb-4"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeWidth={2}
|
||||||
|
d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<p className="text-gray-500">Rasm mavjud emas</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
{/* Main Slider */}
|
||||||
|
<div className="relative group">
|
||||||
<Swiper
|
<Swiper
|
||||||
modules={[Navigation]}
|
modules={[Navigation, Pagination, Thumbs]}
|
||||||
|
thumbs={{ swiper: thumbsSwiper && !thumbsSwiper.destroyed ? thumbsSwiper : null }}
|
||||||
navigation={{
|
navigation={{
|
||||||
// Pass the class selectors here
|
|
||||||
prevEl: navigationPrevEl,
|
prevEl: navigationPrevEl,
|
||||||
nextEl: navigationNextEl,
|
nextEl: navigationNextEl,
|
||||||
}}
|
}}
|
||||||
pagination={{ clickable: true }}
|
pagination={{ clickable: true }}
|
||||||
className="w-full h-96 md:h-125 bg-white rounded-lg overflow-hidden shadow-lg"
|
loop={imgs.length > 1}
|
||||||
|
className="w-[90%] h-96 md:h-96 rounded-lg overflow-hidden shadow-xl"
|
||||||
>
|
>
|
||||||
{imgs.map((image, index) => (
|
{imgs.map((image, index) => (
|
||||||
<SwiperSlide
|
<SwiperSlide
|
||||||
key={index}
|
key={index}
|
||||||
className="bg-white flex items-center justify-center"
|
className=" flex items-center justify-center"
|
||||||
>
|
>
|
||||||
<img
|
<div className="relative w-full h-full p-4 md:p-8">
|
||||||
src={image || "/placeholder.svg"}
|
<Image
|
||||||
alt={`${DATA[0].title} - ${index + 1}`}
|
src={image}
|
||||||
className="w-full h-full object-contain p-4"
|
alt={`Product image ${index + 1}`}
|
||||||
|
fill
|
||||||
|
className="object-contain"
|
||||||
|
sizes="(max-width: 768px) 100vw, 50vw"
|
||||||
|
priority={index === 0}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</SwiperSlide>
|
</SwiperSlide>
|
||||||
))}
|
))}
|
||||||
</Swiper>
|
</Swiper>
|
||||||
{/* Custom buttons */}
|
|
||||||
|
{/* Navigation Buttons */}
|
||||||
|
{imgs.length > 1 && (
|
||||||
|
<>
|
||||||
<button
|
<button
|
||||||
className={`${navigationPrevEl.replace(
|
className={`${navigationPrevEl.replace(
|
||||||
".",
|
".",
|
||||||
"",
|
""
|
||||||
)} absolute z-10 top-1/2 left-5 rounded-sm pb-2 w-8 h-8 bg-primary text-[30px] text-center
|
)} absolute z-10 top-1/2 -translate-y-1/2 left-2 md:left-4 rounded-lg w-10 h-10 md:w-12 md:h-12 bg-red-700/90 hover:bg-red-800 text-white flex items-center justify-center transition opacity-0 group-hover:opacity-100 shadow-lg`}
|
||||||
text-white flex items-center justify-center hover:cursor-pointer transition`}
|
|
||||||
>
|
>
|
||||||
‹
|
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 19l-7-7 7-7" />
|
||||||
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`${navigationNextEl.replace(
|
className={`${navigationNextEl.replace(
|
||||||
".",
|
".",
|
||||||
"",
|
""
|
||||||
)} absolute z-10 top-1/2 right-5 rounded-sm pb-2 w-8 h-8 bg-primary text-[30px] text-center text-white flex items-center justify-center hover:cursor-pointer transition `}
|
)} absolute z-10 top-1/2 -translate-y-1/2 right-2 md:right-4 rounded-lg w-10 h-10 md:w-12 md:h-12 bg-red-700/90 hover:bg-red-800 text-white flex items-center justify-center transition opacity-0 group-hover:opacity-100 shadow-lg`}
|
||||||
>
|
>
|
||||||
›
|
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
|
||||||
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Thumbnail Slider */}
|
||||||
|
{imgs.length > 1 && (
|
||||||
|
<Swiper
|
||||||
|
onSwiper={setThumbsSwiper}
|
||||||
|
spaceBetween={10}
|
||||||
|
slidesPerView={4}
|
||||||
|
breakpoints={{
|
||||||
|
640: { slidesPerView: 5 },
|
||||||
|
768: { slidesPerView: 6 },
|
||||||
|
}}
|
||||||
|
watchSlidesProgress
|
||||||
|
className="w-full"
|
||||||
|
>
|
||||||
|
{imgs.map((image, index) => (
|
||||||
|
<SwiperSlide key={index}>
|
||||||
|
<div className="relative h-20 md:h-24 bg-white rounded-lg overflow-hidden cursor-pointer border-2 border-transparent hover:border-red-700 transition">
|
||||||
|
<Image
|
||||||
|
src={image}
|
||||||
|
alt={`Thumbnail ${index + 1}`}
|
||||||
|
fill
|
||||||
|
className="object-contain p-2"
|
||||||
|
sizes="100px"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</SwiperSlide>
|
||||||
|
))}
|
||||||
|
</Swiper>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,19 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { X } from "lucide-react";
|
import { X } from "lucide-react";
|
||||||
import { usePriceModalStore } from "@/store/useProceModalStore";
|
import { usePriceModalStore } from "@/store/useProceModalStore";
|
||||||
|
import { useMutation } from "@tanstack/react-query";
|
||||||
|
import httpClient from "@/request/api";
|
||||||
|
import { endPoints } from "@/request/links";
|
||||||
|
import { toast } from "react-toastify";
|
||||||
|
|
||||||
|
interface FormType {
|
||||||
|
name: string;
|
||||||
|
product: number;
|
||||||
|
phone: number; // ✅ String bo'lishi kerak
|
||||||
|
}
|
||||||
|
|
||||||
export function PriceModal() {
|
export function PriceModal() {
|
||||||
const t = useTranslations("priceModal");
|
const t = useTranslations("priceModal");
|
||||||
@@ -13,31 +22,41 @@ export function PriceModal() {
|
|||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
name: "",
|
name: "",
|
||||||
phone: "+998 ",
|
phone: "+998 ",
|
||||||
captcha: "",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [errors, setErrors] = useState({
|
const [errors, setErrors] = useState({
|
||||||
name: "",
|
name: "",
|
||||||
phone: "",
|
phone: "",
|
||||||
captcha: "",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [captchaCode, setCaptchaCode] = useState("");
|
const formRequest = useMutation({
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
mutationFn: (data: FormType) =>
|
||||||
|
httpClient.post(endPoints.post.productContact, data),
|
||||||
// Generate random captcha
|
onSuccess: () => {
|
||||||
useEffect(() => {
|
setFormData({
|
||||||
if (isOpen) {
|
name: "",
|
||||||
const code = Math.random().toString(36).substring(2, 8).toUpperCase();
|
phone: "+998 ",
|
||||||
setCaptchaCode(code);
|
});
|
||||||
}
|
toast.success(t("success") || "Muvaffaqiyatli yuborildi!");
|
||||||
}, [isOpen]);
|
closeModal();
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error("Error:", error);
|
||||||
|
toast.error(t("error") || "Xatolik yuz berdi");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// Reset form when modal closes
|
// Reset form when modal closes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
setFormData({ name: "", phone: "+998 ", captcha: "" });
|
setFormData({
|
||||||
setErrors({ name: "", phone: "", captcha: "" });
|
name: "",
|
||||||
|
phone: "+998 ",
|
||||||
|
});
|
||||||
|
setErrors({
|
||||||
|
name: "",
|
||||||
|
phone: "",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
|
|
||||||
@@ -61,7 +80,6 @@ export function PriceModal() {
|
|||||||
|
|
||||||
let formatted = "+998 ";
|
let formatted = "+998 ";
|
||||||
const rest = numbers.slice(3);
|
const rest = numbers.slice(3);
|
||||||
|
|
||||||
if (rest.length > 0) formatted += rest.slice(0, 2);
|
if (rest.length > 0) formatted += rest.slice(0, 2);
|
||||||
if (rest.length > 2) formatted += " " + rest.slice(2, 5);
|
if (rest.length > 2) formatted += " " + rest.slice(2, 5);
|
||||||
if (rest.length > 5) formatted += " " + rest.slice(5, 7);
|
if (rest.length > 5) formatted += " " + rest.slice(5, 7);
|
||||||
@@ -90,51 +108,45 @@ export function PriceModal() {
|
|||||||
const newErrors = {
|
const newErrors = {
|
||||||
name: "",
|
name: "",
|
||||||
phone: "",
|
phone: "",
|
||||||
captcha: "",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Name validation
|
||||||
if (!formData.name.trim()) {
|
if (!formData.name.trim()) {
|
||||||
newErrors.name = t("validation.nameRequired");
|
newErrors.name = t("validation.nameRequired") || "Ism kiritilishi shart";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Phone validation
|
||||||
const phoneNumbers = formData.phone.replace(/\D/g, "");
|
const phoneNumbers = formData.phone.replace(/\D/g, "");
|
||||||
if (phoneNumbers.length !== 12) {
|
if (phoneNumbers.length !== 12) {
|
||||||
newErrors.phone = t("validation.phoneRequired");
|
newErrors.phone =
|
||||||
|
t("validation.phoneRequired") || "To'liq telefon raqam kiriting";
|
||||||
} else if (!phoneNumbers.startsWith("998")) {
|
} else if (!phoneNumbers.startsWith("998")) {
|
||||||
newErrors.phone = t("validation.phoneInvalid");
|
newErrors.phone =
|
||||||
}
|
t("validation.phoneInvalid") || "Noto'g'ri telefon raqam";
|
||||||
|
|
||||||
if (!formData.captcha.trim()) {
|
|
||||||
newErrors.captcha = t("validation.captchaRequired");
|
|
||||||
} else if (formData.captcha.toUpperCase() !== captchaCode) {
|
|
||||||
newErrors.captcha = t("validation.captchaRequired");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setErrors(newErrors);
|
setErrors(newErrors);
|
||||||
return !newErrors.name && !newErrors.phone && !newErrors.captcha;
|
return !newErrors.name && !newErrors.phone;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent) => {
|
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!validateForm()) {
|
if (!validateForm()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsSubmitting(true);
|
// Telefon raqamni tozalash (faqat raqamlar)
|
||||||
|
const cleanPhone = formData.phone.replace(/\D/g, "");
|
||||||
|
|
||||||
try {
|
const sendedData: FormType = {
|
||||||
// API call logikangiz
|
name: formData.name,
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1500));
|
phone: Number(cleanPhone), // ✅ String sifatida yuborish
|
||||||
|
product: product?.id || 0,
|
||||||
|
};
|
||||||
|
|
||||||
// Success
|
console.log("Sended data:", sendedData);
|
||||||
alert(t("success"));
|
formRequest.mutate(sendedData);
|
||||||
closeModal();
|
|
||||||
} catch (error) {
|
|
||||||
alert(t("error"));
|
|
||||||
} finally {
|
|
||||||
setIsSubmitting(false);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isOpen || !product) return null;
|
if (!isOpen || !product) return null;
|
||||||
@@ -143,49 +155,58 @@ export function PriceModal() {
|
|||||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4">
|
<div className="fixed inset-0 z-50 flex items-center justify-center p-4">
|
||||||
{/* Backdrop */}
|
{/* Backdrop */}
|
||||||
<div
|
<div
|
||||||
className="absolute inset-0 bg-black/50"
|
className="absolute inset-0 bg-black/60 backdrop-blur-sm"
|
||||||
onClick={closeModal}
|
onClick={closeModal}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Modal */}
|
{/* Modal */}
|
||||||
<div className="relative bg-white rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto">
|
<div className="relative bg-[#2a2a2a] rounded-2xl shadow-2xl w-full max-w-md max-h-[90vh] overflow-y-auto">
|
||||||
{/* Close button */}
|
{/* Close button */}
|
||||||
<button
|
<button
|
||||||
onClick={closeModal}
|
onClick={closeModal}
|
||||||
className="absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors z-10"
|
className="absolute right-4 top-4 text-gray-400 hover:text-white transition-colors z-10"
|
||||||
aria-label="Close modal"
|
aria-label="Close modal"
|
||||||
>
|
>
|
||||||
<X size={24} />
|
<X size={24} />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{/* Content */}
|
{/* Content */}
|
||||||
<div className="p-8">
|
<div className="p-6 md:p-8">
|
||||||
<h2 className="text-3xl font-bold mb-8">{t("title")}</h2>
|
<h2 className="text-2xl md:text-3xl font-bold text-white mb-6">
|
||||||
|
{t("title") || "Narx so'rash"}
|
||||||
|
</h2>
|
||||||
|
|
||||||
{/* Product Info */}
|
{/* Product Info */}
|
||||||
<div className="bg-[#f5f0e8] rounded-lg p-6 mb-8 flex items-center gap-6">
|
<div className="bg-[#1e1e1e] rounded-lg p-4 mb-6 flex items-center gap-4">
|
||||||
<div className="relative w-24 h-24 shrink-0">
|
<div className="relative w-20 h-20 shrink-0 bg-white rounded-lg overflow-hidden">
|
||||||
<Image
|
<Image
|
||||||
src={product.image}
|
src={product.image || "/placeholder.svg"}
|
||||||
alt={product.name}
|
alt={product.name}
|
||||||
fill
|
fill
|
||||||
className="object-contain"
|
className="object-contain p-2"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className="flex-1">
|
||||||
<h3 className="text-xl font-semibold mb-2">{product.name}</h3>
|
<h3 className="text-white font-semibold mb-1 line-clamp-2">
|
||||||
<span className="text-green-600 font-medium">
|
{product.name}
|
||||||
{t("product.inStock")}
|
</h3>
|
||||||
|
<span className="text-green-400 text-sm">
|
||||||
|
{product.inStock
|
||||||
|
? t("product.inStock") || "Sotuvda mavjud"
|
||||||
|
: t("product.outOfStock") || "Sotuvda yo'q"}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Form */}
|
{/* Form */}
|
||||||
<form onSubmit={handleSubmit} className="space-y-6">
|
<form onSubmit={handleSubmit} className="space-y-5">
|
||||||
{/* Name */}
|
{/* Name */}
|
||||||
<div>
|
<div>
|
||||||
<label htmlFor="name" className="block text-sm font-medium mb-2">
|
<label
|
||||||
{t("form.name")}
|
htmlFor="name"
|
||||||
|
className="block text-sm font-medium text-gray-300 mb-2"
|
||||||
|
>
|
||||||
|
{t("form.name") || "Ismingiz"}
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@@ -193,80 +214,50 @@ export function PriceModal() {
|
|||||||
name="name"
|
name="name"
|
||||||
value={formData.name}
|
value={formData.name}
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
placeholder={t("form.namePlaceholder")}
|
className={`w-full px-4 py-3 bg-[#1e1e1e] border ${
|
||||||
className={`w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 ${
|
errors.name ? "border-red-500" : "border-gray-700"
|
||||||
errors.name ? "border-red-500" : "border-gray-300"
|
} rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-red-700 transition`}
|
||||||
}`}
|
placeholder={t("form.namePlaceholder") || "Ismingizni kiriting"}
|
||||||
/>
|
/>
|
||||||
{errors.name && (
|
{errors.name && (
|
||||||
<p className="text-red-500 text-sm mt-1">{errors.name}</p>
|
<p className="mt-1 text-sm text-red-500">{errors.name}</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Phone */}
|
{/* Phone */}
|
||||||
<div>
|
<div>
|
||||||
<label htmlFor="phone" className="block text-sm font-medium mb-2">
|
<label
|
||||||
{t("form.phone")}
|
htmlFor="phone"
|
||||||
|
className="block text-sm font-medium text-gray-300 mb-2"
|
||||||
|
>
|
||||||
|
{t("form.phone") || "Telefon raqam"}
|
||||||
</label>
|
</label>
|
||||||
<div className="relative">
|
|
||||||
<input
|
<input
|
||||||
type="tel"
|
type="tel"
|
||||||
id="phone"
|
id="phone"
|
||||||
name="phone"
|
name="phone"
|
||||||
value={formData.phone}
|
value={formData.phone}
|
||||||
onChange={handlePhoneChange}
|
onChange={handlePhoneChange}
|
||||||
placeholder={t("form.phonePlaceholder")}
|
className={`w-full px-4 py-3 bg-[#1e1e1e] border ${
|
||||||
className={`w-full pl-2 pr-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 ${
|
errors.phone ? "border-red-500" : "border-gray-700"
|
||||||
errors.phone ? "border-red-500" : "border-gray-300"
|
} rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-red-700 transition`}
|
||||||
}`}
|
placeholder="+998 90 123 45 67"
|
||||||
|
maxLength={17}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
{errors.phone && (
|
{errors.phone && (
|
||||||
<p className="text-red-500 text-sm mt-1">{errors.phone}</p>
|
<p className="mt-1 text-sm text-red-500">{errors.phone}</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Captcha */}
|
|
||||||
{/* <div>
|
|
||||||
<label htmlFor="captcha" className="block text-sm font-medium mb-2">
|
|
||||||
{t("form.captcha")}
|
|
||||||
</label>
|
|
||||||
<div className="flex gap-4">
|
|
||||||
<div className="relative w-40 h-12 bg-linear-to-r from-purple-200 via-pink-200 to-blue-200 rounded-lg flex items-center justify-center">
|
|
||||||
<span className="text-2xl font-bold tracking-widest select-none">
|
|
||||||
{captchaCode}
|
|
||||||
</span>
|
|
||||||
<div className="absolute inset-0 opacity-30">
|
|
||||||
<svg className="w-full h-full">
|
|
||||||
<line x1="0" y1="0" x2="100%" y2="100%" stroke="currentColor" strokeWidth="1" />
|
|
||||||
<line x1="100%" y1="0" x2="0" y2="100%" stroke="currentColor" strokeWidth="1" />
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="captcha"
|
|
||||||
name="captcha"
|
|
||||||
value={formData.captcha}
|
|
||||||
onChange={handleInputChange}
|
|
||||||
placeholder={t("form.captchaPlaceholder")}
|
|
||||||
className={`flex-1 px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 ${
|
|
||||||
errors.captcha ? "border-red-500" : "border-gray-300"
|
|
||||||
}`}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{errors.captcha && (
|
|
||||||
<p className="text-red-500 text-sm mt-1">{errors.captcha}</p>
|
|
||||||
)}
|
|
||||||
</div> */}
|
|
||||||
|
|
||||||
{/* Submit Button */}
|
{/* Submit Button */}
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={isSubmitting}
|
disabled={formRequest.isPending}
|
||||||
className="w-full bg-[#8B1538] hover:bg-[#6d1028] text-white font-semibold py-4 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
className="w-full bg-red-700 hover:bg-red-800 disabled:bg-gray-600 disabled:cursor-not-allowed text-white font-bold py-3 px-6 rounded-lg transition-all duration-300 transform hover:scale-105 disabled:hover:scale-100"
|
||||||
>
|
>
|
||||||
{isSubmitting ? t("form.submitting") : t("form.submit")}
|
{formRequest.isPending
|
||||||
|
? t("form.submitting") || "Yuborilmoqda..."
|
||||||
|
: t("form.submit") || "Yuborish"}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user