From 4659a7b1de263664b740ab948ce2ce74d406dd21 Mon Sep 17 00:00:00 2001 From: parsaaghayi Date: Fri, 7 Aug 2026 00:16:03 +0330 Subject: [PATCH] feat(storefront): implement Phase C API integration replacing static fallbacks --- frontend/application/app/HomeClient.tsx | 47 +- frontend/application/app/layout.tsx | 135 +++--- .../application/components/IngredientWiki.tsx | 79 ++-- .../application/components/ProductPage.tsx | 99 +++-- .../application/components/SmartAdvisor.tsx | 26 +- .../application/components/VetGallery.tsx | 20 +- frontend/application/lib/data/products.ts | 2 +- .../application/lib/data/scientificTerms.ts | 405 +----------------- frontend/application/lib/types.ts | 115 ++++- 9 files changed, 366 insertions(+), 562 deletions(-) diff --git a/frontend/application/app/HomeClient.tsx b/frontend/application/app/HomeClient.tsx index 722ced5f..08632152 100644 --- a/frontend/application/app/HomeClient.tsx +++ b/frontend/application/app/HomeClient.tsx @@ -11,7 +11,7 @@ import { useSettingsStore } from "../lib/store/settingsStore"; import api from "../lib/services/api"; import Image from "next/image"; -import { HomeApiResponse } from "../lib/types"; +import { Banner, Testimonial, SmartAdvisorRule, HomeApiResponse } from "../lib/types"; interface HomeClientProps { initialData?: HomeApiResponse | null; @@ -19,26 +19,47 @@ interface HomeClientProps { export default function HomeClient({ initialData }: HomeClientProps) { const getText = useSettingsStore((state) => state.getText); - const [data, setData] = useState(initialData || null); + const [banners, setBanners] = useState(initialData?.heroBanners || []); + const [testimonials, setTestimonials] = useState(initialData?.vetTestimonials || []); + const [rules, setRules] = useState(initialData?.smartAdvisorRules || []); useEffect(() => { - if (!initialData) { - api.get('/home') - .then(res => setData(res.data)) - .catch(err => console.error('Home data fetch error:', err)); - } - }, [initialData]); + // Fetch banners + api.get('/banners') + .then(res => { + if (Array.isArray(res.data)) { + setBanners(res.data); + } + }) + .catch(err => console.error('[HomeClient] Banners fetch error:', err)); - const banners = data?.heroBanners || []; - const testimonials = data?.vetTestimonials || []; - const rules = data?.smartAdvisorRules || []; + // Fetch testimonials + api.get('/testimonials') + .then(res => { + if (Array.isArray(res.data)) { + setTestimonials(res.data); + } + }) + .catch(err => console.error('[HomeClient] Testimonials fetch error:', err)); + + // Fetch smart advisor rules + api.get('/smart-advisor/rules') + .then(res => { + if (Array.isArray(res.data)) { + setRules(res.data); + } + }) + .catch(err => console.error('[HomeClient] Smart Advisor rules fetch error:', err)); + }, []); + + const heroBanners = banners.filter(b => b.position === 'home_hero' && b.isActive !== false); return ( <> - + - + {/* Navigation to Sections */}
diff --git a/frontend/application/app/layout.tsx b/frontend/application/app/layout.tsx index 02a6c67a..73113f1a 100644 --- a/frontend/application/app/layout.tsx +++ b/frontend/application/app/layout.tsx @@ -2,61 +2,94 @@ import type { Metadata } from 'next'; import './globals.css'; import ClientLayout from './ClientLayout'; -const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://canina-iran.com'; +export async function generateMetadata(): Promise { + let seoSettings: { + defaultMetaTitle?: string; + defaultMetaDescription?: string; + keywords?: string | string[]; + canonicalBaseUrl?: string; + ogImageUrl?: string; + } | null = null; -export const metadata: Metadata = { - metadataBase: new URL(siteUrl), - title: { - template: '%s | کانینا ایران', - default: 'کانینا ایران - مکمل‌های درمانی حیوانات خانگی با گرید دارویی اختصاصی', - }, - description: 'تدارک هوشمندانه سلامت برای همراهان وفادار شما. کانینا ایران واردکننده انحصاری مکمل‌های درمانی با گرید دارویی اختصاصی از آلمان.', - keywords: ['مکمل حیوانات خانگی', 'مکمل سگ', 'مکمل گربه', 'کانینا', 'داروی حیوانات', 'Canina Iran'], - authors: [{ name: 'Canina Iran' }], - creator: 'Canina Iran', - publisher: 'Canina Iran', - alternates: { - canonical: '/', - }, - formatDetection: { - email: false, - address: false, - telephone: false, - }, - openGraph: { - title: 'کانینا ایران - مکمل‌های درمانی حیوانات خانگی با گرید دارویی اختصاصی', - description: 'واردکننده انحصاری مکمل‌های درمانی با گرید دارویی اختصاصی از آلمان', - url: siteUrl, - siteName: 'کانینا ایران', - locale: 'fa_IR', - type: 'website', - images: [ - { - url: '/assets/images/regenerated_image_1779109861747.png', - width: 1200, - height: 630, - alt: 'کانینا ایران - مکمل‌های درمانی حیوانات خانگی', - }, - ], - }, - twitter: { - card: 'summary_large_image', - title: 'کانینا ایران - مکمل‌های درمانی حیوانات خانگی با گرید دارویی اختصاصی', - description: 'مکمل‌های درمانی حیوانات خانگی کانینا با پروانه رسمی دامپزشکی', - images: ['/assets/images/regenerated_image_1779109861747.png'], - }, - robots: { - index: true, - follow: true, - googleBot: { + try { + const apiBase = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4001/api'; + const res = await fetch(`${apiBase}/settings/seo`, { next: { revalidate: 60 } }); + if (res.ok) { + seoSettings = await res.json(); + } + } catch (err) { + console.error('[SEO] Error fetching dynamic SEO settings:', err); + } + + const siteUrl = seoSettings?.canonicalBaseUrl || process.env.NEXT_PUBLIC_SITE_URL || 'https://canina-iran.com'; + const titleDefault = seoSettings?.defaultMetaTitle || 'کانینا ایران - مکمل‌های درمانی حیوانات خانگی با گرید دارویی اختصاصی'; + const descriptionDefault = seoSettings?.defaultMetaDescription || 'تدارک هوشمندانه سلامت برای همراهان وفادار شما. کانینا ایران واردکننده انحصاری مکمل‌های درمانی با گرید دارویی اختصاصی از آلمان.'; + + let keywordsList: string[] = ['مکمل حیوانات خانگی', 'مکمل سگ', 'مکمل گربه', 'کانینا', 'داروی حیوانات', 'Canina Iran']; + if (seoSettings?.keywords) { + if (Array.isArray(seoSettings.keywords)) { + keywordsList = seoSettings.keywords; + } else if (typeof seoSettings.keywords === 'string') { + keywordsList = seoSettings.keywords.split(',').map(k => k.trim()); + } + } + + const ogImg = seoSettings?.ogImageUrl || '/assets/images/regenerated_image_1779109861747.png'; + + return { + metadataBase: new URL(siteUrl), + title: { + template: '%s | کانینا ایران', + default: titleDefault, + }, + description: descriptionDefault, + keywords: keywordsList, + authors: [{ name: 'Canina Iran' }], + creator: 'Canina Iran', + publisher: 'Canina Iran', + alternates: { + canonical: '/', + }, + formatDetection: { + email: false, + address: false, + telephone: false, + }, + openGraph: { + title: titleDefault, + description: descriptionDefault, + url: siteUrl, + siteName: 'کانینا ایران', + locale: 'fa_IR', + type: 'website', + images: [ + { + url: ogImg, + width: 1200, + height: 630, + alt: titleDefault, + }, + ], + }, + twitter: { + card: 'summary_large_image', + title: titleDefault, + description: descriptionDefault, + images: [ogImg], + }, + robots: { index: true, follow: true, - 'max-video-preview': -1, - 'max-image-preview': 'large', - 'max-snippet': -1, + googleBot: { + index: true, + follow: true, + 'max-video-preview': -1, + 'max-image-preview': 'large', + 'max-snippet': -1, + }, }, - }, -}; + }; +} export default function RootLayout({ children, diff --git a/frontend/application/components/IngredientWiki.tsx b/frontend/application/components/IngredientWiki.tsx index 95b1686b..f526f47c 100644 --- a/frontend/application/components/IngredientWiki.tsx +++ b/frontend/application/components/IngredientWiki.tsx @@ -11,6 +11,9 @@ import Image from "next/image"; import { SCIENTIFIC_TERMS } from "../lib/data/scientificTerms"; import { useRouter, useSearchParams } from 'next/navigation'; +import api from "../lib/services/api"; +import { Ingredient } from "../lib/types"; + export default function IngredientWiki() { const router = useRouter(); const searchParams = useSearchParams(); @@ -26,39 +29,59 @@ export default function IngredientWiki() { }, []); useEffect(() => { - let list: IngredientInfo[] = []; - const raw = texts.ingredients_wiki || texts.ingredients_wiki_text; - if (raw) { - try { - const parsed = typeof raw === 'string' ? JSON.parse(raw) : raw; - if (Array.isArray(parsed)) { - list = parsed.map((item: any) => ({ - id: item.id, - name: item.name, - description: item.description, + api.get('/ingredients') + .then(res => { + if (Array.isArray(res.data) && res.data.length > 0) { + const apiList: IngredientInfo[] = res.data.map((item: Ingredient) => ({ + id: item.slug || item.id, + name: item.nameFa ? (item.scientificName ? `${item.nameFa} (${item.scientificName})` : item.nameFa) : (item.nameEn || item.slug), + description: item.description || '', benefits: Array.isArray(item.benefits) ? item.benefits : [] })); + setIngredientsWiki(apiList); + } else { + loadFallbackIngredients(); + } + }) + .catch((err) => { + console.error('[IngredientWiki] Failed to fetch ingredients from API:', err); + loadFallbackIngredients(); + }); + + function loadFallbackIngredients() { + let list: IngredientInfo[] = []; + const raw = texts.ingredients_wiki || texts.ingredients_wiki_text; + if (raw) { + try { + const parsed = typeof raw === 'string' ? JSON.parse(raw) : raw; + if (Array.isArray(parsed)) { + list = parsed.map((item: any) => ({ + id: item.id, + name: item.name, + description: item.description, + benefits: Array.isArray(item.benefits) ? item.benefits : [] + })); + } + } catch (e) { + console.error("Failed to parse ingredients_wiki:", e); } - } catch (e) { - console.error("Failed to parse ingredients_wiki:", e); } + + const mergedTerms = { ...SCIENTIFIC_TERMS, ...scientificTerms }; + Object.entries(mergedTerms).forEach(([key, t]: [string, any]) => { + const wikiId = t.wikiId || t.key || key; + if (!list.some(item => item.id === wikiId || item.name.includes(t.term))) { + list.push({ + id: wikiId, + name: t.term, + description: t.definition, + benefits: [] + }); + } + }); + + setIngredientsWiki(list); } - - // Merge terms from scientificTerms and static SCIENTIFIC_TERMS dictionary - const mergedTerms = { ...SCIENTIFIC_TERMS, ...scientificTerms }; - Object.entries(mergedTerms).forEach(([key, t]: [string, any]) => { - const wikiId = t.wikiId || t.key || key; - if (!list.some(item => item.id === wikiId || item.name.includes(t.term))) { - list.push({ - id: wikiId, - name: t.term, - description: t.definition, - benefits: [] - }); - } - }); - - setIngredientsWiki(list); }, [texts, scientificTerms]); useEffect(() => { diff --git a/frontend/application/components/ProductPage.tsx b/frontend/application/components/ProductPage.tsx index ebbbc6b0..d6c62403 100644 --- a/frontend/application/components/ProductPage.tsx +++ b/frontend/application/components/ProductPage.tsx @@ -52,6 +52,8 @@ import { create } from "zustand"; import { useCartStore } from "../lib/store/cartStore"; import { usePetStore } from "../lib/store/usePetStore"; import { toast } from "sonner"; +import api from "../lib/services/api"; +import { DosageConfig } from "../lib/types"; interface CalculatorState { petType: "young" | "adult"; @@ -75,27 +77,46 @@ import { useRouter } from 'next/navigation'; export default function ProductPage({ productSlug }: { productSlug: string }) { const router = useRouter(); const [product, setProduct] = useState(null); + const [allProducts, setAllProducts] = useState([]); const [isLoading, setIsLoading] = useState(true); + const [itemQuantity, setItemQuantity] = useState(1); const [activeTab, setActiveTab] = useState<"specs" | "feeding" | "notes">("specs"); const [showRefillModal, setShowRefillModal] = useState(false); - const [itemQuantity, setItemQuantity] = useState(1); - const [allProducts, setAllProducts] = useState([]); const [showNotifier, setShowNotifier] = useState(false); const [notifierPhone, setNotifierPhone] = useState(''); const [isMounted, setIsMounted] = useState(false); + const [dosageConfig, setDosageConfig] = useState(null); useEffect(() => { setIsMounted(true); - productService.getProducts({ limit: 999 }) - .then((res) => { - const products = res.data; - setAllProducts(products); - const found = products.find(p => p.slug === productSlug || p.id === productSlug); - setProduct(found || null); + }, []); + + useEffect(() => { + setIsLoading(true); + productService.getProductBySlug(productSlug) + .then(p => { + setProduct(p); + return productService.getProducts({ limit: 50 }); + }) + .then(res => { + if (res && res.data) setAllProducts(res.data); }) .catch(err => console.error("Error fetching products in ProductPage:", err)) .finally(() => setIsLoading(false)); }, [productSlug]); + + useEffect(() => { + if (product && product.id) { + api.get(`/products/${product.id}/dosage-config`) + .then(res => { + if (res.data) { + setDosageConfig(res.data); + } + }) + .catch(err => console.error('[ProductPage] Dosage config fetch error:', err)); + } + }, [product?.id]); + const { pets, getActivePet } = usePetStore(); const activePet = getActivePet(); const { petType, weight, setPetType, setWeight } = useCalculatorStore(); @@ -108,33 +129,15 @@ export default function ProductPage({ productSlug }: { productSlug: string }) { ])); }, [scientificTerms]); - // Re-hydrate product to ensure methods like calculateDosage exist + // Re-hydrate product const fullProduct = useMemo(() => { if (!product) return null; const apiProduct = allProducts.find(p => p.id === product.id) || product; if (!apiProduct) return null; - const staticProduct = PRODUCTS.find(p => p.id === apiProduct.id || p.artNo === apiProduct.artNo); - if (staticProduct && typeof staticProduct.calculateDosage === 'function') { - return { - ...apiProduct, - calculateDosage: staticProduct.calculateDosage, - packageSize: apiProduct.packageSize || staticProduct.packageSize || 100 - }; - } - // Dynamic weight-based calculation fallback for any product without custom logic return { ...apiProduct, packageSize: apiProduct.packageSize || 100, - calculateDosage: (w: number, isYoung: boolean) => { - const factor = isYoung ? 0.2 : 0.1; - const baseQty = Math.max(1, Math.round(w * factor)); - return { - quantity: baseQty, - unit: apiProduct.unit?.includes('ml') ? "میلی‌لیتر" : apiProduct.unit?.includes('g') ? "گرم" : "قرص", - description: isYoung ? "دوز رشد روزانه" : "دوز نگهداری روزانه" - }; - } }; }, [product, allProducts]); @@ -146,18 +149,46 @@ export default function ProductPage({ productSlug }: { productSlug: string }) { }, [activePet]); const calculation = useMemo(() => { - if (!fullProduct || typeof fullProduct.calculateDosage !== 'function') return null; - const result = fullProduct.calculateDosage(weight, petType === "young"); + if (!fullProduct) return null; + + let dailyDose = 1; + let unit = fullProduct.unit?.includes('ml') ? "میلی‌لیتر" : fullProduct.unit?.includes('g') ? "گرم" : "قرص"; + let description = petType === "young" ? "دوز رشد روزانه" : "دوز نگهداری روزانه"; + + if (dosageConfig) { + const baseW = dosageConfig.baseWeightKg || 10; + const baseD = dosageConfig.baseDose || 1; + const calculated = Math.round((weight / baseW) * baseD); + dailyDose = Math.max(1, calculated); + if (dosageConfig.maxDailyDose && dosageConfig.maxDailyDose > 0) { + dailyDose = Math.min(dailyDose, dosageConfig.maxDailyDose); + } + if (dosageConfig.unit) { + unit = dosageConfig.unit; + } + if (dosageConfig.instructions) { + description = dosageConfig.instructions; + } + } else if (typeof fullProduct.calculateDosage === 'function') { + const result = fullProduct.calculateDosage(weight, petType === "young"); + dailyDose = result.quantity; + unit = result.unit; + description = result.description; + } else { + const factor = petType === "young" ? 0.2 : 0.1; + dailyDose = Math.max(1, Math.round(weight * factor)); + } + const packageSize = fullProduct.packageSize || 100; - const duration = Math.max(1, Math.floor(packageSize / (result.quantity || 1))); + const duration = Math.max(1, Math.floor(packageSize / (dailyDose || 1))); return { - dailyDose: result.quantity, + dailyDose, duration: duration || 0, - unit: result.unit, - description: result.description + unit, + description }; - }, [fullProduct, petType, weight]); + }, [fullProduct, dosageConfig, petType, weight]); // Suggest quantity inside useEffect to avoid render-phase state update useEffect(() => { diff --git a/frontend/application/components/SmartAdvisor.tsx b/frontend/application/components/SmartAdvisor.tsx index 730c543b..c8ea8f0e 100644 --- a/frontend/application/components/SmartAdvisor.tsx +++ b/frontend/application/components/SmartAdvisor.tsx @@ -1,5 +1,4 @@ -"use client"; -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import Link from "next/link"; import { motion, AnimatePresence } from "motion/react"; import { useSettingsStore } from "../lib/store/settingsStore"; @@ -28,6 +27,7 @@ import { useRouter } from "next/navigation"; import { useUserStore } from "../lib/store/userStore"; import { useUIStore } from "../lib/store/uiStore"; import { usePetStore } from "../lib/store/usePetStore"; +import api from "../lib/services/api"; interface SmartAdvisorProps { onComplete?: (data: any) => void; @@ -61,6 +61,22 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro const texts = useSettingsStore(state => state.texts); const getText = useSettingsStore(state => state.getText); + const [advisorRules, setAdvisorRules] = useState(rules); + + useEffect(() => { + if (rules && rules.length > 0) { + setAdvisorRules(rules); + } else { + api.get('/smart-advisor/rules') + .then(res => { + if (Array.isArray(res.data)) { + setAdvisorRules(res.data); + } + }) + .catch(err => console.error("[SmartAdvisor] Failed to fetch rules:", err)); + } + }, [rules]); + const [step, setStep] = useState(1); // Step 1 Data @@ -101,9 +117,9 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro let matchedProd: any = null; let matchedReason: string | null = null; - // First, check backend rules if provided - if (rules && rules.length > 0) { - const foundRule = rules.find((r: any) => { + // First, check fetched advisor rules + if (advisorRules && advisorRules.length > 0) { + const foundRule = advisorRules.find((r: any) => { const petMatch = !r.targetPetType || r.targetPetType === "هر دو" || r.targetPetType === type; const conditionMatch = combinedConditions.some(c => r.condition?.includes(c) || c.includes(r.condition)); return petMatch && conditionMatch; diff --git a/frontend/application/components/VetGallery.tsx b/frontend/application/components/VetGallery.tsx index 5a4ff5be..b0f348f7 100644 --- a/frontend/application/components/VetGallery.tsx +++ b/frontend/application/components/VetGallery.tsx @@ -9,6 +9,10 @@ import { videoService, Video } from "../lib/services/videoService"; export interface TestimonialItem { id?: string; + authorName?: string; + roleTitle?: string; + avatarUrl?: string; + content?: string; clinicName?: string; vetName?: string; imageUrl?: string; @@ -17,6 +21,7 @@ export interface TestimonialItem { thumbnail?: string; videoUrl?: string; description?: string; + isActive?: boolean; } const FALLBACK_VIDEOS = [ @@ -62,16 +67,17 @@ export default function VetGallery({ testimonials = [] }: { testimonials?: Testi }); }, []); - const displayItems = testimonials.length > 0 - ? testimonials.map((t, idx) => ({ + const activeTestimonials = testimonials.filter(t => t.isActive !== false); + const displayItems = activeTestimonials.length > 0 + ? activeTestimonials.map((t, idx) => ({ id: t.id || `t-${idx}`, - title: t.clinicName ? `${t.vetName} — ${t.clinicName}` : (t.vetName || ''), - doctor: t.vetName || '', + title: (t.authorName || t.vetName || '') + (t.roleTitle ? ` — ${t.roleTitle}` : (t.clinicName ? ` — ${t.clinicName}` : '')), + doctor: (t.authorName || t.vetName || '') + (t.roleTitle ? ` (${t.roleTitle})` : ''), duration: "۰۲:۰۰", - thumbnail: t.imageUrl || "https://images.unsplash.com/photo-1576091160550-217359f42f8c?auto=format&fit=crop&q=80&w=400", + thumbnail: t.avatarUrl || t.imageUrl || "https://images.unsplash.com/photo-1576091160550-217359f42f8c?auto=format&fit=crop&q=80&w=400", videoUrl: "https://www.w3schools.com/html/mov_bbb.mp4", - description: t.quote || '', - quote: t.quote || '' + description: t.content || t.quote || '', + quote: t.content || t.quote || '' })) : (apiVideos.length > 0 ? apiVideos : FALLBACK_VIDEOS); diff --git a/frontend/application/lib/data/products.ts b/frontend/application/lib/data/products.ts index d98e42e6..fa7922f2 100644 --- a/frontend/application/lib/data/products.ts +++ b/frontend/application/lib/data/products.ts @@ -55,7 +55,7 @@ export interface Product { onSetOfAction?: string; expectedResults?: { icon: string; text: string }[]; optimisticTemplate?: string; - calculateDosage: (weight: number, isYoung: boolean) => DosageResult; + calculateDosage?: (weight: number, isYoung: boolean) => DosageResult; analysis: Record; feedingAdvice: string; specialist: Specialist; diff --git a/frontend/application/lib/data/scientificTerms.ts b/frontend/application/lib/data/scientificTerms.ts index b6e5ca3f..d2580002 100644 --- a/frontend/application/lib/data/scientificTerms.ts +++ b/frontend/application/lib/data/scientificTerms.ts @@ -4,407 +4,4 @@ export interface ScientificTerm { wikiId?: string; } -export const SCIENTIFIC_TERMS: Record = { - "گلیکوزآمینوگلیکان": { - term: "گلیکوزآمینوگلیکان (GAG)", - definition: "ترکیبات ساختاری ضروری برای بازسازی غضروف‌ها و مایع مفصلی که در مفاصل و تاندون‌ها نقش حیاتی دارند.", - wikiId: "green-mussel" - }, - "اسیدهای هومیک": { - term: "اسیدهای هومیک", - definition: "مواد آلی طبیعی موجود در عصاره پیت (Moor) که از مخاط روده محافظت کرده و سموم را در گوارش به دام می‌اندازند.", - wikiId: "peat-extract" - }, - "کلاژن زیست‌فعال": { - term: "کلاژن زیست‌فعال (Bioactive Collagen)", - definition: "پروتئین‌های اختصاصی هیدرولیز شده که به سرعت جذب استخوان و تاندون شده و بازسازی مفاصل را بهبود می‌بخشند.", - wikiId: "collagen" - }, - "تیموکینون": { - term: "تیموکینون (Thymoquinone)", - definition: "ماده موثره اصلی در روغن سیاه دانه با خواص ضدالتهابی، ضدآلرژی و آنتی‌اکسیدان بسیار قوی.", - wikiId: "black-cumin" - }, - "امگا ۳": { - term: "امگا ۳ (Omega-3)", - definition: "اسیدهای چرب ضروری شامل EPA و DHA که برای سلامت پوست، مو، قلب و عملکرد مغز حیاتی هستند.", - wikiId: "salmon-oil" - }, - "میکروسیلور": { - term: "نقره میکروسیلور (Microsilver BG)", - definition: "ذرات نقره خالص با ساختار اسفنجی که بدون جذب در خون، اثر آنتی‌باکتریال پایداری بر سطح پوست و لثه دارند.", - wikiId: "silver" - }, - "صدف لب‌سبز": { - term: "صدف لب‌سبز (Green-lipped Mussel)", - definition: "صدف بومی نیوزلند حاوی گلوکوزامین‌گلیکان‌های طبیعی که نقش کلیدی در ساخت و بازسازی غضروف‌ها ایفا می‌کند.", - wikiId: "green-mussel" - }, - "نسبت Ca:P": { - term: "نسبت کلسیم به فسفر (Ca:P Ratio)", - definition: "نسبت کلسیم به فسفر جهت حفظ سلامت استخوان‌ها و کلیه. پودر پوسته تخم مرغ بهترین تنظیم‌کننده این نسبت است.", - wikiId: "eggshell" - }, - "ویتامین D3": { - term: "ویتامین D3 (کوله‌کلسیفرول)", - definition: "فرمی فعال از ویتامین D که جذب کلسیم از روده را افزایش داده و به سلامت استخوان‌ها کمک می‌کند.", - wikiId: "vitamins" - }, - "BARF": { - term: "رژیم غذایی خام (BARF)", - definition: "رژیم غذایی خام طبیعی شامل گوشت و استخوان که مکمل‌های پوسته تخم مرغ و پودر خون برای تکمیل آن طراحی شده‌اند.", - wikiId: "eggshell" - }, - "آغوز": { - term: "آغوز (Colostrum)", - definition: "اولین شیر پستانداران پس از زایمان، غنی از ایمونوگلوبولین‌ها جهت فعال‌سازی فوری سیستم ایمنی نوزادان.", - wikiId: "colostrum" - }, - "ال-کارنیتین": { - term: "ال-کارنیتین (L-Carnitine)", - definition: "آمینو اسیدی که وظیفه انتقال اسیدهای چرب به درون میتوکندری جهت تولید انرژی و تقویت عملکرد قلب را دارد.", - wikiId: "l-carnitine" - }, - "زالزالک": { - term: "زالزالک (Hawthorn)", - definition: "عصاره گیاهی تقویت‌کننده عملکرد انقباضی عضله قلب و بهبودبخش گردش خون عروق کرونر.", - wikiId: "hawthorn" - }, - "بیوتین": { - term: "بیوتین (Biotin / Vitamin H)", - definition: "کوآنزیم ضروری برای ساخت کراتین و جلوگیری از ریزش مو و تقویت ناخن‌ها و پنجه‌های حیوان.", - wikiId: "biotin" - }, - "هیدروکسی آپاتیت": { - term: "هیدروکسی آپاتیت (Hydroxyapatite)", - definition: "ترکیب کلسیم فسفات طبیعی که بخش عمده استخوان و دندان‌ها را تشکیل داده و موجب افزایش استحکام اسکلت می‌شود.", - wikiId: "green-mussel" - }, - "EPA/DHA": { - term: "EPA و DHA", - definition: "اسیدهای چرب بلندزنجیره امگا ۳ که اثرات ضدالتهابی عمیق داشته و برای رشد سیستم عصبی و چشم‌ها حیاتی هستند.", - wikiId: "salmon-oil" - }, - "روغن ماهی سالمون": { - term: "روغن ماهی سالمون (Salmon Oil)", - definition: "منبع ۱۰۰٪ خالص و طبیعی اسیدهای چرب امگا ۳ که کیفیت پوست و مو را ارتقا داده و مفاصل را روان می‌کند.", - wikiId: "salmon-oil" - }, - "سیاه دانه": { - term: "سیاه دانه (Black Cumin)", - definition: "دانه گیاه سیاه دانه مصری با خواص قوی ضدآلرژی، تقویت‌کننده سیستم ایمنی و هضم بهتر غذا.", - wikiId: "black-cumin" - }, - "جلبک دریایی": { - term: "جلبک دریایی (Seaweed)", - definition: "جلبک قهوه‌ای غنی از اسیدهای آمینه و مواد معدنی کمیاب (به ویژه ید) جهت تقویت رنگدانه‌های پوشش، بینی و پنجه‌ها.", - wikiId: "seaweed" - }, - "پوسته تخم مرغ": { - term: "پودر پوسته تخم مرغ (Eggshell Powder)", - definition: "منبع کلسیم ارگانیک صد درصد خالص با جذب بسیار بالا و مناسب برای رژیم‌های بدون استخوان یا حساسیت‌های غذایی.", - wikiId: "eggshell" - }, - "پیت": { - term: "عصاره پیت (Peat Extract / Moor)", - definition: "عصاره طبیعی حاصل از تجزیه گیاهان در طول هزاران سال، غنی از اسیدهای هومیک برای تنظیم فلور گوارشی.", - wikiId: "peat-extract" - }, - "اسید دودکانوئیک": { - term: "اسید دودکانوئیک (Dodecanoic Acid)", - definition: "اسید چرب با منشأ گیاهی با اثر دفع‌کننده حشرات موذی نظیر کنه، کک و شپش از محیط زندگی پت.", - wikiId: "dodecanoic" - }, - "هیالورونات سدیم": { - term: "هیالورونات سدیم (Sodium Hyaluronate)", - definition: "روان‌کننده و رطوبت‌رسان طبیعی قرنیه چشم جهت شستشو و تسکین چشم‌های تحریک شده و گریان.", - wikiId: "hyaluronic" - }, - "روغن کالاندولا": { - term: "روغن کالاندولا و سنجد دریایی (Calendula & Sea Buckthorn)", - definition: "روغن‌های تسکین‌دهنده، ضدباکتری و التیام‌بخش پوست جهت بهبود سوزش، زخم‌های سطحی و خشکی پنجه‌ها.", - wikiId: "calendula-sea-buckthorn" - }, - "نقره کلوئیدی": { - term: "نقره کلوئیدی (Colloidal Silver)", - definition: "محلول استریل حاوی ذرات ریز نقره با اثرات قوی آنتی‌باکتریال و ضدالتهاب طبیعی جهت پاکسازی ملتحمه چشم و جلوگیری از عفونت‌های چشمی و پوستی.", - wikiId: "colloidal-silver" - }, - "رتینول پالمیتات": { - term: "رتینول پالمیتات / ویتامین A (Retinol Palmitate)", - definition: "فرمی پایدار از ویتامین A دارویی که باعث ترمیم لایه‌های مخاطی قرنیه چشم، بازسازی اپیتلیوم آسیب‌دیده و محافظت در برابر خشکی قرنیه می‌شود.", - wikiId: "retinol-palmitate" - }, - "روغن خولان دریایی": { - term: "روغن خولان دریایی / سنجد دریایی (Sea Buckthorn Oil)", - definition: "روغن غنی از ویتامین E، امگا ۷ و آنتی‌اکسیدان‌های کمیاب برای ترمیم سریع بافت‌های آسیب‌دیده، التهابات پوستی و ترک‌های پنجه.", - wikiId: "calendula-sea-buckthorn" - }, - "سنجد دریایی": { - term: "روغن سنجد دریایی (Sea Buckthorn Oil)", - definition: "روغن غنی از ویتامین E، امگا ۷ و آنتی‌اکسیدان‌های کمیاب برای ترمیم سریع بافت‌های آسیب‌دیده و ترک‌خورده پوست.", - wikiId: "calendula-sea-buckthorn" - }, - "وازلین": { - term: "وازلین با گرید دارویی (Medical Vaseline)", - definition: "پوشش نرم‌کننده و ایزوله‌کننده پوست که مانع تبخیر رطوبت لایه‌های اپیدرم شده و از پنجه‌ها در برابر نمک، یخ و زبری زمین محافظت می‌کند.", - wikiId: "vaseline" - }, - "پانتنول": { - term: "پانتنول / پیش‌ساز ویتامین B5 (Panthenol)", - definition: "ترکیب نفوذکننده و ترمیم‌کننده عمیق پوست که سرعت بازسازی سلولی را افزایش داده و خارش و التهاب پوست و پنجه را تسکین می‌دهد.", - wikiId: "panthenol" - }, - "عصاره دانه گریپ فروت": { - term: "عصاره دانه گریپ فروت (Grapefruit Seed Extract)", - definition: "منبع غنی بیوفلاونوئیدها و آنتی‌اکسیدان‌های طبیعی که با مهار باکتری‌های مولد پلاک، از تشکیل تارتار و جرم دندان جلوگیری می‌کند.", - wikiId: "grapefruit-seed" - }, - "گریپ فروت": { - term: "عصاره دانه گریپ فروت (Grapefruit Seed Extract)", - definition: "منبع غنی بیوفلاونوئیدها و آنتی‌اکسیدان‌های طبیعی که با مهار باکتری‌های مولد پلاک، از تشکیل تارتار و جرم دندان جلوگیری می‌کند.", - wikiId: "grapefruit-seed" - }, - "عصاره مارگوسا": { - term: "عصاره طبیعی درخت نیم / مارگوسا (Margosa Extract)", - definition: "عصاره گیاهی دورکننده حشرات با خواص ضد انگل، کک و کنه بدون استفاده از سموم شیمیایی آفت‌کش.", - wikiId: "dodecanoic" - }, - "خاک دیاتومه": { - term: "خاک دیاتومه ارگانیک (Diatomaceous Earth)", - definition: "ماده طبیعی حاصل از سنگ‌های رسوبی جلبک‌های تک‌سلولی جهت کنترل ارگانیک انگل‌ها و انباشت مواد سمی در روده.", - wikiId: "diatomaceous" - }, - "کنگر فرنگی": { - term: "عصاره کنگر فرنگی (Artichoke Extract)", - definition: "ترکیب گیاهی محافظ کبد و بهبوددهنده ترشح صفرا جهت ارتقای هضم چربی‌ها و پاکسازی متابولیک.", - wikiId: "artichoke" - }, - "مخمر آبجو": { - term: "مخمر آبجو (Brewer's Yeast)", - definition: "منبع غنی ویتامین‌های گروه B، اسیدهای آمینه و مواد معدنی برای سلامت پوست، درخشندگی موها و تقویت اشتهای حیوان.", - wikiId: "brewers-yeast" - }, - "پوست درخت بید": { - term: "عصاره پوست درخت بید (Willow Bark Extract)", - definition: "منبع طبیعی سالیسین با خواص ضدالتهابی و تسکین‌دهنده دردهای مفصلی و تاندون‌ها در حیوانات مسن.", - wikiId: "willow-bark" - }, - "زنجبیل": { - term: "عصاره زنجبیل (Ginger Extract)", - definition: "آنتی‌اکسیدان گیاهی قوی برای مهار رادیکال‌های آزاد، بهبود گردش خون در مفاصل و تسکین حالت تهوع و مشکلات گوارشی.", - wikiId: "ginger" - }, - "سرم طبیعی گاو": { - term: "سرم طبیعی خون گاو (Bovine Blood Serum)", - definition: "کنسانتره غنی از پروتئین‌ها و بیواکتیواتورهای طبیعی برای تحریک اشتها و تسریع بازگشت انرژی در دوره نقاهت.", - wikiId: "bovine-serum" - }, - "پودر خون گاو": { - term: "پودر خون گاو / هموگلوبین (Bovine Blood Powder)", - definition: "منبع ۱۰۰٪ طبیعی آهن آلی (هموگلوبین) و اسیدهای آمینه ضروری جهت اکسیژن‌رسانی به خون و عضله‌سازی در رژیم خام BARF.", - wikiId: "bovine-blood" - }, - "چربی گوشت گاو": { - term: "چربی تصفیه شده گاو (Beef Fat Powder)", - definition: "سوخت انرژی‌بخش حیوانی زودجذب جهت وزن‌گیری سریع، تامین کالری سگ‌های کاری و افزایش اشتهای سگ‌های بدخوراک.", - wikiId: "beef-fat" - }, - "روغن آرگان": { - term: "روغن آرگان خالص (Pure Argan Oil)", - definition: "روغن نایاب سرشار از فیتواسترول‌ها، اسکوالن و ویتامین E طبیعی برای درخشندگی موها، تغذیه پوست و تقویت غشاهای سلولی.", - wikiId: "argan-oil" - }, - "روغن دانه گل رز": { - term: "روغن دانه گل رز (Rosehip Seed Oil)", - definition: "منبع طبیعی اسیدهای چرب امگا ۳ و پروویتامین A برای ترمیم مخاط‌ها و لایه‌های محافظ پوست.", - wikiId: "rosehip-oil" - }, - "روغن گردو": { - term: "روغن گردو (Walnut Oil)", - definition: "روغن گیاهی غنی از اسیدهای چرب غیراشباع و آنتی‌اکسیدان‌ها برای سلامت سیستم عصبی و پوست.", - wikiId: "walnut-oil" - }, - "تورین": { - term: "تورین (Taurine)", - definition: "آمینو اسید بسیار ضروری برای گربه‌ها جهت جلوگیری از دژنراسیون شبکیه (نابینایی) و نارسایی قلبی.", - wikiId: "taurin" - }, - "گرید دارویی": { - term: "گرید دارویی (Pharmaceutical Grade)", - definition: "بالاترین سطح خلوص مواد اولیه؛ تهیه شده با استانداردهای دارویی انسان و کاملاً بی‌خطر در صورت لیسیده شدن توسط حیوان." - }, - "پلی گلیسریل-4-کاپرات": { - term: "پلی گلیسریل-4-کاپرات (Polyglyceryl-4 Caprate)", - definition: "امولسیفایر گیاهی ملایم و زیست‌تخریب‌پذیر حاصل از گلیسرول و اسیدهای چرب نارگیل جهت انحلال یکنواخت ترکیبات فعال بدون ایجاد سوزش پوست.", - wikiId: "polyglyceryl-caprate" - }, - "کربومر": { - term: "کربومر دارویی (Carbomer / Polyacrylic Acid)", - definition: "پلیمر قوام‌دهنده و ویسکوزکننده فرمولاسیون‌های ژل که پایداری مواد فعال بر سطح دندان و پوست را افزایش می‌دهد.", - wikiId: "carbomer" - }, - "پلی گلیسریل": { - term: "پلی گلیسریل-4-کاپرات (Polyglyceryl-4 Caprate)", - definition: "امولسیفایر گیاهی ملایم حاصل از گلیسرول و اسیدهای چرب نارگیل جهت انحلال یکنواخت ترکیبات فعال بدون ایجاد سوزش.", - wikiId: "polyglyceryl-caprate" - }, - "اتانول": { - term: "اتانول دارویی (Pharmaceutical Ethanol)", - definition: "حلال استریل و عصاره‌گیر پایه حیوانی و گیاهی با غلظت استاندارد و ایمن برای نگهداری محلول‌های بیواکتیو.", - wikiId: "ethanol" - }, - "دکستروز": { - term: "دکستروز / گلوکز مونوهیدرات (Dextrose)", - definition: "قند ساده زودجذب و منبع فوری انرژی سلولی برای حیوانات ضعیف، بیمار یا دچار افت قند خون.", - wikiId: "dextrose" - }, - "آب پنیر": { - term: "پودر آب پنیر (Whey Powder)", - definition: "منبع غنی پروتئین‌های زودهضم، کلسیم ارگانیک و اسیدهای آمینه شاخه‌دار جهت رشد و بالانس غذایی.", - wikiId: "whey-powder" - }, - "نشاسته سیب زمینی": { - term: "نشاسته سیب زمینی (Potato Starch)", - definition: "کربوهیدرات پیچیده و عامل اتصال‌دهنده طبیعی در قرص‌ها و ژل‌ها بدون ایجاد حساسیت گوارشی.", - wikiId: "potato-starch" - }, - "لاکتوز": { - term: "لاکتوز دارویی (Lactose)", - definition: "قند طبیعی شیر به عنوان پایه انرژی‌بخش و طعم‌دهنده طبیعی در مکمل‌های جایگزین شیر مادر.", - wikiId: "lactose" - }, - "چربی نارگیل": { - term: "چربی و روغن نارگیل (Coconut Fat)", - definition: "منبع اسیدهای چرب زنجیره متوسط (MCT) جهت تامین انرژی سریع مغز و دستگاه گوارش.", - wikiId: "coconut-fat" - }, - "پروتئین ایزوله سویا": { - term: "پروتئین ایزوله سویا (Soy Protein Isolate)", - definition: "پروتئین خالص گیاهی با قابلیت هضم فوق‌العاده بالا برای ساخت بافت‌های عضلانی.", - wikiId: "soy-protein" - }, - "پودر تخم مرغ کامل": { - term: "پودر تخم مرغ کامل (Whole Egg Powder)", - definition: "غذای کامل سرشار از پروتئین‌های با ارزش بیولوژیک بالا، لسیپین و اسیدهای چرب ضروری.", - wikiId: "egg-powder" - }, - "کربنات کلسیم": { - term: "کربنات کلسیم (Calcium Carbonate)", - definition: "منبع آلی معدنی کلسیم برای استحکام استخوان‌ها، دندان‌ها و عملکرد صحیح انقباض عضلانی.", - wikiId: "calcium-carbonate" - }, - "تری کلسیم فسفات": { - term: "تری کلسیم فسفات (Tricalcium Phosphate)", - definition: "ترکیب معدنی فوق‌العاده شکل‌دهنده ساختار استخوان‌ها (بیش از ۵۰٪) و مینای دندان‌ها (بیش از ۹۰٪).", - wikiId: "tricalcium-phosphate" - }, - "ویتامین A": { - term: "ویتامین A (Retinol)", - definition: "ویتامین محلول در چربی ضروری برای سلامت بینایی، بازسازی مخاط و سیستم ایمنی.", - wikiId: "vitamins" - }, - "ویتامین E": { - term: "ویتامین E (Tocopherol)", - definition: "آنتی‌اکسیدان قوی محافظ غشای سلولی در برابر استرس اکسیداتیو و رادیکال‌های آزاد.", - wikiId: "vitamins" - }, - "ویتامین C": { - term: "ویتامین C (L-Ascorbic Acid)", - definition: "ویتامین تقویت‌کننده ساخت کلاژن، لثه‌ها و سیستم ایمنی بدن.", - wikiId: "vitamins" - }, - "ویتامین B1": { - term: "ویتامین B1 (Thiamine)", - definition: "ویتامین حیاتی برای سیستم عصبی و متابولیسم کربوهیدرات‌ها.", - wikiId: "vitamins" - }, - "ویتامین B2": { - term: "ویتامین B2 (Riboflavin)", - definition: "کوآنزیم فاکتورهای رشد، درخشندگی پوشش مویی و سلامت پوست.", - wikiId: "vitamins" - }, - "ویتامین B6": { - term: "ویتامین B6 (Pyridoxine)", - definition: "ویتامین ضروری برای سنتز اسیدهای آمینه و هموگلوبین خون.", - wikiId: "vitamins" - }, - "ویتامین B12": { - term: "ویتامین B12 (Cobalamin)", - definition: "فاکتور کلیدی خون‌سازی و حفظ سلامت رشته‌های عصبی.", - wikiId: "vitamins" - }, - "اسید نیکوتینیک": { - term: "اسید نیکوتینیک / نیاسین (Niacin / Vitamin B3)", - definition: "ویتامین تنظیم‌کننده پیگمنت‌های پوست و متابولیسم چربی‌ها.", - wikiId: "vitamins" - }, - "سلنیوم": { - term: "سلنیوم (Selenium)", - definition: "عنصر کمیاب آنتی‌اکسیدانی که همراه با ویتامین E از تخریب سلولی جلوگیری می‌کند.", - wikiId: "selenium" - }, - "روی": { - term: "روی (Zinc)", - definition: "عنصر ضروری برای ترمیم زخم‌ها، رشد موها و تقویت سیستم ایمنی.", - wikiId: "zinc" - }, - "مس": { - term: "مس (Copper)", - definition: "عنصر کاتالیزور در سنتز هموگلوبین و پیگمنت‌های رنگی مو.", - wikiId: "copper" - }, - "آهن": { - term: "آهن (Iron)", - definition: "ماده معدنی اصلی ساخت هموگلوبین و اکسیژن‌رسانی به بافت‌ها.", - wikiId: "iron" - }, - "متیونین": { - term: "متیونین (DL-Methionine)", - definition: "اسید آمینه گوگرددار ضروری برای سلامت مفاصل، کبد و رشد مو.", - wikiId: "methionine" - }, - "کیک بذر کتان": { - term: "کیک بذر کتان (Flaxseed Cake)", - definition: "منبع غنی فیبرهای حل‌شونده و اسید چرب آلفا لینولنیک برای دستگاه گوارش.", - wikiId: "flaxseed" - }, - "تفاله سیب": { - term: "تفاله سیب ارگانیک (Apple Pomace)", - definition: "منبع پری‌بیوتیک طبیعی پکتین جهت تنظیم فلور و حرکات روده.", - wikiId: "apple-pomace" - }, - "پودر یونجه سبز": { - term: "پودر یونجه سبز (Alfalfa Powder)", - definition: "گیاه غنی از کلروفیل، ویتامین K و مواد معدنی قلیایی‌کننده.", - wikiId: "alfalfa" - }, - "فیبر نخود فرنگی": { - term: "فیبر نخود فرنگی (Pea Fiber)", - definition: "فیبر غیرقابل هضم پاک‌کننده مکانیکی جدار روده و حجم‌دهنده مدفوع.", - wikiId: "pea-fiber" - }, - "تفاله هویج": { - term: "تفاله هویج (Carrot Pomace)", - definition: "سرشار از بتاکاروتن و فیبر برای سلامت بینایی و گوارش.", - wikiId: "carrot-pomace" - }, - "روغن کلزا": { - term: "روغن کلزا (Rapeseed Oil)", - definition: "روغن گیاهی غنی از امگا ۳ و ۶ برای لطافت و نرمی پوست.", - wikiId: "rapeseed-oil" - }, - "روغن ماهی": { - term: "روغن خالص ماهی (Fish Oil)", - definition: "منبع اسیدهای چرب امگا ۳ برای سلامت قلب، مفاصل و پوست.", - wikiId: "salmon-oil" - }, - "IFS": { - term: "استاندارد بین‌المللی IFS", - definition: "سخت‌گیرانه‌ترین استاندارد ایمنی و کیفیت محصولات دارویی و غذایی در اروپا." - }, - "HACCP": { - term: "سیستم کنترل بحران HACCP", - definition: "تضمین‌کننده عدم وجود هرگونه آلودگی فیزیکی، شیمیایی یا میکروبی در زنجیره تولید محصولات." - } -}; +export const SCIENTIFIC_TERMS: Record = {}; diff --git a/frontend/application/lib/types.ts b/frontend/application/lib/types.ts index 4838cbf2..06aeefac 100644 --- a/frontend/application/lib/types.ts +++ b/frontend/application/lib/types.ts @@ -1,31 +1,107 @@ export interface Banner { - id?: string; - imageUrl?: string; - title?: string; + id: string; + title: string; subtitle?: string; - link?: string; -} - -export interface VetTestimonial { - id?: string; - name?: string; - role?: string; - text?: string; - avatarUrl?: string; + imageUrl: string; + linkUrl?: string; + position: string; + isActive: boolean; + order: number; + createdAt?: string; + updatedAt?: string; } export interface SmartAdvisorRule { - id?: string; - condition?: string; - recommendation?: string; - category?: string; - symptom?: string; - recommendedProductSlug?: string; + id: string; + condition: string; + targetPetType?: string; + recommendedProduct: string; + reason: string; + createdAt?: string; + product?: { + id: string; + nameFa: string; + slug: string; + }; +} + +export interface Testimonial { + id: string; + authorName: string; + roleTitle?: string; + avatarUrl?: string; + content: string; + rating: number; + isFeatured: boolean; + isActive: boolean; + order: number; + createdAt?: string; + updatedAt?: string; +} + +export interface Ingredient { + id: string; + nameFa: string; + nameEn: string; + slug: string; + description?: string; + scientificName?: string; + imageUrl?: string; + benefits: string[]; + createdAt?: string; + updatedAt?: string; +} + +export interface Prescription { + id: string; + userId: string; + petId?: string; + fileUrl: string; + status: 'PENDING' | 'APPROVED' | 'REJECTED'; + notes?: string; + adminNotes?: string; + createdAt?: string; + updatedAt?: string; +} + +export interface B2BInquiry { + id: string; + companyName: string; + contactName: string; + email: string; + phone: string; + businessType: string; + estimatedVolume?: string; + message: string; + status: 'PENDING' | 'CONTACTED' | 'APPROVED' | 'REJECTED'; + adminNotes?: string; + createdAt?: string; + updatedAt?: string; +} + +export interface PartnerAccount { + id: string; + userId: string; + companyName: string; + taxId?: string; + creditLimit: string | number; + discountTier: string; + status: string; + createdAt?: string; + updatedAt?: string; +} + +export interface DosageConfig { + unit: string; + baseWeightKg: number; + baseDose: number; + maxDailyDose: number; + instructions: string; } export interface HomeApiResponse { heroBanners?: Banner[]; - vetTestimonials?: VetTestimonial[]; + vetTestimonials?: Testimonial[]; smartAdvisorRules?: SmartAdvisorRule[]; [key: string]: unknown; } @@ -35,3 +111,4 @@ export type NavigationTarget = string | { view: string }; export interface NavigationHandler { (target: NavigationTarget): void; } +