diff --git a/index.html b/index.html deleted file mode 100644 index 3dad3722..00000000 --- a/index.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - Canina - مراقبت هوشمند از پت - - - -
- - - - diff --git a/public/locales/fa/common.json b/public/locales/fa/common.json deleted file mode 100644 index a0aafaf7..00000000 --- a/public/locales/fa/common.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "api": { - "errors": { - "400": "درخواست شما نامعتبر است. لطفاً داده‌ها را بررسی کنید.", - "401": "دسترسی غیرمجاز. لطفا دوباره وارد شوید.", - "403": "شما اجازه دسترسی به این بخش را ندارید.", - "404": "سرویس یا منبع مورد نظر یافت نشد.", - "500": "خطای داخلی سرور. تیم فنی در حال بررسی است.", - "insufficient_balance": "موجودی کیف پول شما کافی نیست. لطفا حساب خود را شارژ کنید.", - "breed_mismatch": "این محصول با نژاد انتخاب شده پت شما سازگار نیست.", - "invalid_coupon": "کد تخفیف وارد شده معتبر نیست یا منقضی شده است.", - "order_failed": "متاسفانه ثبت سفارش با خطا مواجه شد. لطفا دوباره تلاش کنید." - } - }, - "messages": { - "loading": "در حال دریافت اطلاعات از سرور...", - "saving": "در حال ذخیره‌سازی تغییرات...", - "success_update": "تغییرات با موفقیت ذخیره شد." - } -} diff --git a/public/manifest.json b/public/manifest.json deleted file mode 100644 index 4ca30f30..00000000 --- a/public/manifest.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "کانینا ایران | Canina Iran", - "short_name": "Canina", - "description": "مکمل‌های تخصصی حیوانات خانگی آلمان", - "start_url": "/", - "display": "standalone", - "background_color": "#ffffff", - "theme_color": "#005EB8", - "icons": [ - { - "src": "https://upload.wikimedia.org/wikipedia/commons/d/d5/Paw_Print.svg", - "sizes": "192x192", - "type": "image/svg+xml" - }, - { - "src": "https://upload.wikimedia.org/wikipedia/commons/d/d5/Paw_Print.svg", - "sizes": "512x512", - "type": "image/svg+xml" - } - ] -} diff --git a/public/sw.js b/public/sw.js deleted file mode 100644 index d2b62216..00000000 --- a/public/sw.js +++ /dev/null @@ -1,23 +0,0 @@ -const CACHE_NAME = 'canina-v1'; -const ASSETS_TO_CACHE = [ - '/', - '/index.html', - '/src/main.tsx', - '/src/index.css' -]; - -self.addEventListener('install', (event) => { - event.waitUntil( - caches.open(CACHE_NAME).then((cache) => { - return cache.addAll(ASSETS_TO_CACHE); - }) - ); -}); - -self.addEventListener('fetch', (event) => { - event.respondWith( - caches.match(event.request).then((response) => { - return response || fetch(event.request); - }) - ); -}); diff --git a/src/App.tsx b/src/App.tsx deleted file mode 100644 index d9c2965f..00000000 --- a/src/App.tsx +++ /dev/null @@ -1,430 +0,0 @@ -/** - * @license - * SPDX-License-Identifier: Apache-2.0 - */ - -import { useState, useEffect, lazy, Suspense } from "react"; -import Header from "./components/Header"; -import Hero from "./components/Hero"; -import Footer from "./components/Footer"; -import { Toaster } from "sonner"; -import { Product } from "./data/products"; -import { useCartStore } from "./store/cartStore"; -import { usePetStore } from "./store/usePetStore"; -import { useUserStore } from "./store/userStore"; -import { useSettingsStore } from "./store/settingsStore"; -import { NetworkBanner } from './components/NetworkBanner'; -import { ErrorBoundary } from './components/ErrorBoundary'; -import { NotFoundPage } from './components/ErrorPages'; -import { toast } from "sonner"; -import labImage from "./assets/images/regenerated_image_1779109861747.png"; - -import ArchivePage from "./components/ArchivePage"; - -// Lazy Loaded Components -const ProductPage = lazy(() => import("./components/ProductPage")); -const PetProfile = lazy(() => import("./components/PetProfile")); -const UserDashboard = lazy(() => import("./components/UserDashboard")); -const SearchResultsPage = lazy(() => import("./components/SearchResultsPage")); -const IngredientWiki = lazy(() => import("./components/IngredientWiki")); -const BlogPage = lazy(() => import("./components/BlogPage")); -const VideosPage = lazy(() => import("./components/VideosPage")); -const CheckoutPage = lazy(() => import("./components/CheckoutPage")); -const OrderSuccess = lazy(() => import("./components/OrderSuccess")); -const OrderTracking = lazy(() => import("./components/OrderTracking")); -const SmartAdvisor = lazy(() => import("./components/SmartAdvisor")); -const LoginModal = lazy(() => import("./components/LoginModal")); -const CartDrawer = lazy(() => import("./components/CartDrawer")); -const B2BPortal = lazy(() => import("./components/B2BPortal")); -const FeaturedProducts = lazy(() => import("./components/FeaturedProducts")); -const VetGallery = lazy(() => import("./components/VetGallery")); - -type View = "home" | "shop" | "wiki" | "product-detail" | "profile" | "checkout" | "search" | "order-success" | "order-tracking" | "blog" | "videos" | "user-dashboard"; - -function LoadingFallback() { - return ( -
-
- در حال آماده‌سازی لابراتوار... -
- ); -} - -export default function App() { - const [currentView, setCurrentView] = useState("home"); - const [subView, setSubView] = useState(null); - const [advisorRecommendation, setAdvisorRecommendation] = useState(null); - const [advisorData, setAdvisorData] = useState(null); - const [selectedProduct, setSelectedProduct] = useState(null); - const [lastOrderId, setLastOrderId] = useState(null); - const [initialCategory, setInitialCategory] = useState("all"); - const [initialSearch, setInitialSearch] = useState(""); - const [isCartOpen, setIsCartOpen] = useState(false); - const [showB2B, setShowB2B] = useState(false); - const [isLoggedIn, setIsLoggedIn] = useState(false); - const [showLoginModal, setShowLoginModal] = useState(false); - const [isLoading, setIsLoading] = useState(true); - const [searchQuery, setSearchQuery] = useState(""); - - const { fetchProfile, isLoggedIn: storeIsLoggedIn } = useUserStore(); - const fetchSettings = useSettingsStore(state => state.fetchSettings); - const getText = useSettingsStore(state => state.getText); - - useEffect(() => { - const init = async () => { - await fetchSettings(); - const token = localStorage.getItem('accessToken'); - if (token) { - try { - await fetchProfile(); - } catch (e) { - console.error("Auth init failed:", e); - } - } - setIsLoading(false); - }; - init(); - }, [fetchProfile, fetchSettings]); - - useEffect(() => { - setIsLoggedIn(storeIsLoggedIn); - }, [storeIsLoggedIn]); - useEffect(() => { - const handlePopState = (event: PopStateEvent) => { - const params = new URLSearchParams(window.location.search); - const category = params.get("category") || "all"; - const search = params.get("search") || ""; - - setInitialCategory(category); - setInitialSearch(search); - setCurrentView("shop"); - }; - - window.addEventListener("popstate", handlePopState); - return () => window.removeEventListener("popstate", handlePopState); - }, []); - - const { clearCart, addOrder, getTotal, items } = useCartStore(); - const { getActivePet, pets } = usePetStore(); - - // Global Scroll To Top on view change - useEffect(() => { - window.scrollTo({ top: 0, behavior: "smooth" }); - }, [currentView]); - - const handleProductClick = (product: Product) => { - setSelectedProduct(product); - setCurrentView("product-detail"); - window.scrollTo({ top: 0, behavior: 'smooth' }); - }; - - const navigateToShop = (category: string = "all", search: string = "") => { - // Update URL with search params - const params = new URLSearchParams(); - if (category && category !== "all") params.set("category", category); - if (search) params.set("search", search); - - const newUrl = params.toString() ? `?${params.toString()}` : "/shop"; - window.history.pushState({ category, search }, "", newUrl); - - setInitialCategory(category); - setInitialSearch(search); - setCurrentView("shop"); - window.scrollTo({ top: 0, behavior: "smooth" }); - }; - - const navigateToWiki = () => { - setCurrentView("wiki"); - window.scrollTo({ top: 0, behavior: 'smooth' }); - }; - - const handleNavigate = (v: any) => { - if (typeof v === 'object') { - setCurrentView(v.view); - setSubView(v.subview || null); - } else { - setCurrentView(v); - setSubView(null); - } - }; - - const navigateToProfile = (subview: any = "index") => { - setCurrentView("profile"); - setSubView(subview); - window.scrollTo({ top: 0, behavior: 'smooth' }); - }; - - const navigateToDashboard = () => { - setCurrentView("user-dashboard"); - window.scrollTo({ top: 0, behavior: 'smooth' }); - }; - - const handleCheckout = () => { - setIsCartOpen(false); - setCurrentView("checkout"); - window.scrollTo({ top: 0, behavior: 'smooth' }); - }; - - const handleSearch = (q: string) => { - setSearchQuery(q); - setCurrentView("search"); - window.scrollTo({ top: 0, behavior: 'smooth' }); - }; - - const finalizeOrder = (orderId: string) => { - setLastOrderId(orderId); - setCurrentView("order-success"); - window.scrollTo({ top: 0, behavior: 'smooth' }); - }; - - const handleAdvisorComplete = (data: any) => { - setAdvisorData(data); - - if (!isLoggedIn) { - setShowLoginModal(true); - } else { - processAdvisorResult(data); - } - }; - - const processAdvisorResult = (data?: any) => { - const d = data || advisorData; - if (!d) return; - - // Map medical conditions to a broad recommendation category for the suggested items logic in PetProfile - if (d.medicalConditions.includes("جراحی مفاصل")) setAdvisorRecommendation("joints"); - else if (d.medicalConditions.includes("مشکلات گوارشی")) setAdvisorRecommendation("digestion"); - else if (d.medicalConditions.includes("ریزش موی شدید")) setAdvisorRecommendation("skin"); - else if (d.medicalConditions.includes("بی‌اشتهایی") || d.medicalConditions.includes("زایمان اخیر") || d.medicalConditions.includes("بارداری")) setAdvisorRecommendation("vitamins"); - - // Clear recommended items and add the pet to the store - const { addPet } = usePetStore.getState(); - addPet(d); - - toast.success(`تحلیل سلامت ${d.name} آماده است! شناسنامه صادر شد.`); - navigateToProfile("detail"); - setAdvisorData(null); - }; - - const handleLogin = () => { - setIsLoggedIn(true); - setShowLoginModal(false); - - if (advisorData) { - toast.success(`خوش آمدید! مشخصات ${advisorData.name} در شناسنامه ثبت شد.`); - processAdvisorResult(); - } else { - toast.success("خوش آمدید!"); - } - }; - - const renderView = () => { - if (isLoading) { - return ( -
-
-
-
C
- Canina Pharma Laboratory -
-
- ); - } - - return ( - }> - {(() => { - switch (currentView) { - case "user-dashboard": - return setCurrentView("home")} onNavigate={handleNavigate} />; - case "search": - return ( - setCurrentView("home")} - /> - ); - case "checkout": - return setIsCartOpen(true)} onComplete={finalizeOrder} />; - case "product-detail": - return selectedProduct ? ( - setCurrentView("shop")} - onProductClick={handleProductClick} - onWikiNavigate={() => setCurrentView("wiki")} - onShopNavigate={navigateToShop} - /> - ) : null; - case "shop": - return setCurrentView("home")} onShopNavigate={navigateToShop} />; - case "home": - return ( - <> - navigateToProfile("detail")} onShopNavigate={() => navigateToShop()} /> - - navigateToShop()} /> - - - {/* Navigation to Sections */} -
-
-
navigateToShop()} - className="bg-white p-12 rounded-[3.5rem] border border-medical-gray-200 shadow-sm hover:shadow-2xl hover:-translate-y-2 transition-all cursor-pointer group" - > -

