feat(admin): complete full user management page with detail modal and profile edit [TASK-25.3]
This commit is contained in:
1 parent
81a2837c04
commit
070c68e4c9
2 files changed
+294
-87
No files matched your search
+1
-1
@@ -182,7 +182,7 @@
|
||||
## 📍 بخش ۲۵: بازبینی، اصلاح خطاها و توسعه قابلیتهای درخواستی جدید (Batch Tasks 25.1 - 25.14)
|
||||
- [ ] **TASK-25.1 [Frontend Header Dropdown]:** بازگرداندن Dropdown سریع اطلاعات کاربری و لیست پتها در هدر اصلی فرانتاند (Header Profile Dropdown with Pets List).
|
||||
- [ ] **TASK-25.2 [Admin Panel Topbar]:** اصلاح کارکرد دکمه «خروج از حساب» در Dropdown پروفایل ادمین پنل (Fix Logout Handler in Admin Topbar).
|
||||
- [ ] **TASK-25.3 [Admin Panel Users Page]:** تکمیل مدیریت کامل کاربران (مشاهده تمامی فیلدها، ویرایش اطلاعات کاربر، تغییر نقش، مسدودی و...).
|
||||
- [x] **TASK-25.3 [Admin Panel Users Page]:** تکمیل مدیریت کامل کاربران (مشاهده تمامی فیلدها، ویرایش اطلاعات کاربر، تغییر نقش، مسدودی و...).
|
||||
- [ ] **TASK-25.4 [Health Calculator UI]:** اصلاح فیلدهای گام دوم پایش فیزیکی در چکآپ سلامت جهت امکان تایپ مستقیم عددی علاوه بر دکمههای کم و زیاد.
|
||||
- [ ] **TASK-25.5 [Health Supplement Tracking Logic]:** پیادهسازی کامل منطق و الگوریتم پایش موجودی مکملها براساس تاریخ مصرف و سفارشات واقعی پت.
|
||||
- [ ] **TASK-25.6 [Backend Exception & Error Handling System]:** اصلاح منطق پاسخدهی خطاهای بهینهشده به تفکیک پارامترها و جلوگیری از نمایش پیامهای کلی غیرمنتظره و توستهای تکراری.
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { Users as UsersIcon, CheckCircle, Search, Edit3, Check, X } from 'lucide-react';
|
||||
import { Users as UsersIcon, CheckCircle, Search, Edit3, Check, X, Eye, ShieldAlert, UserCheck, UserX, Mail, Phone, Calendar, Shield } from 'lucide-react';
|
||||
import { toast } from 'react-hot-toast';
|
||||
import api from '../services/api';
|
||||
import Skeleton from '../components/ui/Skeleton';
|
||||
import Spinner from '../components/ui/Spinner';
|
||||
import Pagination from '../components/ui/Pagination';
|
||||
|
||||
export interface UserRecord {
|
||||
[x: string]: string;
|
||||
id: string;
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
mobile?: string;
|
||||
email?: string;
|
||||
role?: string;
|
||||
status?: string;
|
||||
walletBalance?: number;
|
||||
createdAt?: string;
|
||||
addresses?: any[];
|
||||
pets?: any[];
|
||||
}
|
||||
|
||||
export default function Users() {
|
||||
@@ -26,9 +30,17 @@ export default function Users() {
|
||||
const [role, setRole] = useState('');
|
||||
const [totalPages, setTotalPages] = useState(1);
|
||||
|
||||
// Edit State
|
||||
const [editingId, setEditingId] = useState<string | null>(null);
|
||||
const [editRole, setEditRole] = useState<string>('');
|
||||
// Modals & Edit State
|
||||
const [viewUser, setViewUser] = useState<UserRecord | null>(null);
|
||||
const [editUser, setEditUser] = useState<UserRecord | null>(null);
|
||||
const [editFormData, setEditFormData] = useState({
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
email: '',
|
||||
mobile: '',
|
||||
role: 'User_PetOwner',
|
||||
status: 'active'
|
||||
});
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
|
||||
const fetchUsers = useCallback(async () => {
|
||||
@@ -59,66 +71,91 @@ export default function Users() {
|
||||
return () => clearTimeout(delayDebounceFn);
|
||||
}, [fetchUsers]);
|
||||
|
||||
const handleEditClick = (user: UserRecord) => {
|
||||
setEditingId(user.id);
|
||||
setEditRole(user.role || 'User_PetOwner');
|
||||
const handleOpenEdit = (user: UserRecord) => {
|
||||
setEditUser(user);
|
||||
setEditFormData({
|
||||
firstName: user.firstName || '',
|
||||
lastName: user.lastName || '',
|
||||
email: user.email || '',
|
||||
mobile: user.mobile || '',
|
||||
role: user.role || 'User_PetOwner',
|
||||
status: user.status || 'active'
|
||||
});
|
||||
};
|
||||
|
||||
const handleSaveEdit = async (id: string) => {
|
||||
const handleSaveUser = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (!editUser) return;
|
||||
try {
|
||||
setIsSaving(true);
|
||||
await api.put(`/admin/users/${id}/role`, { role: editRole });
|
||||
setEditingId(null);
|
||||
await api.put(`/admin/users/${editUser.id}`, editFormData);
|
||||
toast.success('اطلاعات کاربر با موفقیت بروزرسانی شد');
|
||||
setEditUser(null);
|
||||
fetchUsers();
|
||||
} catch (err) {
|
||||
console.error('Failed to update user role', err);
|
||||
console.error('Failed to update user', err);
|
||||
toast.error('خطا در بروزرسانی اطلاعات کاربر');
|
||||
} finally {
|
||||
setIsSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
const toggleUserStatus = async (user: UserRecord) => {
|
||||
const newStatus = user.status === 'active' ? 'blocked' : 'active';
|
||||
try {
|
||||
await api.put(`/admin/users/${user.id}`, { status: newStatus });
|
||||
toast.success(`وضعیت کاربر به ${newStatus === 'active' ? 'فعال' : 'مسدود'} تغییر یافت`);
|
||||
fetchUsers();
|
||||
} catch (err) {
|
||||
console.error('Status change failed', err);
|
||||
toast.error('خطا در تغییر وضعیت کاربر');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
||||
<div>
|
||||
<h2 className="text-2xl font-black text-gray-900 flex items-center gap-2">
|
||||
<UsersIcon className="w-6 h-6 text-purple-600" />
|
||||
مدیریت کاربران
|
||||
مدیریت کامل کاربران
|
||||
</h2>
|
||||
<p className="text-gray-500 font-medium mt-1">مشاهده و تایید حسابهای کاربری و کلینیکها</p>
|
||||
<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
|
||||
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"
|
||||
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 text-xs"
|
||||
value={role}
|
||||
onChange={(e) => { setRole(e.target.value); setPage(1); }}
|
||||
>
|
||||
<option value="">همه نقشها</option>
|
||||
<option value="B2B">همکار (B2B)</option>
|
||||
<option value="User_PetOwner">مشتری عادی</option>
|
||||
<option value="User_Wholesale">خریدار عمده</option>
|
||||
<option value="User_B2B">همکار (B2B)</option>
|
||||
<option value="ADMIN">ادمین</option>
|
||||
</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" />
|
||||
<Search className="w-4 h-4 text-gray-400 absolute right-3 top-1/2 -translate-y-1/2" />
|
||||
<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"
|
||||
placeholder="جستجو (نام، ایمیل، موبایل)..."
|
||||
className="pl-4 pr-9 py-2 border border-gray-200 rounded-xl outline-none focus:ring-2 focus:ring-purple-500 w-full font-medium text-xs"
|
||||
dir="rtl"
|
||||
value={search}
|
||||
onChange={(e) => { setSearch(e.target.value); setPage(1); }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-right font-vazir">
|
||||
<thead className="bg-gray-50 text-gray-500 text-sm border-b border-gray-200">
|
||||
<table className="w-full text-right font-vazir text-xs">
|
||||
<thead className="bg-gray-50 text-gray-500 border-b border-gray-200">
|
||||
<tr>
|
||||
<th className="py-4 px-6 font-bold">نام کاربر / کلینیک</th>
|
||||
<th className="py-4 px-6 font-bold">شماره موبایل</th>
|
||||
<th className="py-4 px-6 font-bold">ایمیل</th>
|
||||
<th className="py-4 px-6 font-bold">نوع حساب</th>
|
||||
<th className="py-4 px-6 font-bold">تاریخ عضویت</th>
|
||||
@@ -131,83 +168,253 @@ export default function Users() {
|
||||
Array.from({ length: 4 }).map((_, i) => (
|
||||
<tr key={i}>
|
||||
<td className="py-4 px-6"><Skeleton className="h-6 w-32" /></td>
|
||||
<td className="py-4 px-6"><Skeleton className="h-6 w-28" /></td>
|
||||
<td className="py-4 px-6"><Skeleton className="h-6 w-40" /></td>
|
||||
<td className="py-4 px-6"><Skeleton className="h-6 w-24" /></td>
|
||||
<td className="py-4 px-6"><Skeleton className="h-6 w-20" /></td>
|
||||
<td className="py-4 px-6"><Skeleton className="h-6 w-24" /></td>
|
||||
<td className="py-4 px-6"><Skeleton className="h-8 w-20 mx-auto" /></td>
|
||||
<td className="py-4 px-6"><Skeleton className="h-8 w-24 mx-auto" /></td>
|
||||
</tr>
|
||||
))
|
||||
) : (
|
||||
users.map((user) => {
|
||||
const isEditing = editingId === user.id;
|
||||
return (
|
||||
<tr key={user.id} className="hover:bg-gray-50/50 transition-colors">
|
||||
<td className="py-4 px-6 font-bold text-gray-900">{user.firstName} {user.lastName}</td>
|
||||
<td className="py-4 px-6 text-gray-500" dir="ltr">{user.email}</td>
|
||||
<td className="py-4 px-6">
|
||||
{isEditing ? (
|
||||
<select
|
||||
className="border border-purple-300 rounded p-1 text-xs font-bold"
|
||||
value={editRole}
|
||||
onChange={(e) => setEditRole(e.target.value)}
|
||||
>
|
||||
<option value="User_PetOwner">مشتری عادی</option>
|
||||
<option value="User_Wholesale">خریدار عمده (تاییدشده)</option>
|
||||
<option value="User_B2B">همکار (B2B)</option>
|
||||
<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'
|
||||
}`}>
|
||||
{user.role === 'User_Wholesale' ? 'خریدار عمده' :
|
||||
user.role?.includes('B2B') ? 'همکار (B2B)' :
|
||||
(user.role === 'ADMIN' ? 'مدیر سیستم' : 'مشتری عادی')}
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="py-4 px-6 text-gray-500 text-sm font-medium">{new Date(user.createdAt).toLocaleDateString('fa-IR')}</td>
|
||||
<td className="py-4 px-6">
|
||||
{user.status === 'active' ? (
|
||||
<span className="flex items-center gap-1.5 text-green-600 font-bold text-sm">
|
||||
<CheckCircle className="w-4 h-4" />
|
||||
تایید شده
|
||||
</span>
|
||||
) : (
|
||||
<span className="flex items-center gap-1.5 text-orange-500 font-bold text-sm">
|
||||
<div className="w-2 h-2 rounded-full bg-orange-500"></div>
|
||||
در انتظار تایید
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="py-4 px-6 text-center">
|
||||
{isEditing ? (
|
||||
<div className="flex justify-center gap-2">
|
||||
<button onClick={() => handleSaveEdit(user.id)} className="text-green-600 hover:bg-green-50 p-1.5 rounded-lg transition-colors" disabled={isSaving}>
|
||||
{isSaving ? <Spinner size="sm" /> : <Check className="w-5 h-5" />}
|
||||
</button>
|
||||
<button onClick={() => setEditingId(null)} className="text-gray-500 hover:bg-gray-50 p-1.5 rounded-lg transition-colors" disabled={isSaving}>
|
||||
<X className="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex justify-center gap-2">
|
||||
<button onClick={() => handleEditClick(user)} className="text-blue-600 hover:bg-blue-50 p-1.5 rounded-lg transition-colors" title="ویرایش نقش">
|
||||
<Edit3 className="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})
|
||||
users.map((user) => (
|
||||
<tr key={user.id} className="hover:bg-gray-50/50 transition-colors">
|
||||
<td className="py-4 px-6 font-bold text-gray-900">{user.firstName || user.lastName ? `${user.firstName || ''} ${user.lastName || ''}`.trim() : 'بدون نام'}</td>
|
||||
<td className="py-4 px-6 font-mono text-gray-700" dir="ltr">{user.mobile || '---'}</td>
|
||||
<td className="py-4 px-6 text-gray-500 font-mono" dir="ltr">{user.email || '---'}</td>
|
||||
<td className="py-4 px-6">
|
||||
<span className={`px-3 py-1 rounded-full text-[11px] font-bold ${
|
||||
user.role === 'User_Wholesale' ? 'bg-amber-100 text-amber-800' :
|
||||
user.role?.includes('B2B') ? 'bg-blue-100 text-blue-700' :
|
||||
user.role === 'ADMIN' ? 'bg-purple-100 text-purple-700' : 'bg-gray-100 text-gray-700'
|
||||
}`}>
|
||||
{user.role === 'User_Wholesale' ? 'خریدار عمده' :
|
||||
user.role?.includes('B2B') ? 'همکار (B2B)' :
|
||||
user.role === 'ADMIN' ? 'مدیر سیستم' : 'مشتری عادی'}
|
||||
</span>
|
||||
</td>
|
||||
<td className="py-4 px-6 text-gray-500 text-xs font-medium">
|
||||
{user.createdAt ? new Date(user.createdAt).toLocaleDateString('fa-IR') : '---'}
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
{user.status === 'blocked' ? (
|
||||
<span className="inline-flex items-center gap-1 text-red-600 font-bold bg-red-50 px-2.5 py-1 rounded-full border border-red-100">
|
||||
<UserX className="w-3.5 h-3.5" />
|
||||
مسدود شده
|
||||
</span>
|
||||
) : (
|
||||
<span className="inline-flex items-center gap-1 text-green-600 font-bold bg-green-50 px-2.5 py-1 rounded-full border border-green-100">
|
||||
<UserCheck className="w-3.5 h-3.5" />
|
||||
فعال
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="py-4 px-6 text-center">
|
||||
<div className="flex justify-center items-center gap-1.5">
|
||||
<button
|
||||
onClick={() => setViewUser(user)}
|
||||
className="p-1.5 text-gray-500 hover:text-purple-600 hover:bg-purple-50 rounded-lg transition-colors"
|
||||
title="مشاهده جزئیات کامل"
|
||||
>
|
||||
<Eye className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleOpenEdit(user)}
|
||||
className="p-1.5 text-blue-600 hover:bg-blue-50 rounded-lg transition-colors"
|
||||
title="ویرایش کاربر"
|
||||
>
|
||||
<Edit3 className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => toggleUserStatus(user)}
|
||||
className={`p-1.5 rounded-lg transition-colors ${
|
||||
user.status === 'blocked' ? 'text-green-600 hover:bg-green-50' : 'text-red-500 hover:bg-red-50'
|
||||
}`}
|
||||
title={user.status === 'blocked' ? 'رفع مسدودی' : 'مسدود کردن'}
|
||||
>
|
||||
<ShieldAlert className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<Pagination currentPage={page} totalPages={totalPages} onPageChange={setPage} />
|
||||
</div>
|
||||
|
||||
{/* View User Modal */}
|
||||
{viewUser && (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-gray-900/60 backdrop-blur-xs">
|
||||
<div className="bg-white rounded-2xl w-full max-w-lg shadow-2xl p-6 space-y-6 font-vazir animate-in fade-in zoom-in duration-150">
|
||||
<div className="flex items-center justify-between border-b border-gray-100 pb-4">
|
||||
<h3 className="text-lg font-bold text-gray-900 flex items-center gap-2">
|
||||
<UsersIcon className="w-5 h-5 text-purple-600" />
|
||||
مشاهده جزئیات پروفایل کاربر
|
||||
</h3>
|
||||
<button onClick={() => setViewUser(null)} className="text-gray-400 hover:text-red-500 transition-colors">
|
||||
<X className="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4 text-xs">
|
||||
<div className="grid grid-cols-2 gap-4 bg-gray-50 p-4 rounded-xl border border-gray-100">
|
||||
<div>
|
||||
<span className="text-gray-400 font-bold block mb-1">نام و نام خانوادگی:</span>
|
||||
<span className="font-bold text-gray-900 text-sm">{viewUser.firstName} {viewUser.lastName}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-400 font-bold block mb-1">نوع نقش:</span>
|
||||
<span className="font-bold text-purple-700">{viewUser.role}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-400 font-bold block mb-1">موبایل:</span>
|
||||
<span className="font-mono text-gray-800" dir="ltr">{viewUser.mobile || '---'}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-400 font-bold block mb-1">ایمیل:</span>
|
||||
<span className="font-mono text-gray-800" dir="ltr">{viewUser.email || '---'}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-purple-50/60 p-4 rounded-xl border border-purple-100 flex items-center justify-between">
|
||||
<span className="font-bold text-purple-900">موجودی کیف پول کاربر:</span>
|
||||
<span className="font-mono font-black text-purple-700 text-base">
|
||||
{(viewUser.walletBalance || 0).toLocaleString('fa-IR')} تومان
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4 className="font-bold text-gray-900 mb-2">آدرسهای ثبتشده ({viewUser.addresses?.length || 0})</h4>
|
||||
{viewUser.addresses && viewUser.addresses.length > 0 ? (
|
||||
<div className="space-y-2 max-h-32 overflow-y-auto">
|
||||
{viewUser.addresses.map((a: any, idx: number) => (
|
||||
<div key={idx} className="p-2.5 bg-gray-50 rounded-lg border border-gray-200/60">
|
||||
<p className="font-bold text-gray-800">{a.title} - {a.receptorName}</p>
|
||||
<p className="text-gray-500 mt-0.5">{a.province}، {a.city}، {a.detail}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-gray-400 text-center py-2 bg-gray-50 rounded-lg">هیچ آدرسی ثبت نشده است.</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="pt-4 border-t border-gray-100 flex justify-end">
|
||||
<button
|
||||
onClick={() => setViewUser(null)}
|
||||
className="px-5 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 font-bold rounded-xl transition-colors text-xs"
|
||||
>
|
||||
بستن پنجره
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Edit User Modal */}
|
||||
{editUser && (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-gray-900/60 backdrop-blur-xs">
|
||||
<form onSubmit={handleSaveUser} className="bg-white rounded-2xl w-full max-w-lg shadow-2xl p-6 space-y-6 font-vazir animate-in fade-in zoom-in duration-150">
|
||||
<div className="flex items-center justify-between border-b border-gray-100 pb-4">
|
||||
<h3 className="text-lg font-bold text-gray-900 flex items-center gap-2">
|
||||
<Edit3 className="w-5 h-5 text-blue-600" />
|
||||
ویرایش اطلاعات کاربر
|
||||
</h3>
|
||||
<button type="button" onClick={() => setEditUser(null)} className="text-gray-400 hover:text-red-500 transition-colors">
|
||||
<X className="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4 text-xs">
|
||||
<div>
|
||||
<label className="block text-gray-700 font-bold mb-1">نام</label>
|
||||
<input
|
||||
type="text"
|
||||
value={editFormData.firstName}
|
||||
onChange={(e) => setEditFormData({ ...editFormData, firstName: e.target.value })}
|
||||
className="w-full px-3 py-2 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-gray-700 font-bold mb-1">نام خانوادگی</label>
|
||||
<input
|
||||
type="text"
|
||||
value={editFormData.lastName}
|
||||
onChange={(e) => setEditFormData({ ...editFormData, lastName: e.target.value })}
|
||||
className="w-full px-3 py-2 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-gray-700 font-bold mb-1">شماره موبایل</label>
|
||||
<input
|
||||
type="text"
|
||||
value={editFormData.mobile}
|
||||
onChange={(e) => setEditFormData({ ...editFormData, mobile: e.target.value })}
|
||||
className="w-full px-3 py-2 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono"
|
||||
dir="ltr"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-gray-700 font-bold mb-1">ایمیل</label>
|
||||
<input
|
||||
type="email"
|
||||
value={editFormData.email}
|
||||
onChange={(e) => setEditFormData({ ...editFormData, email: e.target.value })}
|
||||
className="w-full px-3 py-2 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono"
|
||||
dir="ltr"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-gray-700 font-bold mb-1">نقش دسترسی</label>
|
||||
<select
|
||||
value={editFormData.role}
|
||||
onChange={(e) => setEditFormData({ ...editFormData, role: e.target.value })}
|
||||
className="w-full px-3 py-2 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-bold"
|
||||
>
|
||||
<option value="User_PetOwner">مشتری عادی</option>
|
||||
<option value="User_Wholesale">خریدار عمده (تاییدشده)</option>
|
||||
<option value="User_B2B">همکار (B2B)</option>
|
||||
<option value="ADMIN">ادمین ارشد</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-gray-700 font-bold mb-1">وضعیت حساب</label>
|
||||
<select
|
||||
value={editFormData.status}
|
||||
onChange={(e) => setEditFormData({ ...editFormData, status: e.target.value })}
|
||||
className="w-full px-3 py-2 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-bold"
|
||||
>
|
||||
<option value="active">فعال</option>
|
||||
<option value="blocked">مسدود شده</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="pt-4 border-t border-gray-100 flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setEditUser(null)}
|
||||
className="px-5 py-2.5 bg-gray-100 hover:bg-gray-200 text-gray-700 font-bold rounded-xl transition-colors text-xs"
|
||||
>
|
||||
انصراف
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isSaving}
|
||||
className="px-6 py-2.5 bg-purple-600 hover:bg-purple-700 text-white font-bold rounded-xl transition-colors text-xs flex items-center gap-2"
|
||||
>
|
||||
{isSaving ? <Spinner size="sm" /> : <Check className="w-4 h-4" />}
|
||||
ذخیره تغییرات
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user