feat: complete settings sync, standard UI inputs, prescriptions flow, pet profile and checkout enhancements
Deploy Canina / deploy (push) Failing after 51s
Deploy Canina / deploy (push) Failing after 51s
This commit is contained in:
1 parent
b3c60a1a7d
commit
6df92f03d7
32 files changed
+61750
-59151
No files matched your search
@@ -30,11 +30,12 @@ import { usePetStore, PetProfile as GlobalPetProfile, Reminder, HealthLog } from
|
||||
import { useCartStore } from "../lib/store/cartStore";
|
||||
import SafeImage from "./SafeImage";
|
||||
import SmartAdvisor from "./SmartAdvisor";
|
||||
import OrderDetailsModal from "./OrderDetailsModal";
|
||||
import { toast } from "sonner";
|
||||
import { toPersian, cn } from "../lib/utils";
|
||||
import api from "../lib/services/api";
|
||||
import api, { BASE_DOMAIN } from "../lib/services/api";
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
|
||||
export default function PetProfile({ initialView, advisorNeed, embedded = false }: {
|
||||
initialView?: "index" | "detail" | "add" | "edit",
|
||||
@@ -42,16 +43,26 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
embedded?: boolean
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { pets, addPet, removePet, setActivePet, getActivePet, updatePet, addReminder, toggleReminder, addHealthLog } = usePetStore();
|
||||
const { orders } = useCartStore();
|
||||
const activePet = getActivePet();
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [products, setProducts] = useState<Product[]>([]);
|
||||
const [prescriptions, setPrescriptions] = useState<any[]>([]);
|
||||
const [selectedInvoiceOrder, setSelectedInvoiceOrder] = useState<any | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
productService.getProducts({ limit: 999 })
|
||||
.then(res => setProducts(res.data))
|
||||
.catch(err => console.error("Error fetching products in PetProfile:", err));
|
||||
|
||||
api.get("/prescriptions")
|
||||
.then(res => {
|
||||
const data = Array.isArray(res.data) ? res.data : (res.data?.data || []);
|
||||
setPrescriptions(data);
|
||||
})
|
||||
.catch(() => {});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -67,7 +78,16 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
}
|
||||
}, [initialView]);
|
||||
|
||||
const [activePetTab, setActivePetTab] = useState<"health" | "orders">("health");
|
||||
const [activePetTab, setActivePetTab] = useState<"health" | "orders" | "prescriptions">("health");
|
||||
|
||||
// URL query param retention for tab
|
||||
useEffect(() => {
|
||||
const tabParam = searchParams.get('tab');
|
||||
if (tabParam && ['health', 'orders', 'prescriptions'].includes(tabParam)) {
|
||||
setActivePetTab(tabParam as "health" | "orders" | "prescriptions");
|
||||
}
|
||||
}, [searchParams]);
|
||||
|
||||
const [petToDelete, setPetToDelete] = useState<GlobalPetProfile | null>(null);
|
||||
|
||||
// Modal states
|
||||
@@ -95,6 +115,11 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
return orders.filter(o => o.petId === activePet.id);
|
||||
}, [activePet, orders]);
|
||||
|
||||
const petPrescriptions = useMemo(() => {
|
||||
if (!activePet) return [];
|
||||
return prescriptions.filter(rx => rx.petId === activePet.id || rx.pet?.id === activePet.id || rx.petName === activePet.name);
|
||||
}, [activePet, prescriptions]);
|
||||
|
||||
const petCharityTotal = useMemo(() => {
|
||||
return petOrders.reduce((sum, o) => sum + (Number(o.charityDonation) || 0), 0);
|
||||
}, [petOrders]);
|
||||
@@ -139,18 +164,39 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
});
|
||||
}
|
||||
|
||||
// Priority 2: Biological factors
|
||||
if (activePet.age > 7) {
|
||||
const heart = products.find(p => p.id === "herz-vital" || p.slug?.includes("herz"));
|
||||
if (heart && !picks.some(x => x.product.id === heart.id)) {
|
||||
picks.push({ product: heart, reason: "محافظت از قلب پتهای مسن" });
|
||||
}
|
||||
// Priority 2: Biological & Life-stage factors
|
||||
if (activePet.age >= 7) {
|
||||
const seniorSupplements = products.filter(p =>
|
||||
(p.id === "herz-vital" || p.slug?.includes("herz") || p.name.includes("قلب") || p.benefits?.includes("مسن")) &&
|
||||
(p.suitableFor === activePet.type || p.suitableFor === "هر دو")
|
||||
);
|
||||
seniorSupplements.forEach(p => {
|
||||
if (!picks.some(x => x.product.id === p.id)) {
|
||||
picks.push({ product: p, reason: "محافظت از قلب و مفاصل در سنین بالا" });
|
||||
}
|
||||
});
|
||||
} else if (activePet.age > 0 && activePet.age <= 1) {
|
||||
const growthSupplements = products.filter(p =>
|
||||
(p.name.includes("رشد") || p.benefits?.includes("تغذیه توله") || p.benefits?.includes("کلسیم")) &&
|
||||
(p.suitableFor === activePet.type || p.suitableFor === "هر دو")
|
||||
);
|
||||
growthSupplements.forEach(p => {
|
||||
if (!picks.some(x => x.product.id === p.id)) {
|
||||
picks.push({ product: p, reason: "تغذیه متوازن و تقویت اسکلت در دوره رشد" });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Fill defaults if needed
|
||||
if (picks.length < 4) {
|
||||
const defaults = products.filter(p => !picks.some(x => x.product.id === p.id) && (p.suitableFor === activePet.type || p.suitableFor === "هر دو"));
|
||||
defaults.slice(0, 4 - picks.length).forEach(p => picks.push({ product: p }));
|
||||
if (activePet.activityLevel === "زیاد") {
|
||||
const performanceSupplements = products.filter(p =>
|
||||
(p.name.includes("انرژی") || p.benefits?.includes("عضله") || p.benefits?.includes("مفصل")) &&
|
||||
(p.suitableFor === activePet.type || p.suitableFor === "هر دو")
|
||||
);
|
||||
performanceSupplements.forEach(p => {
|
||||
if (!picks.some(x => x.product.id === p.id)) {
|
||||
picks.push({ product: p, reason: "تقویت مفاصل و ریکاوری برای سطح فعالیت بالا" });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return picks;
|
||||
@@ -609,6 +655,19 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
<span className="font-black text-sm italic">{condition}</span>
|
||||
</button>
|
||||
))}
|
||||
|
||||
<div className="pt-2">
|
||||
<label className="block text-[10px] font-black text-medical-gray-400 uppercase tracking-widest mb-2 pr-2">
|
||||
توضیحات و سوابق تکمیلی (اختیاری)
|
||||
</label>
|
||||
<textarea
|
||||
rows={3}
|
||||
value={formData.extraNotes || formData.notes || ""}
|
||||
onChange={e => setFormData({ ...formData, extraNotes: e.target.value, notes: e.target.value })}
|
||||
placeholder="سابقه جراحی، حساسیت دارویی، رژیم غذایی یا هر نکته دیگری که پزشکان کنینا باید بدانند..."
|
||||
className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-2xl p-4 text-xs font-medium text-medical-gray-900 focus:ring-2 focus:ring-canina-blue/20 outline-none resize-none leading-relaxed"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
@@ -876,12 +935,13 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
<div className="flex border-b border-medical-gray-200 gap-8 px-4">
|
||||
{[
|
||||
{ id: "health", label: "داشبورد سلامت و یادآوریها", icon: <Heart className="w-4 h-4" /> },
|
||||
{ id: "orders", label: "سوابق خرید و تاریخچه تخصصی", icon: <Package className="w-4 h-4" /> },
|
||||
{ id: "orders", label: "سوابق خرید و فاکتورها", icon: <Package className="w-4 h-4" /> },
|
||||
{ id: "prescriptions", label: "نسخههای پزشکی این همدم", icon: <Stethoscope className="w-4 h-4" /> },
|
||||
].map(tab => (
|
||||
<button
|
||||
key={tab.id}
|
||||
onClick={() => setActivePetTab(tab.id as "health" | "orders")}
|
||||
className={`pb-4 flex items-center gap-2 text-sm font-black transition-all relative ${activePetTab === tab.id ? "text-canina-blue" : "text-medical-gray-400 hover:text-medical-gray-600"}`}
|
||||
onClick={() => setActivePetTab(tab.id as "health" | "orders" | "prescriptions")}
|
||||
className={`pb-4 flex items-center gap-2 text-sm font-black transition-all relative cursor-pointer ${activePetTab === tab.id ? "text-canina-blue" : "text-medical-gray-400 hover:text-medical-gray-600"}`}
|
||||
>
|
||||
{tab.icon}
|
||||
{tab.label}
|
||||
@@ -899,40 +959,48 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
<div className="w-12 h-12 bg-white rounded-2xl flex items-center justify-center text-canina-blue shadow-lg border border-medical-gray-100">
|
||||
<Star className="w-6 h-6" />
|
||||
</div>
|
||||
<h3 className="text-3xl font-black text-medical-gray-900 italic">توصیههای درمانی اختصاصی</h3>
|
||||
<h3 className="text-3xl font-black text-medical-gray-900 italic">توصیههای درمانی هوشمند</h3>
|
||||
</div>
|
||||
<p className="text-[10px] font-black text-medical-gray-400 uppercase tracking-wider">کاتالوگ ۲۰۲۴ آلمان</p>
|
||||
<p className="text-[10px] font-black text-medical-gray-400 uppercase tracking-wider">کاتالوگ رسمی کنینا آلمان</p>
|
||||
</div>
|
||||
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||
{recommendedProducts.map(({ product: p, reason }) => (
|
||||
<motion.div
|
||||
key={p.id}
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
whileInView={{ opacity: 1, y: 0 }}
|
||||
viewport={{ once: true }}
|
||||
onClick={() => router.push(`/shop/${p.slug || p.id}`)}
|
||||
className="bg-white rounded-[2.5rem] p-6 border border-medical-gray-200 hover:shadow-2xl transition-all cursor-pointer group flex flex-col justify-between relative overflow-hidden"
|
||||
>
|
||||
{reason && (
|
||||
<div className="absolute top-0 left-0 right-0 bg-canina-blue/10 py-2 px-4 text-[9px] font-black text-canina-blue text-center border-b border-canina-blue/10">
|
||||
{reason}
|
||||
{recommendedProducts.length === 0 ? (
|
||||
<div className="p-8 bg-medical-gray-50/70 border border-dashed border-medical-gray-200 rounded-3xl text-center">
|
||||
<p className="text-xs font-bold text-medical-gray-500">
|
||||
بر اساس آخرین وضعیت پایش شده، نیاز درمانی فعالی برای {activePet.name} ثبت نشده است. جهت حفظ سلامتی عمومی میتوانید از کاتالوگ محصولات دیدن فرمایید.
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||
{recommendedProducts.map(({ product: p, reason }) => (
|
||||
<motion.div
|
||||
key={p.id}
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
whileInView={{ opacity: 1, y: 0 }}
|
||||
viewport={{ once: true }}
|
||||
onClick={() => router.push(`/shop/${p.slug || p.id}`)}
|
||||
className="bg-white rounded-[2.5rem] p-6 border border-medical-gray-200 hover:shadow-2xl transition-all cursor-pointer group flex flex-col justify-between relative overflow-hidden"
|
||||
>
|
||||
{reason && (
|
||||
<div className="absolute top-0 left-0 right-0 bg-canina-blue/10 py-2 px-4 text-[9px] font-black text-canina-blue text-center border-b border-canina-blue/10">
|
||||
{reason}
|
||||
</div>
|
||||
)}
|
||||
<div className={cn("aspect-square bg-medical-gray-50 rounded-[1.5rem] p-6 mb-6 flex items-center justify-center overflow-hidden", reason ? "mt-8" : "")}>
|
||||
<SafeImage src={p.image} alt={p.name} className="w-full h-full group-hover:scale-110 transition-transform duration-500" imgClassName="object-contain" />
|
||||
</div>
|
||||
)}
|
||||
<div className={cn("aspect-square bg-medical-gray-50 rounded-[1.5rem] p-6 mb-6 flex items-center justify-center overflow-hidden", reason ? "mt-8" : "")}>
|
||||
<SafeImage src={p.image} alt={p.name} className="w-full h-full group-hover:scale-110 transition-transform duration-500" imgClassName="object-contain" />
|
||||
</div>
|
||||
<div>
|
||||
<h4 className="text-lg font-black text-medical-gray-900 group-hover:text-canina-blue transition-colors mb-2 italic">{p.name}</h4>
|
||||
<p className="text-xs text-medical-gray-400 line-clamp-2 leading-relaxed mb-6 font-medium">{p.benefits}</p>
|
||||
<button className="w-full py-3.5 bg-medical-gray-900 text-white rounded-xl text-[10px] font-black uppercase tracking-widest group-hover:bg-canina-blue transition-colors flex items-center justify-center gap-2">
|
||||
بررسی تخصصی
|
||||
<ChevronLeft className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
))}
|
||||
</div>
|
||||
<div>
|
||||
<h4 className="text-lg font-black text-medical-gray-900 group-hover:text-canina-blue transition-colors mb-2 italic">{p.name}</h4>
|
||||
<p className="text-xs text-medical-gray-400 line-clamp-2 leading-relaxed mb-6 font-medium">{p.benefits}</p>
|
||||
<button className="w-full py-3.5 bg-medical-gray-900 text-white rounded-xl text-[10px] font-black uppercase tracking-widest group-hover:bg-canina-blue transition-colors flex items-center justify-center gap-2">
|
||||
بررسی تخصصی
|
||||
<ChevronLeft className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<div className="grid lg:grid-cols-2 gap-10">
|
||||
@@ -979,9 +1047,6 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
<p className="text-[10px] text-medical-gray-400 font-bold">{toPersian(reminder.time)} - {reminder.frequency}</p>
|
||||
</div>
|
||||
</div>
|
||||
<span className={cn("text-[10px] font-black italic", isCompleted ? "text-green-600" : "text-medical-gray-400")}>
|
||||
{isCompleted ? "انجام شد" : "در انتظار"}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})
|
||||
@@ -992,38 +1057,38 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
onClick={() => setIsAddingReminder(true)}
|
||||
className="w-full mt-8 py-5 border-2 border-dashed border-medical-gray-200 rounded-2xl text-medical-gray-400 font-black hover:border-canina-blue hover:text-canina-blue transition-all flex items-center justify-center gap-2"
|
||||
>
|
||||
<Plus className="w-4 h-4" />
|
||||
افزودن یادآور جدید
|
||||
<Plus className="w-5 h-5" />
|
||||
تعریف یادآور درمانی جدید
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Health Logs */}
|
||||
<div className="bg-white rounded-[3rem] border border-medical-gray-200 p-10 shadow-sm">
|
||||
<div className="flex items-center gap-3 mb-10">
|
||||
<ClipboardList className="w-8 h-8 text-canina-blue" />
|
||||
<h3 className="text-2xl font-black text-medical-gray-900 italic">تایملاین سلامت</h3>
|
||||
<div className="flex items-center justify-between mb-10">
|
||||
<div className="flex items-center gap-3">
|
||||
<Activity className="w-8 h-8 text-canina-blue" />
|
||||
<h3 className="text-2xl font-black text-medical-gray-900 italic">گزارشات سلامت</h3>
|
||||
</div>
|
||||
<ClipboardList className="w-6 h-6 text-canina-blue" />
|
||||
</div>
|
||||
|
||||
<div className="space-y-6 max-h-[400px] overflow-y-auto pr-2 scrollbar-hide">
|
||||
<div className="space-y-4">
|
||||
{(activePet?.logs || []).length === 0 ? (
|
||||
<div className="text-center py-10 bg-medical-gray-50 rounded-2xl border border-dashed border-medical-gray-200">
|
||||
<p className="text-sm font-bold text-medical-gray-400 italic">هنوز گزارشی ثبت نشده است</p>
|
||||
</div>
|
||||
) : (
|
||||
(activePet?.logs || []).map((log) => (
|
||||
<div key={log.id} className="bg-medical-gray-50 p-6 rounded-[2.5rem] border border-medical-gray-100 relative group">
|
||||
<div className="flex justify-between items-center mb-4">
|
||||
<div className="text-[10px] font-black text-medical-gray-400 uppercase tracking-widest">
|
||||
{toPersian(new Date(log.date).toLocaleDateString("fa-IR"))}
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<div className="px-2 py-0.5 bg-canina-blue/10 text-canina-blue rounded-full text-[8px] font-black">{log.appetite}</div>
|
||||
<div className="px-2 py-0.5 bg-green-500/10 text-green-500 rounded-full text-[8px] font-black">{log.energy}</div>
|
||||
(activePet?.logs || []).slice(0, 3).map((log) => (
|
||||
<div key={log.id} className="p-5 bg-medical-gray-50 rounded-2xl border border-medical-gray-100 flex items-center justify-between">
|
||||
<div>
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<span className="text-[10px] font-black bg-white px-2 py-0.5 rounded-md border border-medical-gray-200 text-medical-gray-600">
|
||||
{toPersian(new Date(log.date).toLocaleDateString("fa-IR"))}
|
||||
</span>
|
||||
<span className="text-xs font-black text-medical-gray-900">اشتها: {log.appetite} | انرژی: {log.energy}</span>
|
||||
</div>
|
||||
{log.note && <p className="text-[11px] text-medical-gray-500 line-clamp-1">{log.note}</p>}
|
||||
</div>
|
||||
<p className="text-sm text-medical-gray-600 font-medium leading-relaxed italic">
|
||||
{log.note || "وضعیتی برای این روز ثبت نشده است."}
|
||||
</p>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
@@ -1038,7 +1103,7 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
) : activePetTab === "orders" ? (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
@@ -1051,7 +1116,7 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-3xl font-black text-medical-gray-900 italic">تاریخچه خرید {activePet.name}</h3>
|
||||
<p className="text-xs font-bold text-medical-gray-400 mt-1">لیست محصولات خریداری شده ویژه این پرونده سلامت</p>
|
||||
<p className="text-xs font-bold text-medical-gray-400 mt-1">برای مشاهده جزئیات کامل فاکتور و پیگیری، روی هر سفارش کلیک کنید</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-left">
|
||||
@@ -1066,50 +1131,124 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
<Package className="w-12 h-12" />
|
||||
</div>
|
||||
<p className="text-medical-gray-400 font-black text-xl italic">هنوز سفارشی برای {activePet.name} ثبت نکردهاید.</p>
|
||||
<button onClick={() => router.push('/shop')} className="bg-canina-blue text-white px-10 py-4 rounded-2xl font-black hover:scale-105 transition-all">شروع اولین خرید</button>
|
||||
<button onClick={() => router.push('/shop')} className="bg-canina-blue text-white px-10 py-4 rounded-2xl font-black hover:scale-105 transition-all cursor-pointer">شروع اولین خرید</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-5">
|
||||
{petOrders.map(order =>
|
||||
order.items.map(item => (
|
||||
<motion.div
|
||||
key={`${order.id}-${item.product.id}`}
|
||||
initial={{ opacity: 0, x: 20 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
whileHover={{ x: -10, backgroundColor: "rgba(249, 250, 251, 1)" }}
|
||||
className="p-6 bg-white rounded-[2.5rem] border border-medical-gray-200 flex items-center justify-between gap-6 transition-all cursor-pointer group shadow-sm hover:shadow-xl"
|
||||
onClick={() => router.push(`/shop/${item.product.slug || item.product.id}`)}
|
||||
>
|
||||
{/* Info on Left (Text side) */}
|
||||
<div className="flex-1 text-right">
|
||||
<h4 className="text-xl font-black text-medical-gray-900 group-hover:text-canina-blue transition-colors mb-2 italic">{item.product.name}</h4>
|
||||
<div className="flex flex-wrap gap-x-6 gap-y-2 items-center">
|
||||
<div className="flex items-center gap-1.5 text-xs font-bold text-medical-gray-500">
|
||||
<Calendar className="w-4 h-4 text-canina-blue/40" />
|
||||
{toPersian(new Date(order.date).toLocaleDateString("fa-IR", { year: 'numeric', month: 'long', day: 'numeric' }))}
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5 px-3 py-1 bg-green-50 text-green-600 rounded-full text-[10px] font-black italic">
|
||||
<Check className="w-3 h-3" />
|
||||
تایید شده و تحویل شده
|
||||
</div>
|
||||
<div className="text-[10px] font-black text-medical-gray-400 uppercase tracking-widest bg-medical-gray-50 px-3 py-1 rounded-lg">
|
||||
فاکتور: {toPersian(order.id)}
|
||||
</div>
|
||||
{petOrders.map(order => (
|
||||
<motion.div
|
||||
key={order.id}
|
||||
initial={{ opacity: 0, x: 20 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
whileHover={{ x: -6 }}
|
||||
onClick={() => setSelectedInvoiceOrder(order)}
|
||||
className="p-6 bg-white rounded-[2.5rem] border border-medical-gray-200 hover:border-canina-blue/50 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-6 transition-all cursor-pointer group shadow-sm hover:shadow-xl"
|
||||
>
|
||||
<div className="flex-1 text-right">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<span className="text-xs font-black text-medical-gray-900">سفارش #{toPersian(order.id.slice(-6))}</span>
|
||||
<span className="text-[10px] font-black px-2.5 py-0.5 rounded-full bg-green-50 text-green-600">
|
||||
{toPersian(order.items.length)} قلم کالا
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-x-6 gap-y-2 items-center text-xs text-medical-gray-500 font-bold">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<Calendar className="w-4 h-4 text-canina-blue/40" />
|
||||
{toPersian(new Date(order.date).toLocaleDateString("fa-IR", { year: 'numeric', month: 'long', day: 'numeric' }))}
|
||||
</div>
|
||||
<div className="text-canina-blue font-black">
|
||||
مبلغ کل: {toPersian(order.total.toLocaleString())} تومان
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Image on Right (Icon side) */}
|
||||
<div className="w-20 h-20 shrink-0 bg-medical-gray-50 rounded-[1.5rem] p-3 flex items-center justify-center border border-medical-gray-100 group-hover:bg-white transition-colors relative overflow-hidden">
|
||||
<SafeImage
|
||||
src={item.product.image}
|
||||
alt={item.product.name}
|
||||
className="w-full h-full"
|
||||
imgClassName="object-contain"
|
||||
/>
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
{order.items.slice(0, 3).map((item, idx) => (
|
||||
<div key={idx} className="w-14 h-14 bg-medical-gray-50 rounded-2xl p-2 flex items-center justify-center border border-medical-gray-100 overflow-hidden">
|
||||
<SafeImage src={item.product.image} alt={item.product.name} className="w-full h-full" imgClassName="object-contain" />
|
||||
</div>
|
||||
))}
|
||||
<div className="px-4 py-2 bg-canina-blue/10 text-canina-blue text-xs font-black rounded-xl group-hover:bg-canina-blue group-hover:text-white transition-colors">
|
||||
مشاهده فاکتور
|
||||
</div>
|
||||
</motion.div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</motion.div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</motion.div>
|
||||
) : (
|
||||
/* Prescriptions Tab */
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
className="bg-white rounded-[4rem] border border-medical-gray-200 p-12 min-h-[500px] shadow-sm"
|
||||
>
|
||||
<div className="flex items-center justify-between mb-12">
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="w-14 h-14 bg-canina-blue text-white rounded-[1.5rem] flex items-center justify-center shadow-xl">
|
||||
<Stethoscope className="w-7 h-7" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-3xl font-black text-medical-gray-900 italic">نسخههای پزشکی {activePet.name}</h3>
|
||||
<p className="text-xs font-bold text-medical-gray-400 mt-1">پرونده نسخههای بارگذاری شده و نظرات تخصصی پزشکان کنینا</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{petPrescriptions.length === 0 ? (
|
||||
<div className="py-24 text-center space-y-6">
|
||||
<div className="w-24 h-24 bg-medical-gray-50 rounded-full flex items-center justify-center mx-auto text-medical-gray-200 shadow-inner">
|
||||
<Stethoscope className="w-12 h-12" />
|
||||
</div>
|
||||
<p className="text-medical-gray-400 font-black text-xl italic">هنوز نسخه پزشکی برای {activePet.name} ثبت نشده است.</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-6">
|
||||
{petPrescriptions.map((rx: any) => (
|
||||
<div
|
||||
key={rx.id}
|
||||
className="p-6 bg-medical-gray-50/70 rounded-[2.5rem] border border-medical-gray-200 flex flex-col md:flex-row items-start md:items-center justify-between gap-6"
|
||||
>
|
||||
<div className="space-y-2 flex-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs font-black text-medical-gray-900">نسخه شماره #{rx.id.slice(0, 8)}</span>
|
||||
<span className={`text-[10px] font-black px-2.5 py-0.5 rounded-full ${
|
||||
rx.status === 'APPROVED' ? 'bg-green-100 text-green-700' : rx.status === 'REJECTED' ? 'bg-red-100 text-red-700' : 'bg-amber-100 text-amber-700'
|
||||
}`}>
|
||||
{rx.status === 'APPROVED' ? 'تایید شده توسط پزشک' : rx.status === 'REJECTED' ? 'عدم تایید' : 'در حال بررسی تخصصی'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-xs text-medical-gray-500 font-bold flex items-center gap-2">
|
||||
<Calendar className="w-4 h-4 text-canina-blue" />
|
||||
<span>تاریخ ثبت: {toPersian(new Date(rx.createdAt).toLocaleDateString("fa-IR", { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit' }))}</span>
|
||||
</div>
|
||||
{rx.notes && (
|
||||
<p className="text-xs text-medical-gray-600 bg-white p-3 rounded-xl border border-medical-gray-200">
|
||||
<strong className="text-medical-gray-800 block mb-0.5">یادداشت شما:</strong>
|
||||
{rx.notes}
|
||||
</p>
|
||||
)}
|
||||
{rx.adminNotes && (
|
||||
<p className="text-xs text-canina-blue bg-canina-blue/5 p-3 rounded-xl border border-canina-blue/10 font-bold">
|
||||
<strong className="text-canina-dark block mb-0.5">پاسخ و دستور مصرف پزشک کنینا:</strong>
|
||||
{rx.adminNotes.split('__PRESCRIBED_PRODUCTS__:')[0]}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="shrink-0 flex items-center gap-3">
|
||||
<a
|
||||
href={rx.fileUrl.startsWith('http') ? rx.fileUrl : `${BASE_DOMAIN}${rx.fileUrl}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="px-4 py-2.5 bg-white text-canina-blue border border-canina-blue/20 rounded-xl text-xs font-black hover:bg-canina-blue hover:text-white transition-all shadow-xs"
|
||||
>
|
||||
مشاهده فایل نسخه
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</motion.div>
|
||||
@@ -1290,6 +1429,12 @@ export default function PetProfile({ initialView, advisorNeed, embedded = false
|
||||
)}
|
||||
</AnimatePresence>
|
||||
|
||||
{/* Invoice Modal for Pet Purchase History */}
|
||||
<OrderDetailsModal
|
||||
isOpen={!!selectedInvoiceOrder}
|
||||
order={selectedInvoiceOrder}
|
||||
onClose={() => setSelectedInvoiceOrder(null)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user