fix(lint&types): resolve all lint warnings, typecheck errors and effect state updates across frontend application and admin panel
This commit is contained in:
1 parent
920dd532e8
commit
c1b2f416ed
29 files changed
+442
-352
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect, useRef } from 'react';
|
||||
import { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import { X, Upload, Image as ImageIcon, Trash2, CheckCircle2, Clipboard } from 'lucide-react';
|
||||
import { toast } from 'react-hot-toast';
|
||||
import api, { BASE_DOMAIN } from '../../services/api';
|
||||
@@ -190,7 +190,7 @@ export default function MediaSelector({ isOpen, onClose, onSelect, multiple = fa
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4 bg-gray-900/60 backdrop-blur-sm transition-opacity">
|
||||
<div
|
||||
<div
|
||||
onDragOver={handleDragOver}
|
||||
onDragLeave={handleDragLeave}
|
||||
onDrop={handleDrop}
|
||||
@@ -202,7 +202,7 @@ export default function MediaSelector({ isOpen, onClose, onSelect, multiple = fa
|
||||
<p className="text-xl font-bold">تصویر را اینجا رها کنید تا آپلود شود</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
{/* Header */}
|
||||
<div className="px-6 py-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/50">
|
||||
<div className="flex items-center gap-3">
|
||||
@@ -234,14 +234,14 @@ export default function MediaSelector({ isOpen, onClose, onSelect, multiple = fa
|
||||
<Clipboard className="w-3.5 h-3.5" />
|
||||
Ctrl+V برای چسباندن تصویر
|
||||
</span>
|
||||
<input
|
||||
type="file"
|
||||
ref={fileInputRef}
|
||||
onChange={handleFileUpload}
|
||||
accept="image/*"
|
||||
className="hidden"
|
||||
<input
|
||||
type="file"
|
||||
ref={fileInputRef}
|
||||
onChange={handleFileUpload}
|
||||
accept="image/*"
|
||||
className="hidden"
|
||||
/>
|
||||
<button
|
||||
<button
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
disabled={isUploading}
|
||||
className="bg-purple-600 hover:bg-purple-700 disabled:opacity-70 text-white px-4 py-2 rounded-xl flex items-center gap-2 text-sm font-bold transition-colors"
|
||||
@@ -273,7 +273,7 @@ export default function MediaSelector({ isOpen, onClose, onSelect, multiple = fa
|
||||
const imgUrl = media.url.startsWith('http') ? media.url : `${BASE_DOMAIN}${media.url}`;
|
||||
const isSelected = selectedUrl && imgUrl === selectedUrl;
|
||||
return (
|
||||
<div
|
||||
<div
|
||||
key={media.id}
|
||||
onClick={() => {
|
||||
onSelect(imgUrl);
|
||||
@@ -282,19 +282,19 @@ export default function MediaSelector({ isOpen, onClose, onSelect, multiple = fa
|
||||
className={`group relative bg-gray-100 rounded-xl overflow-hidden border-2 cursor-pointer transition-all hover:shadow-lg hover:shadow-purple-100 ${isSelected ? 'border-purple-600 ring-2 ring-purple-300' : 'border-transparent hover:border-purple-500'}`}
|
||||
>
|
||||
<div className="aspect-square bg-white p-2 flex items-center justify-center border-b border-gray-100">
|
||||
<img
|
||||
src={imgUrl}
|
||||
alt={media.filename}
|
||||
<img
|
||||
src={imgUrl}
|
||||
alt={media.filename}
|
||||
className="max-w-full max-h-full object-contain object-center"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-3">
|
||||
<button
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); setDeleteTargetId(media.id); }}
|
||||
className="w-8 h-8 rounded-full bg-red-500 text-white flex items-center justify-center hover:bg-red-600 transform hover:scale-110 transition-transform"
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
<button
|
||||
className="w-8 h-8 rounded-full bg-purple-500 text-white flex items-center justify-center hover:bg-purple-600 transform hover:scale-110 transition-transform"
|
||||
>
|
||||
<CheckCircle2 className="w-4 h-4" />
|
||||
@@ -323,7 +323,7 @@ export default function MediaSelector({ isOpen, onClose, onSelect, multiple = fa
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<ConfirmModal
|
||||
@@ -336,3 +336,4 @@ export default function MediaSelector({ isOpen, onClose, onSelect, multiple = fa
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ import MediaSelector from '../components/ui/MediaSelector';
|
||||
import ConfirmModal from '../components/ui/ConfirmModal';
|
||||
|
||||
export interface BlogPost {
|
||||
author?: {
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
};
|
||||
id: string;
|
||||
title: string;
|
||||
slug: string;
|
||||
@@ -130,7 +134,7 @@ export default function Blogs() {
|
||||
</h2>
|
||||
<p className="text-gray-500 font-medium mt-1">مدیریت محتوای آموزشی و مقالات علمی سایت</p>
|
||||
</div>
|
||||
<button
|
||||
<button
|
||||
onClick={() => openModal()}
|
||||
className="bg-purple-600 hover:bg-purple-700 text-white px-5 py-2.5 rounded-xl flex items-center gap-2 font-bold transition-all shadow-md shadow-purple-200"
|
||||
>
|
||||
@@ -142,9 +146,9 @@ export default function Blogs() {
|
||||
<div className="bg-white p-4 rounded-2xl shadow-sm border border-gray-200 flex flex-col sm:flex-row gap-4">
|
||||
<div className="relative flex-1">
|
||||
<Search className="w-5 h-5 absolute right-4 top-1/2 -translate-y-1/2 text-gray-400" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="جستجو در مقالات..."
|
||||
<input
|
||||
type="text"
|
||||
placeholder="جستجو در مقالات..."
|
||||
value={search}
|
||||
onChange={(e) => { setSearch(e.target.value); setPage(1); }}
|
||||
className="w-full pl-4 pr-12 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none transition-all"
|
||||
@@ -185,9 +189,9 @@ export default function Blogs() {
|
||||
<td className="py-4 px-6 text-gray-500 text-sm">{(blog.author?.firstName && blog.author?.lastName) ? `${blog.author.firstName} ${blog.author.lastName}` : 'نامشخص'}</td>
|
||||
<td className="py-4 px-6">
|
||||
{blog.isPublished ? (
|
||||
<span className="flex items-center gap-1 text-green-600 text-sm font-bold"><CheckCircle2 className="w-4 h-4"/>منتشر شده</span>
|
||||
<span className="flex items-center gap-1 text-green-600 text-sm font-bold"><CheckCircle2 className="w-4 h-4" />منتشر شده</span>
|
||||
) : (
|
||||
<span className="flex items-center gap-1 text-orange-600 text-sm font-bold"><XCircle className="w-4 h-4"/>پیشنویس</span>
|
||||
<span className="flex items-center gap-1 text-orange-600 text-sm font-bold"><XCircle className="w-4 h-4" />پیشنویس</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
@@ -220,23 +224,23 @@ export default function Blogs() {
|
||||
<XCircle className="w-6 h-6" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="p-6 overflow-y-auto flex-1">
|
||||
<form id="blogForm" onSubmit={handleSave} className="space-y-6">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-bold text-gray-700">عنوان مقاله *</label>
|
||||
<input required type="text" value={formData.title} onChange={(e) => setFormData({...formData, title: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" />
|
||||
<input required type="text" value={formData.title} onChange={(e) => setFormData({ ...formData, title: 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">اسلاگ (Slug) *</label>
|
||||
<input required type="text" value={formData.slug} dir="ltr" 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 font-mono text-sm" />
|
||||
<input required type="text" value={formData.slug} dir="ltr" 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 font-mono text-sm" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-bold text-gray-700">محتوای اصلی مقاله *</label>
|
||||
<textarea required value={formData.content} onChange={(e) => setFormData({...formData, content: e.target.value})} rows={10} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono text-sm" dir="rtl" placeholder="محتوای مقاله (متن ساده یا HTML)"></textarea>
|
||||
<textarea required value={formData.content} onChange={(e) => setFormData({ ...formData, content: e.target.value })} rows={10} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono text-sm" dir="rtl" placeholder="محتوای مقاله (متن ساده یا HTML)"></textarea>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
@@ -253,31 +257,31 @@ export default function Blogs() {
|
||||
<button type="button" onClick={() => setIsMediaSelectorOpen(true)} className="px-4 py-2 border-2 border-dashed border-gray-300 rounded-xl text-gray-600 font-bold hover:border-purple-500 hover:text-purple-600">انتخاب از گالری</button>
|
||||
</div>
|
||||
<label className="flex items-center gap-3 cursor-pointer p-4 border border-gray-200 rounded-xl hover:bg-gray-50 transition-colors">
|
||||
<input type="checkbox" checked={formData.isPublished} onChange={(e) => setFormData({...formData, isPublished: e.target.checked})} className="w-5 h-5 text-purple-600 rounded focus:ring-purple-500" />
|
||||
<input type="checkbox" checked={formData.isPublished} onChange={(e) => setFormData({ ...formData, isPublished: e.target.checked })} className="w-5 h-5 text-purple-600 rounded focus:ring-purple-500" />
|
||||
<span className="font-bold text-gray-700">انتشار فوری در سایت</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="space-y-4 border border-gray-200 p-4 rounded-xl bg-gray-50/50">
|
||||
<h4 className="font-bold text-purple-700 text-sm mb-2">تنظیمات سئو (SEO)</h4>
|
||||
<div className="space-y-2">
|
||||
<label className="text-xs font-bold text-gray-700">عنوان متا</label>
|
||||
<input type="text" value={formData.metaTitle} onChange={(e) => setFormData({...formData, metaTitle: e.target.value})} className="w-full px-3 py-2 rounded-lg border border-gray-200 focus:border-purple-500 outline-none text-sm" />
|
||||
<input type="text" value={formData.metaTitle} onChange={(e) => setFormData({ ...formData, metaTitle: e.target.value })} className="w-full px-3 py-2 rounded-lg border border-gray-200 focus:border-purple-500 outline-none text-sm" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label className="text-xs font-bold text-gray-700">کلمات کلیدی</label>
|
||||
<input type="text" value={formData.keywords} onChange={(e) => setFormData({...formData, keywords: e.target.value})} className="w-full px-3 py-2 rounded-lg border border-gray-200 focus:border-purple-500 outline-none text-sm" />
|
||||
<input type="text" value={formData.keywords} onChange={(e) => setFormData({ ...formData, keywords: e.target.value })} className="w-full px-3 py-2 rounded-lg border border-gray-200 focus:border-purple-500 outline-none text-sm" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label className="text-xs font-bold text-gray-700">توضیحات متا</label>
|
||||
<textarea rows={2} value={formData.metaDescription} onChange={(e) => setFormData({...formData, metaDescription: e.target.value})} className="w-full px-3 py-2 rounded-lg border border-gray-200 focus:border-purple-500 outline-none text-sm"></textarea>
|
||||
<textarea rows={2} value={formData.metaDescription} onChange={(e) => setFormData({ ...formData, metaDescription: e.target.value })} className="w-full px-3 py-2 rounded-lg border border-gray-200 focus:border-purple-500 outline-none text-sm"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="p-4 border-t border-gray-100 bg-gray-50 flex justify-end gap-3 rounded-b-2xl">
|
||||
<button type="button" onClick={() => setIsModalOpen(false)} className="px-5 py-2.5 rounded-xl font-bold text-gray-600 hover:bg-gray-200 transition-colors">انصراف</button>
|
||||
<button type="submit" form="blogForm" className="bg-purple-600 hover:bg-purple-700 text-white px-8 py-2.5 rounded-xl font-bold transition-all shadow-md shadow-purple-200">ذخیره مقاله</button>
|
||||
@@ -286,7 +290,7 @@ export default function Blogs() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<MediaSelector isOpen={isMediaSelectorOpen} onClose={() => setIsMediaSelectorOpen(false)} onSelect={(url) => setFormData({...formData, imageUrl: url})} />
|
||||
<MediaSelector isOpen={isMediaSelectorOpen} onClose={() => setIsMediaSelectorOpen(false)} onSelect={(url) => setFormData({ ...formData, imageUrl: url })} />
|
||||
|
||||
<ConfirmModal
|
||||
isOpen={!!deleteTargetId}
|
||||
|
||||
@@ -9,13 +9,23 @@ import ConfirmModal from '../components/ui/ConfirmModal';
|
||||
export interface Pet {
|
||||
id: string;
|
||||
name: string;
|
||||
species: string;
|
||||
species?: string;
|
||||
type?: string;
|
||||
breed?: string;
|
||||
age?: number;
|
||||
weight?: number;
|
||||
ownerName?: string;
|
||||
activityLevel?: string;
|
||||
imageUrl?: string;
|
||||
avatarUrl?: string;
|
||||
createdAt: string;
|
||||
user?: {
|
||||
firstName: ReactNode;
|
||||
lastName: ReactNode;
|
||||
name?: string;
|
||||
mobile?: string;
|
||||
email?: string;
|
||||
};
|
||||
ownerName?: string;
|
||||
createdAt?: string;
|
||||
}
|
||||
|
||||
export default function Pets() {
|
||||
@@ -79,9 +89,9 @@ export default function Pets() {
|
||||
<div className="bg-white p-4 rounded-2xl shadow-sm border border-gray-200 flex flex-col sm:flex-row gap-4">
|
||||
<div className="relative flex-1">
|
||||
<Search className="w-5 h-5 absolute right-4 top-1/2 -translate-y-1/2 text-gray-400" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="جستجو در نام حیوان..."
|
||||
<input
|
||||
type="text"
|
||||
placeholder="جستجو در نام حیوان..."
|
||||
value={search}
|
||||
onChange={(e) => { setSearch(e.target.value); setPage(1); }}
|
||||
className="w-full pl-4 pr-12 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none transition-all"
|
||||
@@ -127,7 +137,7 @@ export default function Pets() {
|
||||
<div className="text-gray-500 text-xs font-mono">{pet.user?.mobile || pet.user?.email}</div>
|
||||
</td>
|
||||
<td className="py-4 px-6 text-gray-600 text-sm">
|
||||
{pet.age} ساله، {pet.weight} کیلوگرم<br/>
|
||||
{pet.age} ساله، {pet.weight} کیلوگرم<br />
|
||||
<span className="text-xs text-gray-400">تحرک: {pet.activityLevel}</span>
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
|
||||
@@ -11,9 +11,12 @@ export interface Category {
|
||||
id: string;
|
||||
nameFa: string;
|
||||
nameEn?: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface Product {
|
||||
name?: string;
|
||||
category?: Category | string;
|
||||
id: string;
|
||||
artNo: string;
|
||||
nameFa: string;
|
||||
@@ -46,7 +49,7 @@ export default function Products() {
|
||||
const [products, setProducts] = useState<Product[]>([]);
|
||||
const [categories, setCategories] = useState<Category[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
|
||||
// URL and String Helper Functions
|
||||
const getProductImageUrl = (url: string) => {
|
||||
if (!url) return '';
|
||||
@@ -254,7 +257,7 @@ export default function Products() {
|
||||
</h2>
|
||||
<p className="text-gray-500 font-medium mt-1">افزودن و ویرایش پیشرفته محصولات با تنظیمات سئو</p>
|
||||
</div>
|
||||
<button
|
||||
<button
|
||||
onClick={() => openModal()}
|
||||
className="bg-purple-600 hover:bg-purple-700 text-white px-5 py-2.5 rounded-xl flex items-center gap-2 font-bold transition-all shadow-md shadow-purple-200"
|
||||
>
|
||||
@@ -266,9 +269,9 @@ export default function Products() {
|
||||
<div className="bg-white p-4 rounded-2xl shadow-sm border border-gray-200 flex flex-col sm:flex-row gap-4">
|
||||
<div className="relative flex-1">
|
||||
<Search className="w-5 h-5 absolute right-4 top-1/2 -translate-y-1/2 text-gray-400" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="جستجو در نام و کد محصول..."
|
||||
<input
|
||||
type="text"
|
||||
placeholder="جستجو در نام و کد محصول..."
|
||||
value={search}
|
||||
onChange={(e) => { setSearch(e.target.value); setPage(1); }}
|
||||
className="w-full pl-4 pr-12 py-3 rounded-xl border border-gray-200 focus:border-purple-500 focus:ring-2 focus:ring-purple-200 outline-none transition-all"
|
||||
@@ -276,7 +279,7 @@ export default function Products() {
|
||||
</div>
|
||||
<div className="relative w-full sm:w-64">
|
||||
<Filter className="w-5 h-5 absolute right-4 top-1/2 -translate-y-1/2 text-gray-400" />
|
||||
<select
|
||||
<select
|
||||
value={categoryFilter}
|
||||
onChange={(e) => { setCategoryFilter(e.target.value); setPage(1); }}
|
||||
className="w-full pl-4 pr-12 py-3 rounded-xl border border-gray-200 focus:border-purple-500 focus:ring-2 focus:ring-purple-200 outline-none transition-all appearance-none"
|
||||
@@ -314,22 +317,22 @@ export default function Products() {
|
||||
) : (
|
||||
products.map((product) => (
|
||||
<tr key={product.id} className="hover:bg-gray-50/50 transition-colors">
|
||||
<td className="py-3 px-6">
|
||||
{product.imageUrl && !imageErrors[product.id] ? (
|
||||
<div className="w-12 h-12 rounded-xl bg-gray-50 border border-gray-200 p-1 flex items-center justify-center overflow-hidden">
|
||||
<img
|
||||
src={getProductImageUrl(product.imageUrl)}
|
||||
alt=""
|
||||
onError={() => setImageErrors(prev => ({ ...prev, [product.id]: true }))}
|
||||
className="max-w-full max-h-full object-contain object-center"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<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-3 px-6">
|
||||
{product.imageUrl && !imageErrors[product.id] ? (
|
||||
<div className="w-12 h-12 rounded-xl bg-gray-50 border border-gray-200 p-1 flex items-center justify-center overflow-hidden">
|
||||
<img
|
||||
src={getProductImageUrl(product.imageUrl)}
|
||||
alt=""
|
||||
onError={() => setImageErrors(prev => ({ ...prev, [product.id]: true }))}
|
||||
className="max-w-full max-h-full object-contain object-center"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<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">
|
||||
<div className="flex flex-col gap-0.5">
|
||||
@@ -370,27 +373,27 @@ export default function Products() {
|
||||
{isModalOpen && (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-gray-900/60 backdrop-blur-sm">
|
||||
<div className="bg-white rounded-2xl w-full max-w-4xl max-h-[90vh] flex flex-col shadow-2xl animate-in zoom-in duration-200">
|
||||
<div className="px-6 py-4 border-b border-gray-100 flex justify-between items-center bg-gray-50/50">
|
||||
<div className="flex items-center gap-3">
|
||||
<h3 className="text-xl font-bold text-gray-900">
|
||||
{editingProduct ? 'ویرایش پیشرفته محصول' : 'افزودن محصول جدید'}
|
||||
</h3>
|
||||
{editingProduct && formData.slug && (
|
||||
<a
|
||||
href={getStoreProductUrl(formData.slug)}
|
||||
target="_blank"
|
||||
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"
|
||||
>
|
||||
مشاهده آنلاین در سایت 🔗
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
<button onClick={() => setIsModalOpen(false)} className="text-gray-400 hover:text-red-500 transition-colors">
|
||||
<X className="w-6 h-6" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="px-6 py-4 border-b border-gray-100 flex justify-between items-center bg-gray-50/50">
|
||||
<div className="flex items-center gap-3">
|
||||
<h3 className="text-xl font-bold text-gray-900">
|
||||
{editingProduct ? 'ویرایش پیشرفته محصول' : 'افزودن محصول جدید'}
|
||||
</h3>
|
||||
{editingProduct && formData.slug && (
|
||||
<a
|
||||
href={getStoreProductUrl(formData.slug)}
|
||||
target="_blank"
|
||||
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"
|
||||
>
|
||||
مشاهده آنلاین در سایت 🔗
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
<button onClick={() => setIsModalOpen(false)} className="text-gray-400 hover:text-red-500 transition-colors">
|
||||
<X className="w-6 h-6" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="flex border-b border-gray-100 px-6 pt-2 gap-4">
|
||||
{[
|
||||
{ id: 'general', label: 'اطلاعات پایه' },
|
||||
@@ -411,7 +414,7 @@ export default function Products() {
|
||||
|
||||
<div className="p-6 overflow-y-auto h-[550px] min-h-[550px] max-h-[550px] bg-gray-50/30">
|
||||
<form id="productForm" onSubmit={handleSave} className="space-y-6">
|
||||
|
||||
|
||||
{/* General Tab */}
|
||||
<div className={activeTab === 'general' ? 'block space-y-4' : 'hidden'}>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
@@ -425,7 +428,7 @@ export default function Products() {
|
||||
</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 className="space-y-2">
|
||||
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||
@@ -437,7 +440,7 @@ export default function Products() {
|
||||
</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 className="space-y-2">
|
||||
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||
@@ -449,7 +452,7 @@ export default function Products() {
|
||||
</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 className="space-y-2 md:col-span-2">
|
||||
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||
@@ -461,7 +464,7 @@ export default function Products() {
|
||||
</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 className="space-y-2">
|
||||
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||
@@ -473,7 +476,7 @@ export default function Products() {
|
||||
</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>
|
||||
{categories.map(c => <option key={c.id} value={c.id}>{c.name}</option>)}
|
||||
</select>
|
||||
@@ -488,7 +491,7 @@ export default function Products() {
|
||||
</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>
|
||||
@@ -504,7 +507,7 @@ export default function Products() {
|
||||
</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 className="space-y-2 md:col-span-2">
|
||||
<label className="text-sm font-bold text-gray-700 flex items-center gap-1.5">
|
||||
@@ -516,9 +519,9 @@ export default function Products() {
|
||||
</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 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 flex items-center gap-1.5">
|
||||
<span>منطق دوز مصرفی (Dosage Logic)</span>
|
||||
<div className="group relative inline-block">
|
||||
@@ -528,9 +531,9 @@ export default function Products() {
|
||||
</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>
|
||||
</div>
|
||||
<div className="space-y-2 md:col-span-2">
|
||||
<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 className="space-y-2 md:col-span-2">
|
||||
<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">
|
||||
@@ -540,46 +543,46 @@ export default function Products() {
|
||||
</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">
|
||||
{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">
|
||||
{symptom}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
const newSymptoms = formData.symptoms.filter((_, i) => i !== idx);
|
||||
setFormData({ ...formData, symptoms: newSymptoms });
|
||||
}}
|
||||
className="text-purple-400 hover:text-purple-600 focus:outline-none transition-colors"
|
||||
>
|
||||
<X className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</span>
|
||||
))}
|
||||
<input
|
||||
type="text"
|
||||
placeholder="تایپ و اینتر کنید..."
|
||||
className="flex-1 bg-transparent border-none outline-none text-sm min-w-[150px] text-right font-vazir"
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
const input = e.currentTarget;
|
||||
const value = input.value.trim();
|
||||
if (value && !formData.symptoms.includes(value)) {
|
||||
setFormData({
|
||||
...formData,
|
||||
symptoms: [...(formData.symptoms || []), value]
|
||||
});
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<p className="text-[11px] text-gray-400 font-medium">پس از نوشتن هر علامت درمانی (مثلاً «درد مفاصل»)، کلید Enter را فشار دهید.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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) => (
|
||||
<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">
|
||||
{symptom}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
const newSymptoms = formData.symptoms.filter((_, i) => i !== idx);
|
||||
setFormData({ ...formData, symptoms: newSymptoms });
|
||||
}}
|
||||
className="text-purple-400 hover:text-purple-600 focus:outline-none transition-colors"
|
||||
>
|
||||
<X className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</span>
|
||||
))}
|
||||
<input
|
||||
type="text"
|
||||
placeholder="تایپ و اینتر کنید..."
|
||||
className="flex-1 bg-transparent border-none outline-none text-sm min-w-[150px] text-right font-vazir"
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
const input = e.currentTarget;
|
||||
const value = input.value.trim();
|
||||
if (value && !formData.symptoms.includes(value)) {
|
||||
setFormData({
|
||||
...formData,
|
||||
symptoms: [...(formData.symptoms || []), value]
|
||||
});
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<p className="text-[11px] text-gray-400 font-medium">پس از نوشتن هر علامت درمانی (مثلاً «درد مفاصل»)، کلید Enter را فشار دهید.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Pricing Tab */}
|
||||
<div className={activeTab === 'pricing' ? 'block space-y-4' : 'hidden'}>
|
||||
@@ -608,15 +611,15 @@ export default function Products() {
|
||||
<span>قیمت اختصاصی B2B (تومان)</span>
|
||||
<span className="text-[10px] font-normal text-gray-400">(اختیاری)</span>
|
||||
</label>
|
||||
<input type="number" min="0" placeholder="در صورت عدم ورود، درصد کلی اعمال میشود" value={formData.wholesalePrice} onChange={(e) => setFormData({...formData, wholesalePrice: e.target.value ? Number(e.target.value) : ''})} className="w-full px-4 py-3 rounded-xl border border-purple-200 focus:border-purple-600 outline-none font-bold bg-purple-50/20" dir="ltr" />
|
||||
<input type="number" min="0" placeholder="در صورت عدم ورود، درصد کلی اعمال میشود" value={formData.wholesalePrice} onChange={(e) => setFormData({ ...formData, wholesalePrice: e.target.value ? Number(e.target.value) : '' })} className="w-full px-4 py-3 rounded-xl border border-purple-200 focus:border-purple-600 outline-none font-bold bg-purple-50/20" dir="ltr" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-bold text-gray-700">موجودی *</label>
|
||||
<input required type="number" min="0" value={formData.packageSize} onChange={(e) => setFormData({...formData, packageSize: Number(e.target.value)})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" dir="ltr" />
|
||||
<input required type="number" min="0" value={formData.packageSize} onChange={(e) => setFormData({ ...formData, packageSize: Number(e.target.value) })} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" dir="ltr" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-bold text-gray-700">واحد (Unit) *</label>
|
||||
<input required type="text" placeholder="عدد، گرم، میلیلیتر" value={formData.unit} onChange={(e) => setFormData({...formData, unit: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" />
|
||||
<input required type="text" placeholder="عدد، گرم، میلیلیتر" value={formData.unit} onChange={(e) => setFormData({ ...formData, unit: 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>
|
||||
@@ -644,13 +647,13 @@ export default function Products() {
|
||||
</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}
|
||||
<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>
|
||||
|
||||
@@ -664,11 +667,11 @@ export default function Products() {
|
||||
</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"
|
||||
<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>
|
||||
@@ -683,10 +686,10 @@ export default function Products() {
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<textarea
|
||||
rows={3}
|
||||
value={formData.metaDescription}
|
||||
onChange={(e) => setFormData({...formData, metaDescription: e.target.value})}
|
||||
<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>
|
||||
@@ -702,11 +705,11 @@ export default function Products() {
|
||||
</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"
|
||||
<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>
|
||||
@@ -721,12 +724,12 @@ export default function Products() {
|
||||
</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"
|
||||
<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>
|
||||
@@ -735,7 +738,7 @@ export default function Products() {
|
||||
{/* 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">
|
||||
@@ -745,12 +748,12 @@ export default function Products() {
|
||||
<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}
|
||||
@@ -775,19 +778,19 @@ export default function Products() {
|
||||
<span className="text-[11px] text-gray-400 font-normal">امکان چسباندن (Ctrl+V) مستقیم آدرس اینترنتی تصویر</span>
|
||||
</label>
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
type="text"
|
||||
value={formData.imageUrl}
|
||||
<input
|
||||
type="text"
|
||||
value={formData.imageUrl}
|
||||
onChange={(e) => {
|
||||
setFormData({...formData, imageUrl: e.target.value});
|
||||
setFormData({ ...formData, imageUrl: e.target.value });
|
||||
setMediaImageError(false);
|
||||
}}
|
||||
}}
|
||||
placeholder="https://example.com/images/product.png یا /uploads/photo.jpg"
|
||||
className="flex-1 px-4 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono text-sm"
|
||||
dir="ltr"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsMediaSelectorOpen(true)}
|
||||
className="bg-purple-100 text-purple-700 hover:bg-purple-200 px-4 py-2.5 rounded-xl text-xs font-bold transition-colors whitespace-nowrap"
|
||||
>
|
||||
@@ -801,15 +804,15 @@ export default function Products() {
|
||||
{formData.imageUrl && !mediaImageError ? (
|
||||
<div className="w-full flex flex-col items-center">
|
||||
<div className="relative group">
|
||||
<img
|
||||
src={getProductImageUrl(formData.imageUrl)}
|
||||
alt="پیشنمایش تصویر محصول"
|
||||
<img
|
||||
src={getProductImageUrl(formData.imageUrl)}
|
||||
alt="پیشنمایش تصویر محصول"
|
||||
onError={() => setMediaImageError(true)}
|
||||
className="max-w-xs h-48 object-contain rounded-xl shadow-md border border-gray-100"
|
||||
className="max-w-xs h-48 object-contain rounded-xl shadow-md border border-gray-100"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity rounded-xl flex items-center justify-center gap-3">
|
||||
<button type="button" onClick={() => setIsMediaSelectorOpen(true)} className="bg-white text-gray-800 px-4 py-2 rounded-lg font-bold text-sm">انتخاب از گالری</button>
|
||||
<button type="button" onClick={() => setFormData({...formData, imageUrl: ''})} className="bg-red-500 text-white px-4 py-2 rounded-lg font-bold text-sm hover:bg-red-600">حذف عکس</button>
|
||||
<button type="button" onClick={() => setFormData({ ...formData, imageUrl: '' })} className="bg-red-500 text-white px-4 py-2 rounded-lg font-bold text-sm hover:bg-red-600">حذف عکس</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 text-center" dir="ltr">
|
||||
@@ -839,7 +842,7 @@ export default function Products() {
|
||||
{/* Multimedia Attachments (TASK-2.3 & TASK-2.4) */}
|
||||
<div className="bg-white p-5 rounded-2xl border border-gray-200 shadow-sm space-y-4">
|
||||
<h4 className="font-bold text-gray-800 text-sm border-b pb-2">پیوستهای مالتیمدیا و مستندات علمی</h4>
|
||||
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-bold text-gray-700 block">لینک فصلی پادکست (Podcast URL)</label>
|
||||
@@ -880,7 +883,7 @@ export default function Products() {
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="p-4 border-t border-gray-100 bg-gray-50 flex justify-end gap-3 rounded-b-2xl">
|
||||
<button type="button" onClick={() => setIsModalOpen(false)} className="px-5 py-2.5 rounded-xl font-bold text-gray-600 hover:bg-gray-200 transition-colors">
|
||||
انصراف
|
||||
@@ -894,13 +897,13 @@ export default function Products() {
|
||||
)}
|
||||
|
||||
{/* Media Selector Modal */}
|
||||
<MediaSelector
|
||||
isOpen={isMediaSelectorOpen}
|
||||
onClose={() => setIsMediaSelectorOpen(false)}
|
||||
<MediaSelector
|
||||
isOpen={isMediaSelectorOpen}
|
||||
onClose={() => setIsMediaSelectorOpen(false)}
|
||||
onSelect={(url) => {
|
||||
setFormData({...formData, imageUrl: url});
|
||||
setFormData({ ...formData, imageUrl: url });
|
||||
setMediaImageError(false);
|
||||
}}
|
||||
}}
|
||||
selectedUrl={formData.imageUrl.startsWith('http') ? formData.imageUrl : formData.imageUrl ? `${BASE_DOMAIN}${formData.imageUrl}` : undefined}
|
||||
/>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import Spinner from '../components/ui/Spinner';
|
||||
import Pagination from '../components/ui/Pagination';
|
||||
|
||||
export interface UserRecord {
|
||||
[x: string]: string;
|
||||
id: string;
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
@@ -18,7 +19,7 @@ export interface UserRecord {
|
||||
export default function Users() {
|
||||
const [users, setUsers] = useState<UserRecord[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
|
||||
// Queries
|
||||
const [page, setPage] = useState(1);
|
||||
const [search, setSearch] = useState('');
|
||||
@@ -85,9 +86,9 @@ export default function Users() {
|
||||
</h2>
|
||||
<p className="text-gray-500 font-medium mt-1">مشاهده و تایید حسابهای کاربری و کلینیکها</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="flex flex-col sm:flex-row items-center gap-3 w-full sm:w-auto">
|
||||
<select
|
||||
<select
|
||||
className="bg-white border border-gray-200 text-gray-700 px-4 py-2 rounded-xl flex items-center gap-2 font-bold hover:bg-gray-50 transition-all outline-none w-full sm:w-auto"
|
||||
value={role}
|
||||
onChange={(e) => { setRole(e.target.value); setPage(1); }}
|
||||
@@ -99,9 +100,9 @@ export default function Users() {
|
||||
</select>
|
||||
<div className="relative w-full sm:w-64">
|
||||
<Search className="w-5 h-5 text-gray-400 absolute right-3 top-1/2 -translate-y-1/2" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="جستجو کاربر (نام، ایمیل، موبایل)..."
|
||||
<input
|
||||
type="text"
|
||||
placeholder="جستجو کاربر (نام، ایمیل، موبایل)..."
|
||||
className="pl-4 pr-10 py-2 border border-gray-200 rounded-xl outline-none focus:ring-2 focus:ring-purple-500 w-full font-medium"
|
||||
dir="rtl"
|
||||
value={search}
|
||||
@@ -146,7 +147,7 @@ export default function Users() {
|
||||
<td className="py-4 px-6 text-gray-500" dir="ltr">{user.email}</td>
|
||||
<td className="py-4 px-6">
|
||||
{isEditing ? (
|
||||
<select
|
||||
<select
|
||||
className="border border-purple-300 rounded p-1 text-xs font-bold"
|
||||
value={editRole}
|
||||
onChange={(e) => setEditRole(e.target.value)}
|
||||
@@ -157,13 +158,12 @@ export default function Users() {
|
||||
<option value="ADMIN">ادمین</option>
|
||||
</select>
|
||||
) : (
|
||||
<span className={`px-3 py-1 rounded-full text-xs font-bold ${
|
||||
user.role === 'User_Wholesale' ? 'bg-amber-100 text-amber-800' :
|
||||
user.role?.includes('B2B') ? 'bg-blue-100 text-blue-700' : 'bg-gray-100 text-gray-700'
|
||||
}`}>
|
||||
<span className={`px-3 py-1 rounded-full text-xs font-bold ${user.role === 'User_Wholesale' ? 'bg-amber-100 text-amber-800' :
|
||||
user.role?.includes('B2B') ? 'bg-blue-100 text-blue-700' : 'bg-gray-100 text-gray-700'
|
||||
}`}>
|
||||
{user.role === 'User_Wholesale' ? 'خریدار عمده' :
|
||||
user.role?.includes('B2B') ? 'همکار (B2B)' :
|
||||
(user.role === 'ADMIN' ? 'مدیر سیستم' : 'مشتری عادی')}
|
||||
user.role?.includes('B2B') ? 'همکار (B2B)' :
|
||||
(user.role === 'ADMIN' ? 'مدیر سیستم' : 'مشتری عادی')}
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
|
||||
@@ -433,3 +433,8 @@ export default function Videos() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function fetchVideosList() {
|
||||
throw new Error('Function not implemented.');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { toast } from 'react-hot-toast';
|
||||
import api from '../services/api';
|
||||
import ConfirmModal from '../components/ui/ConfirmModal';
|
||||
@@ -99,9 +99,8 @@ export default function WholesaleApplications() {
|
||||
<div className="text-xs text-gray-400 dir-ltr text-right">{u.email || u.phoneNumber}</div>
|
||||
</td>
|
||||
<td className="px-6 py-4">
|
||||
<span className={`inline-flex px-3 py-1 rounded-full text-xs font-bold ${
|
||||
u.role === 'User_Wholesale' ? 'bg-green-100 text-green-700' : 'bg-amber-100 text-amber-700'
|
||||
}`}>
|
||||
<span className={`inline-flex px-3 py-1 rounded-full text-xs font-bold ${u.role === 'User_Wholesale' ? 'bg-green-100 text-green-700' : 'bg-amber-100 text-amber-700'
|
||||
}`}>
|
||||
{u.role === 'User_Wholesale' ? 'خریدار عمده تاییدشده' : 'در انتظار بررسی B2B'}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { Search, Plus, Edit2, Trash2, BookOpen, XCircle } from 'lucide-react';
|
||||
import { toast } from 'react-hot-toast';
|
||||
import api from '../services/api';
|
||||
|
||||
Reference in new issue
Block a user