فروشگاه تخصصی

-

دسترسی به تمامی محصولات بر اساس علائم بالینی و نیازهای پت شما.

-
- کاتالوگ کامل محصولات - ← -
-
-
-

دانشنامه علمی

-

آشنایی با ترکیبات نایاب و استانداردهای دارویی محصولات آلمانی کانینا.

-
- مطالعه مقالات تخصصی - ← -
-
-
-
- - {/* About Section Teaser */} -
-
-
-
- Laboratory -
-
{getText('about_teaser_quality_title', 'کیفیت')}
-
{getText('about_teaser_quality_desc', 'استانداردهای فوق‌دارویی')}
-
-
-
-
{getText('about_teaser_badge', 'میراث ما از آلمان')}
-

- {getText('about_teaser_title', 'چرا برند آلمانی Canina مرجع دامپزشکان است؟')} -

-
- {[ - { title: getText('about_teaser_feat1_title', 'مواد اولیه نایاب'), desc: getText('about_teaser_feat1_desc', 'استفاده از پودر صدف لب‌سبز اصل نیوزیلند و مواد ارگانیک با گرید دارویی.') }, - { title: getText('about_teaser_feat2_title', 'فاقد مواد نگهدارنده'), desc: getText('about_teaser_feat2_desc', 'تمامی محصولات ۱۰۰٪ طبیعی و فاقد رنگ‌های مصنوعی و طعم‌دهنده‌های شیمیایی هستند.') }, - { title: getText('about_teaser_feat3_title', 'تاییدیه اروپا'), desc: getText('about_teaser_feat3_desc', 'مطابق با سخت‌گیرانه‌ترین استانداردهای ایمنی مواد غذایی و دارویی در اتحادیه اروپا.') } - ].map((item, idx) => ( -
-
- {idx + 1} -
-
-

{item.title}

-

{item.desc}

-
-
- ))} -
-
-
-
- - ); - case "wiki": - return setCurrentView("home")} />; - case "profile": - return setCurrentView("home")} initialView={subView} advisorNeed={advisorRecommendation} />; - case "order-success": - return lastOrderId ? : null; - case "order-tracking": - return setCurrentView("home")} />; - case "blog": - return setCurrentView("home")} onProductClick={handleProductClick} />; - case "videos": - return setCurrentView("home")} />; - default: - return setCurrentView("home")} />; - } - })()} -
- ); - }; - - return ( - -
- -
setIsCartOpen(true)} - onSearch={handleSearch} - onB2BOpen={() => setShowB2B(true)} - /> -
- {renderView()} - - {/* Call to Action */} -
-
-
- {Array.from({length: 100}).map((_, i) => ( -
- ))} -
-
-
-

