From 976dfcd61061d05d5d6a37146d1e8955ae60e189 Mon Sep 17 00:00:00 2001 From: parsaaghayi Date: Fri, 12 Jun 2026 01:10:52 +0330 Subject: [PATCH] feat: interactive pages migrated to Next.js (Dashboard, Checkout, Profile, Wiki) --- frontend/application/app/checkout/page.tsx | 5 +++++ frontend/application/app/dashboard/page.tsx | 5 +++++ frontend/application/app/profile/page.tsx | 5 +++++ frontend/application/app/wiki/page.tsx | 5 +++++ frontend/application/components/CheckoutPage.tsx | 14 ++++++++------ frontend/application/components/IngredientWiki.tsx | 13 ++++++++----- frontend/application/components/PetProfile.tsx | 11 ++++++----- frontend/application/components/UserDashboard.tsx | 11 +++++++---- 8 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 frontend/application/app/checkout/page.tsx create mode 100644 frontend/application/app/dashboard/page.tsx create mode 100644 frontend/application/app/profile/page.tsx create mode 100644 frontend/application/app/wiki/page.tsx diff --git a/frontend/application/app/checkout/page.tsx b/frontend/application/app/checkout/page.tsx new file mode 100644 index 0000000..f0b77b7 --- /dev/null +++ b/frontend/application/app/checkout/page.tsx @@ -0,0 +1,5 @@ +import CheckoutPage from "../../components/CheckoutPage"; + +export default function Checkout() { + return ; +} diff --git a/frontend/application/app/dashboard/page.tsx b/frontend/application/app/dashboard/page.tsx new file mode 100644 index 0000000..9816fa9 --- /dev/null +++ b/frontend/application/app/dashboard/page.tsx @@ -0,0 +1,5 @@ +import UserDashboard from "../../components/UserDashboard"; + +export default function DashboardPage() { + return ; +} diff --git a/frontend/application/app/profile/page.tsx b/frontend/application/app/profile/page.tsx new file mode 100644 index 0000000..4642db7 --- /dev/null +++ b/frontend/application/app/profile/page.tsx @@ -0,0 +1,5 @@ +import PetProfile from "../../components/PetProfile"; + +export default function ProfilePage() { + return ; +} diff --git a/frontend/application/app/wiki/page.tsx b/frontend/application/app/wiki/page.tsx new file mode 100644 index 0000000..bdb599e --- /dev/null +++ b/frontend/application/app/wiki/page.tsx @@ -0,0 +1,5 @@ +import IngredientWiki from "../../components/IngredientWiki"; + +export default function WikiPage() { + return ; +} diff --git a/frontend/application/components/CheckoutPage.tsx b/frontend/application/components/CheckoutPage.tsx index 396fc1c..edde4ef 100644 --- a/frontend/application/components/CheckoutPage.tsx +++ b/frontend/application/components/CheckoutPage.tsx @@ -23,8 +23,10 @@ import { useUserStore } from "../store/userStore"; import { Product } from "../data/products"; import { productService } from "../services/productService"; import { toast } from "sonner"; +import { useRouter } from 'next/navigation'; -export default function CheckoutPage({ onBack, onComplete }: { onBack: () => void; onComplete: (orderId: string) => void }) { +export default function CheckoutPage() { + const router = useRouter(); const { items, getTotal, getSubtotal, getDiscount, isSubscribed, charityDonation, setCharityDonation, addOrder, clearCart } = useCartStore(); const { getActivePet, updatePet } = usePetStore(); const { profile, updateProfile } = useUserStore(); @@ -94,8 +96,8 @@ export default function CheckoutPage({ onBack, onComplete }: { onBack: () => voi } clearCart(); - onComplete(orderId); toast.success("سفارش شما با موفقیت ثبت شد و به پرونده سلامت همدمتان اضافه شد!"); + router.push('/dashboard'); } catch (err: any) { toast.error(err.message || "خطا در ثبت سفارش. لطفاً مجدداً تلاش کنید."); } finally { @@ -111,7 +113,7 @@ export default function CheckoutPage({ onBack, onComplete }: { onBack: () => voi

سبد خرید شما خالی است

- + ); @@ -124,7 +126,7 @@ export default function CheckoutPage({ onBack, onComplete }: { onBack: () => voi {/* Mobile Navigation & Breadcrumbs */}
- سبد خرید + router.push('/shop')}>سبد خرید نهایی‌سازی سفارش
@@ -140,7 +142,7 @@ export default function CheckoutPage({ onBack, onComplete }: { onBack: () => voi {/* Desktop Breadcrumbs (Hidden on Mobile) */}
- خانه + router.push('/')}>خانه درگاه پرداخت امن و نهایی‌سازی
diff --git a/frontend/application/components/IngredientWiki.tsx b/frontend/application/components/IngredientWiki.tsx index 1355305..6e2fd25 100644 --- a/frontend/application/components/IngredientWiki.tsx +++ b/frontend/application/components/IngredientWiki.tsx @@ -6,7 +6,10 @@ import { FlaskConical, CheckCircle2, ChevronRight, ChevronLeft, Beaker } from "l import { useSettingsStore } from "../store/settingsStore"; import { productService } from "../services/productService"; -export default function IngredientWiki({ onProductClick, onBack }: { onProductClick: (p: Product) => void, onBack?: () => void }) { +import { useRouter } from 'next/navigation'; + +export default function IngredientWiki() { + const router = useRouter(); const texts = useSettingsStore(state => state.texts); const [products, setProducts] = useState([]); @@ -33,7 +36,7 @@ export default function IngredientWiki({ onProductClick, onBack }: { onProductCl {/* Mobile Navigation & Breadcrumbs */}
- کانینا + router.push('/')}>کانینا دانشنامه علمی
@@ -49,7 +52,7 @@ export default function IngredientWiki({ onProductClick, onBack }: { onProductCl {/* Desktop Breadcrumbs */}
- خانه + router.push('/')}>خانه دانشنامه مواد نایاب و ارگانیک
@@ -122,7 +125,7 @@ export default function IngredientWiki({ onProductClick, onBack }: { onProductCl {hasIngredient.length > 0 ? hasIngredient.map(p => (
onProductClick(p)} + onClick={() => router.push(`/shop/${p.id}`)} className="bg-white rounded-[2.5rem] p-6 shadow-xl hover:scale-105 transition-transform cursor-pointer group" > {p.name} diff --git a/frontend/application/components/PetProfile.tsx b/frontend/application/components/PetProfile.tsx index 6f9ea80..9e73338 100644 --- a/frontend/application/components/PetProfile.tsx +++ b/frontend/application/components/PetProfile.tsx @@ -35,12 +35,13 @@ import SafeImage from "./SafeImage"; import { toast } from "sonner"; import { toPersian, cn } from "../lib/utils"; -export default function PetProfile({ onProductClick, onBack, initialView, advisorNeed }: { - onProductClick: (p: Product) => void, - onBack?: () => void, +import { useRouter } from 'next/navigation'; + +export default function PetProfile({ initialView, advisorNeed }: { initialView?: "index" | "detail" | "add" | "edit", advisorNeed?: string | null }) { + const router = useRouter(); const { pets, activePetId, addPet, removePet, setActivePet, getActivePet, updatePet, addReminder, toggleReminder, addHealthLog } = usePetStore(); const { orders } = useCartStore(); const activePet = getActivePet(); @@ -553,7 +554,7 @@ export default function PetProfile({ onProductClick, onBack, initialView, adviso onClick={() => { if (view === "edit") setView("detail"); else if (pets.length > 0) setView("index"); - else onBack?.(); + else router.back(); }} className="absolute top-8 left-8 text-medical-gray-400 hover:text-canina-blue transition-colors text-[10px] font-black uppercase tracking-widest" > @@ -757,7 +758,7 @@ export default function PetProfile({ onProductClick, onBack, initialView, adviso {isLow && ( +
) : (