feat(ux-fix): resolve wiki fallback 404, responsive B2B modal, clean badges, aligned bullets, mobile bottom nav on PDP and admin Rx/symptoms management
Deploy Canina / deploy (push) Failing after 1m14s

This commit is contained in:
devops committed 2026-10-18 12:51:04 +00:00
1 parent 52446592e7
commit 468170349d
8 files changed
+168 -54

No files matched your search

+15
View File
@@ -354,4 +354,19 @@ export class AdminController {
await this.settingsService.updateBulkUiTexts(body);
return { success: true, data: body };
}
@Get("symptoms")
@ApiOperation({ summary: "لیست کامل علائم درمانی به همراه تعداد محصولات متصل" })
async getAllSymptoms() {
const data = await this.adminService.getAllSymptoms();
return { success: true, data };
}
@Put("symptoms/rename")
@ApiOperation({ summary: "تغییر نام یکپارچه یک علامت در سراسر محصولات و دیتابیس" })
async renameSymptom(@Body() body: { oldName: string; newName: string }) {
const result = await this.adminService.renameSymptom(body.oldName, body.newName);
return { success: true, ...result };
}
}
+61
View File
@@ -1869,4 +1869,65 @@ export class AdminService {
};
});
}
async getAllSymptoms() {
const rawSymptoms = await this.prisma.productSymptom.groupBy({
by: ['symptom'],
_count: {
productId: true,
},
orderBy: {
symptom: 'asc',
},
});
return rawSymptoms.map((s) => ({
name: s.symptom,
productsCount: s._count.productId,
}));
}
async renameSymptom(oldName: string, newName: string) {
if (!oldName?.trim() || !newName?.trim()) {
throw new BadRequestException('نام قبلی و جدید علامت الزامی است');
}
const cleanOld = oldName.trim();
const cleanNew = newName.trim();
return await this.prisma.(async (tx) => {
// 1. Rename in product_symptoms join table
const updatedJoin = await tx.`
UPDATE product_symptoms
SET symptom = ${cleanNew}
WHERE symptom = ${cleanOld};
`;
// 2. Cascade rename in products.dosage_config->'symptoms' jsonb array
await tx.`
UPDATE products
SET dosage_config = jsonb_set(
dosage_config,
'{symptoms}',
(
SELECT jsonb_agg(
CASE
WHEN elem::text = to_jsonb(${cleanOld}::text)::text THEN to_jsonb(${cleanNew}::text)
ELSE elem
END
)
FROM jsonb_array_elements(dosage_config->'symptoms') AS elem
)
)
WHERE dosage_config ? 'symptoms'
AND dosage_config->'symptoms' @> to_jsonb(${cleanOld}::text);
`;
return {
success: true,
message: \`علامت «${cleanOld}» با موفقیت به «${cleanNew}» در سراسر سیستم تغییر یافت\`,
updatedCount: updatedJoin,
};
});
}
}
+25
View File
@@ -31,6 +31,7 @@ import api from '../services/api';
export interface OrderItem {
requiresRx?: boolean;
id?: string;
name?: string;
priceValue?: number;
@@ -758,6 +759,12 @@ export default function Orders() {
سفارش جدید
</span>
)}
{(order.orderItems || order.items || []).some(it => it.product?.requiresRx) && (
<span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-black bg-rose-600 text-white shadow-xs animate-pulse" title="نیازمند تماس تلفنی و تایید نسخه دامپزشک">
<span>Rx</span>
<span>هماهنگی نسخه</span>
</span>
)}
</div>
<div className="flex flex-wrap gap-1.5 mt-2 font-vazir" dir="rtl">
<span className={`text-[10px] font-bold font-vazir px-2 py-0.5 rounded-md border flex items-center gap-1 shadow-sm ${payInfo.color}`}>
@@ -911,6 +918,24 @@ export default function Orders() {
>
<div className="space-y-6">
{/* Rx Warning Notice for Admin */}
{(selectedOrder.orderItems || selectedOrder.items || []).some(it => it.requiresRx || it.product?.requiresRx) && (
<div className="bg-rose-50 border border-rose-200 rounded-2xl p-4 flex items-center justify-between gap-3 text-rose-900 font-vazir shadow-xs" dir="rtl">
<div className="flex items-center gap-2.5">
<span className="w-8 h-8 rounded-xl bg-rose-600 text-white flex items-center justify-center font-black text-xs shrink-0 shadow-sm">Rx</span>
<div>
<h4 className="text-xs font-black">این سفارش شامل داروی نیازمند نسخه و نظارت دامپزشکی است</h4>
<p className="text-[11px] text-rose-700 font-medium mt-0.5">ارسال سفارش تنها پس از تماس تلفنی کارشناس پشتیبانی و تایید نسخه معتبر انجام شود.</p>
</div>
</div>
<a
href={`tel:${selectedOrder.user?.mobile || selectedOrder.user?.phone || ''}`}
className="bg-rose-600 hover:bg-rose-700 text-white px-3.5 py-2 rounded-xl text-xs font-bold transition-all shadow-sm flex items-center gap-1.5 shrink-0"
>
<span>تماس با مشتری</span>
</a>
</div>
)}
{/* Status & Timing Banner */}
<div className="flex flex-wrap items-center justify-between gap-4 p-4 bg-purple-50/50 rounded-2xl border border-purple-100">
<div className="flex items-center gap-3">
+27 -4
View File
@@ -12,15 +12,38 @@ const apiBase = API_URL.endsWith('/api') ? API_URL : `${API_URL.replace(/\/$/, '
async function getWikiTerm(key: string) {
try {
// 1. Try scientific terms endpoint
const res = await fetch(`${apiBase}/wiki/${encodeURIComponent(key)}`, {
next: { revalidate: 3600, tags: ['wiki', `wiki-${key}`] }
});
if (!res.ok) return null;
return await res.json();
if (res.ok) {
return await res.json();
}
} catch (error) {
console.error('[Wiki] Error fetching term:', error);
return null;
console.warn('[Wiki] /wiki/:key failed, trying /ingredients fallback:', error);
}
try {
// 2. Fallback to ingredients endpoint if slug is an ingredient slug
const ingRes = await fetch(`${apiBase}/ingredients/${encodeURIComponent(key)}`, {
next: { revalidate: 3600, tags: ['ingredients', `ing-${key}`] }
});
if (ingRes.ok) {
const ing = await ingRes.json();
return {
key: ing.slug,
term: ing.nameFa || ing.nameEn || ing.slug,
definition: ing.description || `بررسی تخصصی ترکیب دارویی و خواص ${ing.nameFa || ing.nameEn} در کاتالوگ مکمل‌های کنینا آلمان.`,
metaTitle: `خواص دارویی ${ing.nameFa || ing.nameEn} | دانشنامه کنینا ایران`,
metaDescription: (ing.description || '').slice(0, 155),
wikiId: ing.slug,
};
}
} catch (error) {
console.error('[Wiki] Error fetching ingredient fallback:', error);
}
return null;
}
async function getRelatedProducts(termName: string) {
@@ -129,11 +129,7 @@ export const ArchiveProductCard: React.FC<{ product: Product }> = ({ product })
href={productUrl}
className="group bg-white rounded-[2.5rem] border border-medical-gray-200 overflow-hidden hover:shadow-2xl transition-all flex flex-col h-full relative"
>
{product.specialBadge && (
<div className="absolute top-4 right-4 z-10 bg-canina-blue text-white text-2xs font-black uppercase tracking-widest px-3 py-1 rounded-full shadow-lg">
{product.specialBadge}
</div>
)}
{/* SpecialBadge moved below image to avoid covering product photo */}
{compatibility && (
<div className={`absolute top-14 right-4 z-10 text-3xs font-black uppercase tracking-widest px-3 py-1 rounded-full shadow-md flex items-center gap-1 ${compatibility.type === 'alert' ? 'bg-amber-100 text-amber-700' :
@@ -184,6 +180,13 @@ export const ArchiveProductCard: React.FC<{ product: Product }> = ({ product })
</div>
<div className="p-6 flex flex-col flex-1">
{product.specialBadge && (
<div className="mb-2">
<span className="inline-block bg-canina-blue/10 text-canina-blue border border-canina-blue/20 text-[10px] font-black px-2.5 py-1 rounded-lg line-clamp-1 font-vazir" title={product.specialBadge}>
{product.specialBadge}
</span>
</div>
)}
<div className="text-2xs font-bold text-canina-blue uppercase tracking-widest mb-2">{product.category}</div>
<div className="flex flex-col gap-1 mb-3">
<h3 dir="rtl" className="text-base font-black text-medical-gray-900 group-hover:text-canina-blue transition-colors leading-tight text-right font-vazir">
@@ -325,11 +328,7 @@ const ArchiveProductListItem: React.FC<{ product: Product }> = ({ product }) =>
className="w-full h-full group-hover:scale-105 transition-transform duration-500"
imgClassName="w-full h-full object-contain"
/>
{product.specialBadge && (
<div className="absolute top-1 right-1 z-10 bg-canina-blue text-white text-[9px] font-black uppercase px-1.5 py-0.5 rounded-md shadow-xs">
{product.specialBadge}
</div>
)}
{/* List specialBadge moved below */}
<div className="absolute bottom-1 left-1 flex gap-1">
{forDog && (
<div className="w-5 h-5 bg-white/90 backdrop-blur-xs rounded-md flex items-center justify-center text-medical-gray-500 border border-medical-gray-100 shadow-2xs" title="مناسب برای سگ">
@@ -89,23 +89,24 @@ export default function B2BPortal({ onClose }: { onClose: () => void }) {
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
className="fixed inset-0 z-[100] bg-medical-gray-900/60 backdrop-blur-md flex items-center justify-center p-4 md:p-10 font-vazir"
className="fixed inset-0 z-[100] bg-medical-gray-900/70 backdrop-blur-md flex items-center justify-center p-2 sm:p-4 md:p-8 font-vazir"
dir="rtl"
>
<motion.div
initial={{ scale: 0.9, opacity: 0, y: 20 }}
animate={{ scale: 1, opacity: 1, y: 0 }}
className="bg-white w-full max-w-6xl h-[90vh] rounded-[3rem] shadow-2xl overflow-hidden flex flex-col md:flex-row relative"
className="bg-white w-full max-w-6xl h-[95vh] sm:h-[90vh] rounded-3xl sm:rounded-[3rem] shadow-2xl overflow-hidden flex flex-col md:flex-row relative"
>
<button
onClick={onClose}
className="absolute top-6 left-6 z-20 w-10 h-10 bg-medical-gray-100 rounded-full flex items-center justify-center text-medical-gray-500 hover:bg-red-50 hover:text-red-500 transition-all"
className="absolute top-4 left-4 sm:top-6 sm:left-6 z-30 min-w-[44px] min-h-[44px] w-11 h-11 bg-white/90 sm:bg-medical-gray-100 rounded-full flex items-center justify-center text-medical-gray-600 hover:bg-red-50 hover:text-red-500 transition-all shadow-md cursor-pointer"
aria-label="بستن پنجره"
>
<X className="w-5 h-5" />
</button>
{/* Sidebar Info */}
<div className="w-full md:w-80 bg-canina-blue p-10 text-white flex flex-col overflow-y-auto">
<div className="w-full md:w-80 bg-canina-blue p-5 sm:p-8 md:p-10 text-white flex flex-col overflow-y-auto shrink-0 max-h-[45vh] md:max-h-full">
<div className="mb-8">
<div className="w-16 h-16 bg-white/20 rounded-2xl flex items-center justify-center mb-6">
<Building2 className="w-8 h-8" />
@@ -183,10 +183,8 @@ export default function MobileBottomNav({
}
};
const isProductDetailPage = pathname.startsWith("/shop/") && pathname !== "/shop";
if (isProductDetailPage) {
return null;
}
// Retain MobileBottomNav across all routes including PDP so user never loses Menu & Home navigation
const isProductDetailPage = false;
const totalCartItems = isMounted ? getTotalItems() : 0;
const isHomeActive = pathname === "/";
+24 -32
View File
@@ -498,27 +498,7 @@ export default function ProductPage({
}}
className="bg-white rounded-2xl sm:rounded-[2.5rem] border border-medical-gray-200 shadow-xl relative group overflow-hidden h-[280px] sm:h-[390px] flex items-center justify-center p-2 sm:p-4 select-none touch-pan-y cursor-grab active:cursor-grabbing"
>
{/* Top Floating Badges */}
<div className="absolute top-4 left-4 sm:top-6 sm:left-6 flex flex-col gap-1.5 sm:gap-2 z-10 items-start pointer-events-none">
{product.specialBadge && (
<div className="px-2.5 py-1 bg-medical-gray-900 text-white rounded-full text-[9px] sm:text-[10px] font-black uppercase tracking-widest font-vazir whitespace-nowrap shadow-sm">
{product.specialBadge}
</div>
)}
{isOutOfStock ? (
<div className="px-2.5 py-1 bg-rose-500 text-white rounded-full text-[9px] sm:text-[10px] font-black uppercase tracking-widest flex items-center gap-1 font-vazir shadow-sm">
ناموجود در انبار
</div>
) : (
<div className="px-2.5 py-1 bg-green-500 text-white rounded-full text-[9px] sm:text-[10px] font-black uppercase tracking-widest flex items-center gap-1 font-vazir shadow-sm">
<CheckCircle2 className="w-3 h-3" />
موجود در انبار
</div>
)}
<div className="px-2.5 py-1 bg-canina-blue text-white rounded-full text-[9px] sm:text-[10px] font-black uppercase tracking-widest font-vazir whitespace-nowrap shadow-sm">
گرید دارویی اختصاصی
</div>
</div>
{/* Floating Badges over photo removed to prevent blocking product visual */}
{/* Species Suitable Badges (Dog / Cat) */}
<div className="absolute bottom-4 left-4 flex gap-1.5 z-10 pointer-events-none">
@@ -695,15 +675,27 @@ export default function ProductPage({
<div className="md:col-span-7 space-y-4 sm:space-y-6 flex flex-col items-center md:items-start">
<div className="w-full flex flex-col items-center md:items-start">
<div className="flex flex-wrap justify-center md:justify-start items-center gap-2 sm:gap-3 mb-3 sm:mb-4">
<div className="px-3 py-1 bg-canina-blue text-white rounded-full text-[10px] font-black uppercase tracking-widest font-vazir whitespace-nowrap shadow-sm">
استاندارد صنعتی آلمان
</div>
<div className="px-3 py-1 bg-amber-500 text-white rounded-full text-[10px] font-black uppercase tracking-widest font-vazir whitespace-nowrap shadow-sm flex items-center gap-1">
<ShieldCheck className="w-3 h-3" />
کاتالوگ رسمی Canina
{/* 1. First Priority: Stock Status */}
{isOutOfStock ? (
<div className="px-3 py-1 bg-rose-50 text-rose-700 border border-rose-200 rounded-full text-[10px] font-black uppercase tracking-widest flex items-center gap-1 font-vazir shadow-xs">
<span className="w-2 h-2 rounded-full bg-rose-500" />
ناموجود در انبار مرکزی
</div>
) : (
<div className="px-3 py-1 bg-emerald-50 text-emerald-800 border border-emerald-200 rounded-full text-[10px] font-black uppercase tracking-widest flex items-center gap-1 font-vazir shadow-xs">
<CheckCircle2 className="w-3.5 h-3.5 text-emerald-600" />
موجود در انبار مرکزی
</div>
)}
{/* 2. Pharmaceutical Grade */}
<div className="px-3 py-1 bg-canina-blue/10 text-canina-blue border border-canina-blue/20 rounded-full text-[10px] font-black uppercase tracking-widest font-vazir whitespace-nowrap shadow-xs">
گرید دارویی اختصاصی Canina
</div>
{/* 3. Special Badge if exists */}
{product.specialBadge && (
<div className="px-3 py-1 bg-medical-gray-900 text-white rounded-full text-[10px] font-black uppercase tracking-widest font-vazir whitespace-nowrap shadow-sm">
<div className="px-3 py-1 bg-amber-50 text-amber-900 border border-amber-200 rounded-full text-[10px] font-black uppercase tracking-widest font-vazir shadow-xs max-w-full text-right" title={product.specialBadge}>
{product.specialBadge}
</div>
)}
@@ -745,9 +737,9 @@ export default function ProductPage({
</h2>
)}
{product.scientificTagline && (
<div className="mt-1 text-xs sm:text-sm md:text-base text-canina-blue font-bold font-vazir flex items-center justify-center md:justify-start gap-1.5" dir="rtl">
<span className="w-1.5 h-1.5 rounded-full bg-canina-blue shrink-0" />
<span>{product.scientificTagline}</span>
<div className="mt-1.5 text-xs sm:text-sm md:text-base text-canina-blue font-bold font-vazir flex items-start justify-center md:justify-start gap-2" dir="rtl">
<span className="w-1.5 h-1.5 rounded-full bg-canina-blue shrink-0 mt-2" />
<span className="leading-relaxed text-right">{product.scientificTagline}</span>
</div>
)}
</div>
@@ -1060,7 +1052,7 @@ export default function ProductPage({
<span className="text-xs sm:text-sm font-bold text-medical-gray-700 font-vazir">
{cardSlug ? (
<Link
href={`/wiki/${cardSlug}`}
href={`/wiki?term=${cardSlug}`}
className="hover:text-canina-blue hover:underline transition-colors flex items-center gap-1"
title="مشاهده در دانشنامه علمی کنینا"
>