- {getText('cta_title', 'می‌خواهید بدانید کدام محصول برای پت شما مناسب‌تر است؟')} -

-

- {getText('cta_subtitle', 'تیم متخصص دامپزشکی کانینا ایران آماده پاسخگویی به سوالات شماست.')} -

-
- - -
-
-
-
- -
setShowB2B(true)} /> - - {showB2B && setShowB2B(false)} />} - setIsCartOpen(false)} - onCheckout={handleCheckout} - onShopNavigate={navigateToShop} - /> - { - setShowLoginModal(false); - setAdvisorData(null); // Clear advisor data if closed without login - }} - onLogin={handleLogin} - petName={advisorData?.name} - isAdvisorContext={!!advisorData} - /> - - -
-
- ); -} diff --git a/src/assets/images/regenerated_image_1779109861747.png b/src/assets/images/regenerated_image_1779109861747.png deleted file mode 100644 index a41ae522..00000000 Binary files a/src/assets/images/regenerated_image_1779109861747.png and /dev/null differ diff --git a/src/components/AddressModal.tsx b/src/components/AddressModal.tsx deleted file mode 100644 index 441ae418..00000000 --- a/src/components/AddressModal.tsx +++ /dev/null @@ -1,290 +0,0 @@ -import React, { useState, useEffect } from "react"; -import { motion, AnimatePresence } from "motion/react"; -import { X, MapPin, User, Phone, Hash, Save, Check } from "lucide-react"; -import { toPersian, cn } from "../lib/utils"; -import { Address } from "../store/userStore"; -import { toast } from "sonner"; - -interface AddressModalProps { - isOpen: boolean; - onClose: () => void; - onSave: (address: Address) => void; - editingAddress?: Address | null; -} - -export default function AddressModal({ isOpen, onClose, onSave, editingAddress }: AddressModalProps) { - const [formData, setFormData] = useState>({ - title: "", - receptorName: "", - phone: "", - province: "", - city: "", - detail: "", - zipCode: "", - isDefault: false - }); - - const [errors, setErrors] = useState>({}); - const [isSubmitting, setIsSubmitting] = useState(false); - - useEffect(() => { - if (editingAddress) { - setFormData({ - title: editingAddress.title, - receptorName: editingAddress.receptorName, - phone: editingAddress.phone, - province: editingAddress.province, - city: editingAddress.city, - detail: editingAddress.detail, - zipCode: editingAddress.zipCode, - isDefault: editingAddress.isDefault - }); - } else { - setFormData({ - title: "", - receptorName: "", - phone: "", - province: "", - city: "", - detail: "", - zipCode: "", - isDefault: false - }); - } - setErrors({}); - setIsSubmitting(false); - }, [editingAddress, isOpen]); - - const normalizeDigits = (str: string) => { - const persianDigits = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g]; - const arabicDigits = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g]; - for (let i = 0; i < 10; i++) { - str = str.replace(persianDigits[i], i.toString()).replace(arabicDigits[i], i.toString()); - } - return str; - }; - - const validate = () => { - const newErrors: Record = {}; - if (!formData.title) newErrors.title = "لطفاً عنوان آدرس را وارد کنید"; - if (!formData.receptorName) newErrors.receptorName = "نام گیرنده را وارد کنید"; - - const normalizedPhone = normalizeDigits(formData.phone); - if (!normalizedPhone) { - newErrors.phone = "شماره تماس الزامی است"; - } else if (!/^09\d{9}$/.test(normalizedPhone)) { - newErrors.phone = "شماره موبایل وارد شده معتبر نیست"; - } - - if (!formData.province) newErrors.province = "استان را مشخص کنید"; - if (!formData.city) newErrors.city = "شهر را مشخص کنید"; - if (!formData.detail) newErrors.detail = "آدرس دقیق پستی را وارد کنید"; - - const normalizedZip = normalizeDigits(formData.zipCode); - if (!normalizedZip) { - newErrors.zipCode = "کد پستی الزامی است"; - } else if (!/^\d{10}$/.test(normalizedZip)) { - newErrors.zipCode = "کد پستی باید ۱۰ رقم باشد"; - } - - setErrors(newErrors); - return Object.keys(newErrors).length === 0; - }; - - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - if (validate()) { - setIsSubmitting(true); - // Simulate small delay for UX - setTimeout(() => { - onSave({ - ...formData, - phone: normalizeDigits(formData.phone), - zipCode: normalizeDigits(formData.zipCode), - id: editingAddress?.id || Math.random().toString(36).substr(2, 9), - isDefault: formData.isDefault - }); - toast.success(editingAddress ? "تغییرات آدرس با موفقیت ذخیره شد" : "آدرس جدید با موفقیت اضافه شد"); - setIsSubmitting(false); - onClose(); - }, 600); - } else { - toast.error("لطفاً موارد خطای فرم را اصلاح کنید"); - } - }; - - return ( - - {isOpen && ( -
- - -
-
-
- -
-

- {editingAddress ? "ویرایش آدرس ارسال" : "افزودن آدرس جدید"} -

-
- -
- -
-
- {/* Row 1: Title */} -
- - setFormData({...formData, title: e.target.value})} - className={cn("w-full bg-medical-gray-50 border rounded-2xl py-3 px-5 outline-none font-bold transition-all focus:ring-2 focus:ring-canina-blue/20", errors.title ? "border-red-300" : "border-medical-gray-100")} - placeholder="مثال: منزل اصلی" - /> - {errors.title &&

{errors.title}

} -
- -
- {/* Row 2: Name & Phone */} -
- - setFormData({...formData, receptorName: e.target.value})} - className={cn("w-full bg-medical-gray-50 border rounded-2xl py-3 px-5 outline-none font-bold transition-all focus:ring-2 focus:ring-canina-blue/20", errors.receptorName ? "border-red-300" : "border-medical-gray-100")} - placeholder="نام و نام‌خانوادگی..." - /> - {errors.receptorName &&

{errors.receptorName}

} -
-
- - setFormData({...formData, phone: e.target.value})} - className={cn("w-full bg-medical-gray-50 border rounded-2xl py-3 px-5 outline-none font-bold transition-all focus:ring-2 focus:ring-canina-blue/20 text-left", errors.phone ? "border-red-300" : "border-medical-gray-100")} - placeholder="09120000000" - dir="ltr" - /> - {errors.phone &&

{errors.phone}

} -
-
- -
- {/* Row 3: Province & City */} -
- - setFormData({...formData, province: e.target.value})} - className={cn("w-full bg-medical-gray-50 border rounded-2xl py-3 px-5 outline-none font-bold transition-all focus:ring-2 focus:ring-canina-blue/20", errors.province ? "border-red-300" : "border-medical-gray-100")} - placeholder="نام استان..." - /> - {errors.province &&

{errors.province}

} -
-
- - setFormData({...formData, city: e.target.value})} - className={cn("w-full bg-medical-gray-50 border rounded-2xl py-3 px-5 outline-none font-bold transition-all focus:ring-2 focus:ring-canina-blue/20", errors.city ? "border-red-300" : "border-medical-gray-100")} - placeholder="نام شهر..." - /> - {errors.city &&

{errors.city}

} -
-
- - {/* Row 4: Detail Address */} -
- -