fix(frontend): comprehensive SEO, A11y, media upload validation, and logging enhancements [FE-013 to FE-022]
This commit is contained in:
1 parent
4ce9f6000c
commit
87999be3d2
10 files changed
+42
-12
No files matched your search
@@ -202,6 +202,23 @@ export default function MediaSelector({ isOpen, onClose, onSelect, multiple = fa
|
||||
const files = Array.from(e.dataTransfer.files);
|
||||
if (files.length === 0) return;
|
||||
|
||||
const ALLOWED_MIME_TYPES = ['image/jpeg', 'image/png', 'image/webp', 'image/svg+xml', 'image/gif', 'application/pdf'];
|
||||
const MAX_FILE_SIZE = 15 * 1024 * 1024; // 15MB
|
||||
|
||||
const validFiles = files.filter(f => {
|
||||
if (!ALLOWED_MIME_TYPES.includes(f.type) && !f.type.startsWith('image/')) {
|
||||
toast.error(`فرمت فایل ${f.name} مجاز نمیباشد.`);
|
||||
return false;
|
||||
}
|
||||
if (f.size > MAX_FILE_SIZE) {
|
||||
toast.error(`حجم فایل ${f.name} بیش از حد مجاز (حداکثر ۱۵ مگابایت) است.`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
if (validFiles.length === 0) return;
|
||||
|
||||
setIsUploading(true);
|
||||
let successCount = 0;
|
||||
try {
|
||||
|
||||
@@ -176,7 +176,7 @@ export default function ClientLayout({ children }: { children: React.ReactNode }
|
||||
onSearch={handleSearch}
|
||||
onB2BOpen={() => setB2BPortalOpen(true)}
|
||||
/>
|
||||
<main className={`min-h-screen ${pathname === '/catalog' ? 'bg-slate-950' : ''}`}>
|
||||
<main id="main-content" className={`min-h-screen ${pathname === '/catalog' ? 'bg-slate-950' : ''}`}>
|
||||
{children}
|
||||
</main>
|
||||
{!isUtilityRoute && <Footer onNavigate={handleNavigate} onShopNavigate={navigateToShop} onB2BOpen={() => setB2BPortalOpen(true)} />}
|
||||
|
||||
@@ -10,7 +10,9 @@ export default function ErrorBoundary({
|
||||
reset: () => void;
|
||||
}) {
|
||||
useEffect(() => {
|
||||
console.error("Global Application Error:", error);
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
console.error("Global Application Error:", error?.message || "Unknown error");
|
||||
}
|
||||
}, [error]);
|
||||
|
||||
return <ServerErrorPage onRetry={reset} />;
|
||||
|
||||
@@ -178,6 +178,12 @@ export default async function RootLayout({
|
||||
<link rel="dns-prefetch" href="https://scripts.clarity.ms" />
|
||||
</head>
|
||||
<body className="min-h-screen bg-medical-gray-50 font-sans" suppressHydrationWarning>
|
||||
<a
|
||||
href="#main-content"
|
||||
className="sr-only focus:not-sr-only focus:fixed focus:top-4 focus:right-4 focus:z-[999999] focus:px-4 focus:py-2.5 focus:bg-canina-blue focus:text-white focus:font-black focus:rounded-xl focus:shadow-2xl focus:outline-none focus:ring-2 focus:ring-white font-vazir text-sm transition-all"
|
||||
>
|
||||
پرش به محتوای اصلی
|
||||
</a>
|
||||
{/* Google Tag Manager (noscript fallback) */}
|
||||
{isGtmEnabled && (
|
||||
<noscript>
|
||||
|
||||
@@ -7,6 +7,7 @@ export async function generateMetadata(): Promise<Metadata> {
|
||||
canonicalPath: '/search',
|
||||
fallbackTitle: 'جستجوی هوشمند مکملها و دانشنامه سلامت',
|
||||
fallbackDesc: 'جستجوی سریع در کاتالوگ محصولات، بیماریها، علائم بالینی و مقالات سلامت کنینا ایران.',
|
||||
noIndex: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
changeFrequency: 'weekly',
|
||||
priority: 0.8,
|
||||
},
|
||||
{
|
||||
url: `${baseUrl}/search`,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: 'weekly',
|
||||
priority: 0.5,
|
||||
},
|
||||
|
||||
{
|
||||
url: `${baseUrl}/about`,
|
||||
lastModified: new Date(),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
"use client";
|
||||
import { sanitizeBlogHtml } from "../lib/sanitizeBlogHtml";
|
||||
import Image from "next/image";
|
||||
import { motion, AnimatePresence, animate } from "motion/react";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { sanitizeBlogHtml } from "../lib/sanitizeBlogHtml";
|
||||
/* eslint-disable @next/next/no-img-element */
|
||||
"use client";
|
||||
/* eslint-disable @next/next/no-img-element */
|
||||
import { sanitizeBlogHtml } from "../lib/sanitizeBlogHtml";
|
||||
import Link from "next/link";
|
||||
import { useState, useMemo, useEffect, useRef } from "react";
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
|
||||
@@ -349,9 +349,11 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
|
||||
<div className="grid md:grid-cols-2 gap-4 max-w-xl mx-auto">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-black text-medical-gray-600 pr-1">{getText('advisor_pet_name_label', "نام پت")}</label>
|
||||
<label htmlFor="advisor-pet-name" className="text-xs font-black text-medical-gray-600 pr-1">{getText('advisor_pet_name_label', "نام پت")}</label>
|
||||
<input
|
||||
id="advisor-pet-name"
|
||||
type="text"
|
||||
aria-label={getText('advisor_pet_name_label', "نام پت")}
|
||||
value={name}
|
||||
onChange={e => {
|
||||
setName(e.target.value);
|
||||
@@ -367,9 +369,11 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-black text-medical-gray-600 pr-1">{getText('advisor_pet_breed_label', "نژاد")}</label>
|
||||
<label htmlFor="advisor-pet-breed" className="text-xs font-black text-medical-gray-600 pr-1">{getText('advisor_pet_breed_label', "نژاد")}</label>
|
||||
<input
|
||||
id="advisor-pet-breed"
|
||||
type="text"
|
||||
aria-label={getText('advisor_pet_breed_label', "نژاد")}
|
||||
value={breed}
|
||||
onChange={e => {
|
||||
setBreed(e.target.value);
|
||||
|
||||
@@ -303,6 +303,10 @@ export async function getPageMetadata(
|
||||
keywords,
|
||||
alternates: {
|
||||
canonical: canonicalUrl,
|
||||
languages: {
|
||||
'fa-IR': canonicalUrl,
|
||||
'x-default': canonicalUrl,
|
||||
},
|
||||
},
|
||||
openGraph: {
|
||||
title: ogTitle,
|
||||
|
||||
Reference in new issue
Block a user