login , register api / category provider api
This commit is contained in:
@@ -5,6 +5,7 @@ import Footer from "@/components/footer";
|
||||
import localFont from 'next/font/local';
|
||||
import { CartProvider } from "@/components/context/cartcontext";
|
||||
import { categoryService } from "@/public/src/services/categories/api";
|
||||
import { CategoryProvider } from "@/components/context/categoryprovider";
|
||||
|
||||
const Yekanbakh = localFont({
|
||||
src: [
|
||||
@@ -35,8 +36,12 @@ export default async function RootLayout({
|
||||
<html lang="fa" dir="rtl" className={Yekanbakh.variable}>
|
||||
<body>
|
||||
<CartProvider>
|
||||
<Header categories={categories}/>
|
||||
<CategoryProvider>
|
||||
|
||||
<Header />
|
||||
{children}
|
||||
</CategoryProvider>
|
||||
|
||||
</CartProvider>
|
||||
|
||||
<Footer/>
|
||||
|
||||
82
app/page.tsx
82
app/page.tsx
@@ -1,13 +1,20 @@
|
||||
"use client";
|
||||
import { useState } from "react";
|
||||
import { Headphones, FileText, Truck, ShieldCheck, Square, MoreVertical, Circle, Target, CookingPot, Settings, CircleDashed, Disc, Hexagon, Droplets, Wrench, Minus, MessageCircleCheckIcon, } from "lucide-react";
|
||||
import {
|
||||
Headphones, FileText, Truck, ShieldCheck, CircleDashed,
|
||||
Disc,
|
||||
Hexagon,
|
||||
Settings,
|
||||
Wrench,
|
||||
Droplets, Square, MoreVertical, Circle, Target, CookingPot, Minus, MessageCircleCheckIcon,
|
||||
} from "lucide-react";
|
||||
import ProductCard from "@/components/productcard";
|
||||
import ArticleCard from "@/components/articlecard";
|
||||
import FAQItem from "@/components/faq";
|
||||
import { products } from "@/lib/data";
|
||||
import { articles } from "@/lib/data";
|
||||
import Link from "next/link";
|
||||
|
||||
import { useCategories } from "@/components/context/categoryprovider";
|
||||
|
||||
|
||||
const features = [
|
||||
@@ -60,28 +67,35 @@ export default function Home() {
|
||||
const [activeTab, setActiveTab] = useState(0);
|
||||
const brands = ["NTN", "KOYO", "NACHI", "TIMKEN", "FAG", "SKF"];
|
||||
const latestArticles = articles.slice(-4);
|
||||
const { rootCategories } = useCategories();
|
||||
|
||||
const uniqueCategories = Array.from(new Set(products.map((p) => p.category)));
|
||||
const getCategoryIcon = (categoryName: string) => {
|
||||
switch (categoryName) {
|
||||
case "شیار عمیق":
|
||||
return CircleDashed;
|
||||
case "مخروطی":
|
||||
return Disc;
|
||||
case "شبکه ای":
|
||||
return Hexagon;
|
||||
case "سوزنی":
|
||||
return Settings;
|
||||
case "یاتاقان":
|
||||
return Wrench;
|
||||
case "گریس و روانکار":
|
||||
return Droplets;
|
||||
default:
|
||||
return Settings; // آیکون پیشفرض
|
||||
}
|
||||
};
|
||||
|
||||
// const uniqueCategories = Array.from(new Set(products.map((p) => p.category)));
|
||||
// const getCategoryIcon = (categoryName: string) => {
|
||||
// switch (categoryName) {
|
||||
// case "شیار عمیق":
|
||||
// return CircleDashed;
|
||||
// case "مخروطی":
|
||||
// return Disc;
|
||||
// case "شبکه ای":
|
||||
// return Hexagon;
|
||||
// case "سوزنی":
|
||||
// return Settings;
|
||||
// case "یاتاقان":
|
||||
// return Wrench;
|
||||
// case "گریس و روانکار":
|
||||
// return Droplets;
|
||||
// default:
|
||||
// return Settings; // آیکون پیشفرض
|
||||
// }
|
||||
// };
|
||||
|
||||
const categoryIcons = [
|
||||
CircleDashed,
|
||||
Disc,
|
||||
Hexagon,
|
||||
Wrench,
|
||||
Droplets
|
||||
];
|
||||
|
||||
return (
|
||||
<main className=" bg-gray-50">
|
||||
@@ -225,26 +239,26 @@ export default function Home() {
|
||||
|
||||
|
||||
{/* cards */}
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-6">
|
||||
{uniqueCategories.map((category, index) => {
|
||||
const Icon = getCategoryIcon(category);
|
||||
<div className="grid justify-center grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-6">
|
||||
|
||||
// فقط فاصلهها را به خط تیره تبدیل میکنیم
|
||||
const categorySlug = category.replace(/\s+/g, "-");
|
||||
|
||||
|
||||
{rootCategories.map((cat, index) => {
|
||||
const Icon = categoryIcons[index % categoryIcons.length];
|
||||
|
||||
return (
|
||||
<Link
|
||||
href={`/category/${categorySlug}`}
|
||||
key={index}
|
||||
className="bg-white border border-gray-200 rounded-xl shadow-sm hover:shadow-md hover:border-blue-400 transition-all duration-300 flex flex-col items-center justify-center py-8 cursor-pointer group"
|
||||
key={cat.id}
|
||||
href={`/category/${cat.slug}`}
|
||||
className="bg-white border gap-2 border-gray-200 rounded-xl shadow-sm hover:shadow-md hover:border-blue-400 transition-all duration-300 flex flex-col items-center justify-center py-8 cursor-pointer group"
|
||||
>
|
||||
<Icon size={34} className="text-gray-400 mb-3 group-hover:text-blue-500 transition-colors" />
|
||||
<p className="text-sm font-medium text-gray-700 group-hover:text-blue-600">
|
||||
{category}
|
||||
</p>
|
||||
<Icon size={34} strokeWidth={1} className="text-gray-400 mb-3 group-hover:text-blue-500 transition-colors" />
|
||||
<span className="text-sm font-medium text-gray-700 group-hover:text-blue-600">{cat.name}</span>
|
||||
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user