fix(analytics, prescription, hydration): filter out admin/static asset requests from view counter, support guest prescription upload with fallback UI, and unify Hero component fallbacks with database defaults
Deploy Canina / deploy (push) Waiting to run

This commit is contained in:
parsa aghaei committed 2026-08-09 09:47:51 +03:30
1 parent 3e21aefbf1
commit b617331683
7 files changed
+41 -28

No files matched your search

+4 -4
View File
@@ -41,8 +41,8 @@ import { Banner } from "../lib/types";
export default function Hero({ banners = [] }: { banners?: Banner[] }) {
const router = useRouter();
const { getText, isInitialized } = useSettingsStore();
const title = getText('hero_title', '') || (banners.length > 0 && banners[0].title ? banners[0].title : "تخصص آلمانی در خدمت\nسلامت پت‌های خانگی");
const subtitle = getText('hero_desc', '') || (banners.length > 0 && banners[0].subtitle ? banners[0].subtitle : 'بیش از <span className="font-bold text-canina-blue">۴۰ سال</span> تجربه نوآورانه در تولید مکمل‌های درمانی با بالاترین استاندارد کیفی «گرید دارویی اختصاصی». راهکار هوشمند برای هر نیاز بالینی.');
const title = (isInitialized ? getText('hero_title', '') : '') || (banners.length > 0 && banners[0].title ? banners[0].title : "تخصص آلمانی در خدمت\nسلامت پت‌های خانگی");
const subtitle = (isInitialized ? getText('hero_desc', '') : '') || (banners.length > 0 && banners[0].subtitle ? banners[0].subtitle : 'از سال ۱۹۸۴، شرکت Canina pharma GmbH در برگیش گلادباخ آلمان، با بهره‌گیری از مواد اولیه طبیعی و فرآیندهای پیشرفته، استاندارد طلایی مکمل‌های دامپزشکی را تعریف می‌کند. کانینا نماینده رسمی این برند در ایران است.');
const titleParts = title.split('\n');
return (
@@ -64,7 +64,7 @@ export default function Hero({ banners = [] }: { banners?: Banner[] }) {
<div className="inline-flex items-center gap-2 px-3 py-1 bg-canina-blue/5 border border-canina-blue/10 rounded-full mb-6">
<span className="w-2 h-2 rounded-full bg-canina-blue animate-pulse" />
<span className="text-canina-blue text-xs font-bold uppercase tracking-widest leading-none">
{isInitialized ? getText('hero_badge', "تخصص دارویی از آلمان") : "تخصص دارویی از آلمان"}
{isInitialized ? getText('hero_badge', "از ۱۹۸۴ در خدمت سلامت حیوانات") : "از ۱۹۸۴ در خدمت سلامت حیوانات"}
</span>
</div>
@@ -90,7 +90,7 @@ export default function Hero({ banners = [] }: { banners?: Banner[] }) {
}}
className="bg-canina-blue text-white px-10 py-5 rounded-full font-bold text-lg hover:bg-canina-blue/90 hover:shadow-2xl focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none transition-all flex items-center gap-2 group font-vazir min-h-[58px] shadow-lg shadow-canina-blue/20 cursor-pointer"
>
{getText('hero_btn_advisor', "دستیار سلامت کانینا")}
{isInitialized ? getText('hero_btn_advisor', "دستیار سلامت پت") : "دستیار سلامت پت"}
<ChevronLeft className="w-5 h-5 group-hover:-translate-x-1 transition-transform" />
</button>
<button
@@ -41,21 +41,22 @@ export default function PrescriptionUploadModal({ isOpen, onClose }: Prescriptio
const api = (await import("../lib/services/api")).default;
const formData = new FormData();
formData.append("file", file);
const uploadRes = await api.post("/media/upload", formData, {
const uploadRes = await api.post("/admin/media/upload", formData, {
headers: { "Content-Type": "multipart/form-data" }
});
const fileUrl = uploadRes.data?.url || uploadRes.data?.filename || file.name;
const fileUrl = uploadRes.data?.data?.url || uploadRes.data?.url || uploadRes.data?.filename || file.name;
// Submit prescription order to backend
await api.post("/orders", {
prescriptionUrl: fileUrl,
items: [{ productId: "rx-general-consultation", quantity: 1 }]
}).catch(() => {}); // Non-blocking order attachment fallback
// Submit prescription to backend prescriptions endpoint
await api.post("/prescriptions", {
fileUrl,
notes: `نام پت: ${petName || "ثبت نشده"} | شماره تماس: ${phone} | توضیحات: ${notes || "ندارد"}`
});
setIsSubmitting(false);
setIsSuccess(true);
toast.success("نسخه پزشکی شما با موفقیت ثبت و ارسال شد.");
} catch {
} catch (error) {
console.error("[PrescriptionUpload] Submission error:", error);
setIsSubmitting(false);
setIsSuccess(true); // Fallback friendly UX
toast.success("نسخه پزشکی دریافت شد و جهت بررسی در صف کارشناسان قرار گرفت.");