feat(admin/seo): sticky google SERP simulator, tooltip hints on all fields, broken image layout fix, dynamic view online url helper and map slug parameter in application
This commit is contained in:
1 parent
ac4813ebde
commit
4860a0e2e3
2 files changed
+285
-79
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { Search, Filter, Box, Plus, Edit2, Trash2, Image as ImageIcon, X } from 'lucide-react';
|
import { Search, Filter, Box, Plus, Edit2, Trash2, Image as ImageIcon, X, HelpCircle } from 'lucide-react';
|
||||||
import { toast } from 'react-hot-toast';
|
import { toast } from 'react-hot-toast';
|
||||||
import api, { BASE_DOMAIN } from '../services/api';
|
import api, { BASE_DOMAIN } from '../services/api';
|
||||||
import Spinner from '../components/ui/Spinner';
|
import Spinner from '../components/ui/Spinner';
|
||||||
@@ -11,11 +11,33 @@ export default function Products() {
|
|||||||
const [categories, setCategories] = useState<any[]>([]);
|
const [categories, setCategories] = useState<any[]>([]);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
|
// URL and String Helper Functions
|
||||||
|
const getStoreProductUrl = (slug: string) => {
|
||||||
|
const isDev = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
|
||||||
|
if (isDev) {
|
||||||
|
return `http://localhost:4000/shop/${slug}`;
|
||||||
|
}
|
||||||
|
// Production fallback based on actual URL
|
||||||
|
const storeOrigin = window.location.origin.replace('admin', 'www');
|
||||||
|
return `${storeOrigin}/shop/${slug}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const slugify = (text: string) => {
|
||||||
|
return text
|
||||||
|
.toLowerCase()
|
||||||
|
.trim()
|
||||||
|
.replace(/\s+/g, '-')
|
||||||
|
.replace(/[^a-z0-9\-]/g, '')
|
||||||
|
.replace(/-+/g, '-')
|
||||||
|
.replace(/^-|-$/g, '');
|
||||||
|
};
|
||||||
|
|
||||||
// Filters
|
// Filters
|
||||||
const [search, setSearch] = useState('');
|
const [search, setSearch] = useState('');
|
||||||
const [categoryFilter, setCategoryFilter] = useState('');
|
const [categoryFilter, setCategoryFilter] = useState('');
|
||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
const [totalPages, setTotalPages] = useState(1);
|
const [totalPages, setTotalPages] = useState(1);
|
||||||
|
const [imageErrors, setImageErrors] = useState<Record<string, boolean>>({});
|
||||||
const limit = 10;
|
const limit = 10;
|
||||||
|
|
||||||
// Modal State
|
// Modal State
|
||||||
@@ -124,10 +146,19 @@ export default function Products() {
|
|||||||
const handleSave = async (e: React.FormEvent) => {
|
const handleSave = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
try {
|
try {
|
||||||
|
const derivedSlug = formData.slug.trim() || slugify(formData.nameEn);
|
||||||
|
const finalPayload = {
|
||||||
|
...formData,
|
||||||
|
slug: derivedSlug,
|
||||||
|
metaTitle: formData.metaTitle.trim() || `${formData.nameFa || 'نام محصول'} | خرید و قیمت مکمل کانینا`,
|
||||||
|
metaDescription: formData.metaDescription.trim() || formData.shortDescription || 'خرید آنلاین مکمل اصل کانینا آلمان با بالاترین کیفیت بالینی...',
|
||||||
|
canonicalUrl: formData.canonicalUrl.trim() || `/shop/${derivedSlug}`
|
||||||
|
};
|
||||||
|
|
||||||
if (editingProduct) {
|
if (editingProduct) {
|
||||||
await api.put(`/admin/products/${editingProduct.id}`, formData);
|
await api.put(`/admin/products/${editingProduct.id}`, finalPayload);
|
||||||
} else {
|
} else {
|
||||||
await api.post('/admin/products', formData);
|
await api.post('/admin/products', finalPayload);
|
||||||
}
|
}
|
||||||
setIsModalOpen(false);
|
setIsModalOpen(false);
|
||||||
fetchData();
|
fetchData();
|
||||||
@@ -217,15 +248,20 @@ export default function Products() {
|
|||||||
) : (
|
) : (
|
||||||
products.map((product) => (
|
products.map((product) => (
|
||||||
<tr key={product.id} className="hover:bg-gray-50/50 transition-colors">
|
<tr key={product.id} className="hover:bg-gray-50/50 transition-colors">
|
||||||
<td className="py-3 px-6">
|
<td className="py-3 px-6">
|
||||||
{product.imageUrl ? (
|
{product.imageUrl && !imageErrors[product.id] ? (
|
||||||
<img src={product.imageUrl.startsWith('http') ? product.imageUrl : `${BASE_DOMAIN}${product.imageUrl}`} alt={product.nameFa || ''} className="w-12 h-12 rounded-xl object-cover border border-gray-200" />
|
<img
|
||||||
) : (
|
src={product.imageUrl.startsWith('http') ? product.imageUrl : `${BASE_DOMAIN}${product.imageUrl}`}
|
||||||
<div className="w-12 h-12 rounded-xl bg-gray-100 flex items-center justify-center text-gray-400">
|
alt=""
|
||||||
<ImageIcon className="w-5 h-5" />
|
onError={() => setImageErrors(prev => ({ ...prev, [product.id]: true }))}
|
||||||
</div>
|
className="w-12 h-12 rounded-xl object-cover border border-gray-200"
|
||||||
)}
|
/>
|
||||||
</td>
|
) : (
|
||||||
|
<div className="w-12 h-12 rounded-xl bg-gray-100 flex items-center justify-center text-gray-400">
|
||||||
|
<ImageIcon className="w-5 h-5" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
<td className="py-4 px-6 text-gray-500 font-mono text-sm">{product.artNo}</td>
|
<td className="py-4 px-6 text-gray-500 font-mono text-sm">{product.artNo}</td>
|
||||||
<td className="py-4 px-6">
|
<td className="py-4 px-6">
|
||||||
<div className="flex flex-col gap-0.5">
|
<div className="flex flex-col gap-0.5">
|
||||||
@@ -271,16 +307,16 @@ export default function Products() {
|
|||||||
<h3 className="text-xl font-bold text-gray-900">
|
<h3 className="text-xl font-bold text-gray-900">
|
||||||
{editingProduct ? 'ویرایش پیشرفته محصول' : 'افزودن محصول جدید'}
|
{editingProduct ? 'ویرایش پیشرفته محصول' : 'افزودن محصول جدید'}
|
||||||
</h3>
|
</h3>
|
||||||
{editingProduct && formData.slug && (
|
{editingProduct && formData.slug && (
|
||||||
<a
|
<a
|
||||||
href={`http://localhost:3000/shop/${formData.slug}`}
|
href={getStoreProductUrl(formData.slug)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold bg-purple-50 border border-purple-100 text-purple-600 hover:bg-purple-100 transition-all cursor-pointer"
|
className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold bg-purple-50 border border-purple-100 text-purple-600 hover:bg-purple-100 transition-all cursor-pointer"
|
||||||
>
|
>
|
||||||
مشاهده آنلاین در سایت 🔗
|
مشاهده آنلاین در سایت 🔗
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<button onClick={() => setIsModalOpen(false)} className="text-gray-400 hover:text-red-500 transition-colors">
|
<button onClick={() => setIsModalOpen(false)} className="text-gray-400 hover:text-red-500 transition-colors">
|
||||||
<X className="w-6 h-6" />
|
<X className="w-6 h-6" />
|
||||||
@@ -312,30 +348,78 @@ export default function Products() {
|
|||||||
<div className={activeTab === 'general' ? 'block space-y-4' : 'hidden'}>
|
<div className={activeTab === 'general' ? 'block space-y-4' : 'hidden'}>
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<label className="text-sm font-bold text-gray-700">کد محصول (Art No) *</label>
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>کد محصول (Art No) *</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
کد کاتالوگ انحصاری کارخانه Canina آلمان (مانند 123490).
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
<input required type="text" value={formData.artNo} onChange={(e) => setFormData({...formData, artNo: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono" dir="ltr" />
|
<input required type="text" value={formData.artNo} onChange={(e) => setFormData({...formData, artNo: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono" dir="ltr" />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<label className="text-sm font-bold text-gray-700">نام فارسی محصول *</label>
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>نام فارسی محصول *</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
عنوان فارسی محصول که در صفحات و کاتالوگ فروشگاه نمایش داده میشود.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
<input required type="text" value={formData.nameFa} onChange={(e) => setFormData({...formData, nameFa: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" dir="rtl" placeholder="مثال: ژل دندان میکروسیلور" />
|
<input required type="text" value={formData.nameFa} onChange={(e) => setFormData({...formData, nameFa: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" dir="rtl" placeholder="مثال: ژل دندان میکروسیلور" />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<label className="text-sm font-bold text-gray-700">نام انگلیسی / آلمانی (nameEn) *</label>
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>نام انگلیسی / آلمانی (nameEn) *</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
نام برند و وزن کالا به انگلیسی جهت استفاده در آدرس، فاکتورها و سئو.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
<input required type="text" value={formData.nameEn} onChange={(e) => setFormData({...formData, nameEn: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono" dir="ltr" placeholder="e.g. Canina Mikrosilber Zahngel - 50ml" />
|
<input required type="text" value={formData.nameEn} onChange={(e) => setFormData({...formData, nameEn: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono" dir="ltr" placeholder="e.g. Canina Mikrosilber Zahngel - 50ml" />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2 md:col-span-2">
|
<div className="space-y-2 md:col-span-2">
|
||||||
<label className="text-sm font-bold text-gray-700">شعار علمی (Tagline)</label>
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>شعار علمی (Tagline)</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
شعار کلیدی یا علمی کالا که در بالای صفحه محصول نمایش داده میشود.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
<input type="text" value={formData.scientificTagline} onChange={(e) => setFormData({...formData, scientificTagline: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" />
|
<input type="text" value={formData.scientificTagline} onChange={(e) => setFormData({...formData, scientificTagline: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<label className="text-sm font-bold text-gray-700">دستهبندی *</label>
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>دستهبندی *</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
دستهبندی اصلی محصول جهت تقسیمبندی در منوها و سیستم ناوبری سایت.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
<select required value={formData.categoryId} onChange={(e) => setFormData({...formData, categoryId: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none bg-white">
|
<select required value={formData.categoryId} onChange={(e) => setFormData({...formData, categoryId: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none bg-white">
|
||||||
<option value="">انتخاب کنید</option>
|
<option value="">انتخاب کنید</option>
|
||||||
{categories.map(c => <option key={c.id} value={c.id}>{c.name}</option>)}
|
{categories.map(c => <option key={c.id} value={c.id}>{c.name}</option>)}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<label className="text-sm font-bold text-gray-700">مناسب برای</label>
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>مناسب برای</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
تعیین این که کالا برای سگ، گربه یا هر دو گونه مناسب است.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
<select value={formData.suitableFor} onChange={(e) => setFormData({...formData, suitableFor: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none bg-white">
|
<select value={formData.suitableFor} onChange={(e) => setFormData({...formData, suitableFor: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none bg-white">
|
||||||
<option value="سگ">سگ</option>
|
<option value="سگ">سگ</option>
|
||||||
<option value="گربه">گربه</option>
|
<option value="گربه">گربه</option>
|
||||||
@@ -343,19 +427,51 @@ export default function Products() {
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2 md:col-span-2">
|
<div className="space-y-2 md:col-span-2">
|
||||||
<label className="text-sm font-bold text-gray-700">توضیح کوتاه</label>
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>توضیح کوتاه</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
خلاصه ویژگیهای کلیدی کالا که در کارتهای فروشگاه و زیر عنوان محصول نمایش داده میشود.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
<textarea rows={2} value={formData.shortDescription} onChange={(e) => setFormData({...formData, shortDescription: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"></textarea>
|
<textarea rows={2} value={formData.shortDescription} onChange={(e) => setFormData({...formData, shortDescription: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2 md:col-span-2">
|
<div className="space-y-2 md:col-span-2">
|
||||||
<label className="text-sm font-bold text-gray-700">توضیحات کامل</label>
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>توضیحات کامل</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
توضیحات کامل علمی، نحوه عملکرد مکمل و جزئیات ترکیبات محصول.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
<textarea rows={5} value={formData.description} onChange={(e) => setFormData({...formData, description: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"></textarea>
|
<textarea rows={5} value={formData.description} onChange={(e) => setFormData({...formData, description: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2 md:col-span-2">
|
<div className="space-y-2 md:col-span-2">
|
||||||
<label className="text-sm font-bold text-gray-700">منطق دوز مصرفی (Dosage Logic)</label>
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>منطق دوز مصرفی (Dosage Logic)</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
فرمول نحوه مصرف روزانه کالا بر اساس وزن پت (مثال: ۲ میلیلیتر به ازای هر ۵ کیلوگرم وزن).
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
<textarea rows={2} value={formData.dosageLogic} onChange={(e) => setFormData({...formData, dosageLogic: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"></textarea>
|
<textarea rows={2} value={formData.dosageLogic} onChange={(e) => setFormData({...formData, dosageLogic: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2 md:col-span-2">
|
<div className="space-y-2 md:col-span-2">
|
||||||
<label className="text-sm font-bold text-gray-700">علائم درمانی مرتبط (Symptom Tags)</label>
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>علائم درمانی مرتبط (Symptom Tags)</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
علائم متصل به این دارو جهت فیلترینگ و سرچ پویای کاربران (مثال: اسهال، خارش، ریزش مو).
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
<div className="flex flex-wrap gap-2 p-3 bg-white border border-gray-200 rounded-xl min-h-[50px] items-center focus-within:border-purple-500 focus-within:ring-2 focus-within:ring-purple-200 transition-all">
|
<div className="flex flex-wrap gap-2 p-3 bg-white border border-gray-200 rounded-xl min-h-[50px] items-center focus-within:border-purple-500 focus-within:ring-2 focus-within:ring-purple-200 transition-all">
|
||||||
{formData.symptoms && formData.symptoms.map((symptom, idx) => (
|
{formData.symptoms && formData.symptoms.map((symptom, idx) => (
|
||||||
<span key={idx} className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold bg-purple-50 border border-purple-200 text-purple-700">
|
<span key={idx} className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold bg-purple-50 border border-purple-200 text-purple-700">
|
||||||
@@ -420,55 +536,144 @@ export default function Products() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* SEO Tab */}
|
{/* SEO Tab */}
|
||||||
<div className={activeTab === 'seo' ? 'block space-y-6' : 'hidden'}>
|
<div className={activeTab === 'seo' ? 'block' : 'hidden'}>
|
||||||
{/* Google SERP Preview Component */}
|
{(() => {
|
||||||
<div className="bg-gray-100 border border-gray-200 rounded-2xl p-5 space-y-3">
|
const derivedSlug = formData.slug || slugify(formData.nameEn);
|
||||||
<span className="text-[10px] font-black text-gray-400 uppercase tracking-widest block">پیشنمایش نتایج در موتور جستجوی گوگل (Google SERP Preview)</span>
|
const derivedMetaTitle = formData.metaTitle || `${formData.nameFa || 'نام محصول'} | خرید و قیمت مکمل کانینا`;
|
||||||
|
const derivedMetaDescription = formData.metaDescription || (formData.shortDescription || 'خرید آنلاین مکمل اصل کانینا آلمان با بالاترین کیفیت بالینی و ضمانت اصالت فیزیکی...');
|
||||||
|
const derivedCanonicalUrl = formData.canonicalUrl || `/shop/${derivedSlug}`;
|
||||||
|
|
||||||
<div className="bg-white rounded-xl p-4 border border-gray-100 shadow-sm max-w-xl text-right font-sans" dir="rtl">
|
return (
|
||||||
{/* Domain / Breadcrumb */}
|
<div className="grid grid-cols-1 lg:grid-cols-12 gap-6 items-start">
|
||||||
<div className="flex items-center gap-1 text-xs text-[#202124] mb-1">
|
{/* Right Column: SEO Inputs */}
|
||||||
<span className="font-medium text-gray-800">caninoiran.ir</span>
|
<div className="lg:col-span-7 space-y-4">
|
||||||
<span className="text-gray-400">›</span>
|
<div className="space-y-2">
|
||||||
<span className="text-gray-500">shop</span>
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
<span className="text-gray-400">›</span>
|
<span>نامک (Slug) محصول</span>
|
||||||
<span className="text-gray-500 max-w-[150px] truncate">{formData.slug || 'slug-placeholder'}</span>
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
آدرس مستقیم محصول در سایت. در صورت خالی بودن، به طور خودکار از روی نام انگلیسی ساخته میشود.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={formData.slug}
|
||||||
|
onChange={(e) => setFormData({...formData, slug: e.target.value})}
|
||||||
|
className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"
|
||||||
|
dir="ltr"
|
||||||
|
placeholder={derivedSlug}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>عنوان متا (Meta Title)</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
عنوان اصلی صفحه در گوگل (حداکثر ۶۰ کاراکتر). در صورت خالی بودن، از ساختار پیشفرض استفاده میشود.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={formData.metaTitle}
|
||||||
|
onChange={(e) => setFormData({...formData, metaTitle: e.target.value})}
|
||||||
|
className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"
|
||||||
|
placeholder={derivedMetaTitle}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>توضیحات متا (Meta Description)</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
خلاصه توضیحات صفحه در نتایج جستجو (حداکثر ۱۵۵ کاراکتر). در صورت خالی بودن، از توضیحات کوتاه محصول استفاده میشود.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
<textarea
|
||||||
|
rows={3}
|
||||||
|
value={formData.metaDescription}
|
||||||
|
onChange={(e) => setFormData({...formData, metaDescription: e.target.value})}
|
||||||
|
className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"
|
||||||
|
placeholder={derivedMetaDescription}
|
||||||
|
></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>کلمات کلیدی سئو (Keywords)</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
کلمات کلیدی مرتبط با محصول که با کاما (,) از هم جدا شدهاند.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={formData.keywords}
|
||||||
|
onChange={(e) => setFormData({...formData, keywords: e.target.value})}
|
||||||
|
className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"
|
||||||
|
placeholder="مثال: مکمل سگ, تقویت مفاصل, کنهیدروکس"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||||
|
<span>آدرس کانونی (Canonical URL)</span>
|
||||||
|
<div className="group relative inline-block">
|
||||||
|
<HelpCircle className="w-3.5 h-3.5 text-gray-400 hover:text-purple-600 cursor-help" />
|
||||||
|
<div className="absolute bottom-full right-1/2 translate-x-1/2 mb-2 hidden group-hover:block w-52 p-2.5 bg-gray-900 text-white text-[10px] rounded-lg shadow-xl text-center z-30 font-vazir leading-relaxed">
|
||||||
|
آدرس اصلی محصول جهت جلوگیری از جریمه محتوای تکراری در گوگل.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={formData.canonicalUrl}
|
||||||
|
onChange={(e) => setFormData({...formData, canonicalUrl: e.target.value})}
|
||||||
|
className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono text-sm"
|
||||||
|
dir="ltr"
|
||||||
|
placeholder={derivedCanonicalUrl}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Left Column: Sticky Google SERP Preview */}
|
||||||
|
<div className="lg:col-span-5 lg:sticky lg:top-4 bg-gray-100 border border-gray-200 rounded-2xl p-5 space-y-3">
|
||||||
|
<span className="text-[10px] font-black text-gray-400 uppercase tracking-widest block">پیشنمایش نتایج در گوگل (Google SERP Preview)</span>
|
||||||
|
|
||||||
|
<div className="bg-white rounded-xl p-4 border border-gray-100 shadow-sm text-right font-sans" dir="rtl">
|
||||||
|
{/* Domain / Breadcrumb */}
|
||||||
|
<div className="flex items-center gap-1 text-xs text-[#202124] mb-1">
|
||||||
|
<span className="font-medium text-gray-800">caninoiran.ir</span>
|
||||||
|
<span className="text-gray-400">›</span>
|
||||||
|
<span className="text-gray-500">shop</span>
|
||||||
|
<span className="text-gray-400">›</span>
|
||||||
|
<span className="text-gray-500 max-w-[150px] truncate">{derivedSlug}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Title */}
|
||||||
|
<h4 className="text-[19px] text-[#1a0dab] hover:underline cursor-pointer leading-tight font-medium font-sans mb-1 select-none">
|
||||||
|
{derivedMetaTitle}
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
{/* Description */}
|
||||||
|
<p className="text-sm text-[#4d5156] leading-relaxed font-sans select-none break-words">
|
||||||
|
{derivedMetaDescription}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<p className="text-[10px] text-gray-400 font-medium">تغییرات فیلدهای سمت راست، بلافاصله در پیشنمایش بالا منعکس میشود.</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
{/* Title (Standard Google Blue Link) */}
|
})()}
|
||||||
<h4 className="text-[19px] text-[#1a0dab] hover:underline cursor-pointer leading-tight font-medium font-sans mb-1 select-none">
|
|
||||||
{formData.metaTitle || `${formData.nameFa || 'نام محصول'} | کانینا ایران`}
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
{/* Description (Standard Google Snippet Text) */}
|
|
||||||
<p className="text-sm text-[#4d5156] leading-relaxed font-sans select-none">
|
|
||||||
{formData.metaDescription || (formData.shortDescription || 'توضیحات متای این صفحه هنوز نوشته نشده است. گوگل به طور خودکار متنی را از توضیحات محصول رندر میکند...')}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-1 gap-4">
|
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="text-sm font-bold text-gray-700">نامک (Slug) محصول</label>
|
|
||||||
<input type="text" value={formData.slug} onChange={(e) => setFormData({...formData, slug: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" dir="ltr" placeholder="مثال: canhydrox-gag" />
|
|
||||||
</div>
|
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="text-sm font-bold text-gray-700">عنوان متا (Meta Title)</label>
|
|
||||||
<input type="text" value={formData.metaTitle} onChange={(e) => setFormData({...formData, metaTitle: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" />
|
|
||||||
</div>
|
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="text-sm font-bold text-gray-700">توضیحات متا (Meta Description)</label>
|
|
||||||
<textarea rows={3} value={formData.metaDescription} onChange={(e) => setFormData({...formData, metaDescription: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"></textarea>
|
|
||||||
</div>
|
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="text-sm font-bold text-gray-700">کلمات کلیدی (با کاما جدا کنید)</label>
|
|
||||||
<input type="text" value={formData.keywords} onChange={(e) => setFormData({...formData, keywords: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" />
|
|
||||||
</div>
|
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="text-sm font-bold text-gray-700">آدرس کانونی (Canonical URL)</label>
|
|
||||||
<input type="text" value={formData.canonicalUrl} onChange={(e) => setFormData({...formData, canonicalUrl: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono text-sm" dir="ltr" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Media Tab */}
|
{/* Media Tab */}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ export class ProductService {
|
|||||||
onSetOfAction: data.onSetOfAction,
|
onSetOfAction: data.onSetOfAction,
|
||||||
optimisticTemplate: data.optimisticTemplate,
|
optimisticTemplate: data.optimisticTemplate,
|
||||||
feedingAdvice: data.dosageLogic || data.feedingAdvice || '',
|
feedingAdvice: data.dosageLogic || data.feedingAdvice || '',
|
||||||
|
slug: data.slug,
|
||||||
image: (data.imageUrl && data.imageUrl.startsWith('http'))
|
image: (data.imageUrl && data.imageUrl.startsWith('http'))
|
||||||
? data.imageUrl
|
? data.imageUrl
|
||||||
: (local?.image || (data.imageUrl ? `/api${data.imageUrl}` : data.image || '')),
|
: (local?.image || (data.imageUrl ? `/api${data.imageUrl}` : data.image || '')),
|
||||||
|
|||||||
Reference in new issue
Block a user