diff --git a/frontend/application/app/ClientLayout.tsx b/frontend/application/app/ClientLayout.tsx index 2c1519b1..25e781d7 100644 --- a/frontend/application/app/ClientLayout.tsx +++ b/frontend/application/app/ClientLayout.tsx @@ -16,6 +16,7 @@ import { useSettingsStore } from "../lib/store/settingsStore"; import { useUIStore } from "../lib/store/uiStore"; import MaintenancePage from "../components/MaintenancePage"; +import { NavigationTarget } from "../lib/types"; export default function ClientLayout({ children }: { children: React.ReactNode }) { const isCartOpen = useUIStore((state) => state.isCartOpen); @@ -64,12 +65,12 @@ export default function ClientLayout({ children }: { children: React.ReactNode } if (pathname?.includes("/checkout")) currentView = "checkout"; if (pathname?.includes("/dashboard")) currentView = "user-dashboard"; - const handleNavigate = (v: any) => { - if (typeof v === 'object') { + const handleNavigate = (v: NavigationTarget) => { + if (typeof v === 'object' && v !== null) { if (v.view === 'profile') router.push('/profile'); if (v.view === 'order-tracking') router.push('/order/tracking'); if (v.view === 'home') router.push('/'); - } else { + } else if (typeof v === 'string') { if (v === 'home') router.push('/'); else if (v === 'user-dashboard') router.push('/dashboard'); else router.push(`/${v}`); diff --git a/frontend/application/app/HomeClient.tsx b/frontend/application/app/HomeClient.tsx index 1d6cbee8..722ced5f 100644 --- a/frontend/application/app/HomeClient.tsx +++ b/frontend/application/app/HomeClient.tsx @@ -11,13 +11,15 @@ import { useSettingsStore } from "../lib/store/settingsStore"; import api from "../lib/services/api"; import Image from "next/image"; +import { HomeApiResponse } from "../lib/types"; + interface HomeClientProps { - initialData?: any; + initialData?: HomeApiResponse | null; } export default function HomeClient({ initialData }: HomeClientProps) { const getText = useSettingsStore((state) => state.getText); - const [data, setData] = useState(initialData || null); + const [data, setData] = useState(initialData || null); useEffect(() => { if (!initialData) { diff --git a/frontend/application/app/page.tsx b/frontend/application/app/page.tsx index 1709fa51..042f60db 100644 --- a/frontend/application/app/page.tsx +++ b/frontend/application/app/page.tsx @@ -31,14 +31,9 @@ export const metadata: Metadata = { } }; -interface HomeData { - heroBanners?: any[]; - vetTestimonials?: any[]; - smartAdvisorRules?: any[]; - [key: string]: any; -} +import { HomeApiResponse } from "../lib/types"; -async function getHomeData(): Promise { +async function getHomeData(): Promise { try { const apiUrl = process.env.INTERNAL_API_URL || process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4001/api'; const res = await fetch(`${apiUrl}/home`, { diff --git a/frontend/application/app/shop/[slug]/page.tsx b/frontend/application/app/shop/[slug]/page.tsx index f6e0ded4..0fdd8c99 100644 --- a/frontend/application/app/shop/[slug]/page.tsx +++ b/frontend/application/app/shop/[slug]/page.tsx @@ -1,6 +1,7 @@ import ProductPage from "../../../components/ProductPage"; import { productService } from "../../../lib/services/productService"; import type { Metadata, ResolvingMetadata } from 'next'; +import { Suspense } from 'react'; export async function generateMetadata( { params }: { params: Promise<{ slug: string }> }, @@ -15,14 +16,12 @@ export async function generateMetadata( }; } - // Get raw data for custom fields if we added them (like metaTitle) - // Since we don't have local access to raw DB object without modifying productService, - // we can just use the mapped product fields for now. const nameFa = product.nameFa || product.name; const nameEn = product.nameEn || ""; const title = nameFa.includes("Canina") ? nameFa : `${nameFa} (${nameEn}) | برند کانینا آلمان`; const description = (product.shortDescription || product.description || '').substring(0, 150).trim(); - const keywords = (product as any).keywords ? (product as any).keywords.split(',') : product.main_ingredients; + const rawKeywords = (product as unknown as Record).keywords; + const keywords = typeof rawKeywords === 'string' ? rawKeywords.split(',') : product.main_ingredients; return { title, @@ -106,17 +105,36 @@ export default async function ShopProductPage({ params }: { params: Promise<{ sl ] }; + const safeProductJsonLd = JSON.stringify(productJsonLd).replace(/