diff --git a/backend/src/admin/admin.controller.ts b/backend/src/admin/admin.controller.ts index d197e1e5..2de1352d 100644 --- a/backend/src/admin/admin.controller.ts +++ b/backend/src/admin/admin.controller.ts @@ -19,6 +19,8 @@ import { ApiQuery, } from '@nestjs/swagger'; +import { CreateUserDto, UpdateUserDto } from './dto/user.dto'; + @ApiTags('Admin - مدیریت سیستم') @ApiBearerAuth() @UseGuards(JwtAuthGuard) @@ -43,6 +45,17 @@ export class AdminController { return { success: true, ...result }; } + @Post('users') + @ApiOperation({ summary: 'ایجاد کاربر جدید توسط ادمین' }) + async createUser(@Body() dto: CreateUserDto) { + const user = await this.adminService.createUser(dto); + return { + success: true, + message: 'کاربر جدید با موفقیت ایجاد شد', + data: user, + }; + } + @Get('users/:id') @ApiOperation({ summary: 'جزئیات کاربر' }) async getUserDetails(@Param('id') id: string) { @@ -50,6 +63,30 @@ export class AdminController { return { success: true, data }; } + @Put('users/:id') + @ApiOperation({ summary: 'ویرایش مشخصات کامل کاربر' }) + async updateUser( + @Param('id') id: string, + @Body() dto: UpdateUserDto, + ) { + const user = await this.adminService.updateUser(id, dto); + return { + success: true, + message: 'اطلاعات کاربر با موفقیت ویرایش شد', + data: user, + }; + } + + @Delete('users/:id') + @ApiOperation({ summary: 'حذف کاربر و داده‌های مرتبط' }) + async deleteUser(@Param('id') id: string) { + await this.adminService.deleteUser(id); + return { + success: true, + message: 'کاربر با موفقیت از سیستم حذف شد', + }; + } + @Put('users/:id/role') @ApiOperation({ summary: 'تغییر نقش کاربر' }) async updateUserRole(@Param('id') id: string, @Body('role') role: string) { diff --git a/backend/src/admin/admin.service.ts b/backend/src/admin/admin.service.ts index d7fbcb10..de524293 100644 --- a/backend/src/admin/admin.service.ts +++ b/backend/src/admin/admin.service.ts @@ -1,7 +1,14 @@ -import { Injectable, HttpException, NotFoundException } from '@nestjs/common'; +import { + Injectable, + HttpException, + NotFoundException, + BadRequestException, +} from '@nestjs/common'; import { Prisma } from '@prisma/client'; import { PrismaService } from '../prisma/prisma.service'; import { RedisService } from '../redis/redis.service'; +import * as bcrypt from 'bcryptjs'; +import { CreateUserDto, UpdateUserDto } from './dto/user.dto'; export class PaginationQuery { page?: number | string; @@ -169,6 +176,88 @@ export class AdminService { return user; } + async createUser(dto: CreateUserDto) { + const existingMobile = await this.prisma.user.findUnique({ + where: { mobile: dto.mobile }, + }); + if (existingMobile) { + throw new BadRequestException('کاربری با این شماره موبایل قبلاً در سیستم ثبت شده است'); + } + + if (dto.email) { + const existingEmail = await this.prisma.user.findUnique({ + where: { email: dto.email }, + }); + if (existingEmail) { + throw new BadRequestException('کاربری با این آدرس ایمیل قبلاً در سیستم ثبت شده است'); + } + } + + const hashedPassword = dto.password ? await bcrypt.hash(dto.password, 10) : ''; + + return this.prisma.user.create({ + data: { + firstName: dto.firstName, + lastName: dto.lastName, + mobile: dto.mobile, + email: dto.email || null, + password: hashedPassword, + role: dto.role || 'User_PetOwner', + walletBalance: + dto.walletBalance !== undefined + ? new Prisma.Decimal(dto.walletBalance) + : new Prisma.Decimal(0), + }, + }); + } + + async updateUser(id: string, dto: UpdateUserDto) { + if (id === '12345678-1234-1234-1234-123456789012') { + throw new BadRequestException('امکان ویرایش حساب ادمین پیش‌فرض وجود ندارد'); + } + + const user = await this.prisma.user.findUnique({ where: { id } }); + if (!user) { + throw new NotFoundException(`کاربری با شناسه ${id} یافت نشد`); + } + + if (dto.mobile && dto.mobile !== user.mobile) { + const existingMobile = await this.prisma.user.findUnique({ + where: { mobile: dto.mobile }, + }); + if (existingMobile && existingMobile.id !== id) { + throw new BadRequestException('این شماره موبایل متعلق به کاربر دیگری است'); + } + } + + if (dto.email && dto.email !== user.email) { + const existingEmail = await this.prisma.user.findUnique({ + where: { email: dto.email }, + }); + if (existingEmail && existingEmail.id !== id) { + throw new BadRequestException('این آدرس ایمیل متعلق به کاربر دیگری است'); + } + } + + const updateData: Prisma.UserUpdateInput = {}; + if (dto.firstName !== undefined) updateData.firstName = dto.firstName; + if (dto.lastName !== undefined) updateData.lastName = dto.lastName; + if (dto.mobile !== undefined) updateData.mobile = dto.mobile; + if (dto.email !== undefined) updateData.email = dto.email || null; + if (dto.role !== undefined) updateData.role = dto.role; + if (dto.walletBalance !== undefined) { + updateData.walletBalance = new Prisma.Decimal(dto.walletBalance); + } + if (dto.password && dto.password.trim().length >= 6) { + updateData.password = await bcrypt.hash(dto.password, 10); + } + + return this.prisma.user.update({ + where: { id }, + data: updateData, + }); + } + async updateUserRole(id: string, role: string) { return this.prisma.user.update({ where: { id }, @@ -176,6 +265,29 @@ export class AdminService { }); } + async deleteUser(id: string) { + if (id === '12345678-1234-1234-1234-123456789012') { + throw new BadRequestException('امکان حذف حساب ادمین پیش‌فرض وجود ندارد'); + } + + const user = await this.prisma.user.findUnique({ where: { id } }); + if (!user) { + throw new NotFoundException(`کاربری با شناسه ${id} یافت نشد`); + } + + return this.prisma.$transaction(async (tx) => { + await tx.userAddress.deleteMany({ where: { userId: id } }); + await tx.walletTransaction.deleteMany({ where: { userId: id } }); + await tx.pet.deleteMany({ where: { userId: id } }); + await tx.prescription.deleteMany({ where: { userId: id } }); + await tx.paymentTransaction.deleteMany({ where: { userId: id } }); + await tx.partnerAccount.deleteMany({ where: { userId: id } }); + await tx.blog.deleteMany({ where: { authorId: id } }); + await tx.order.deleteMany({ where: { userId: id } }); + return tx.user.delete({ where: { id } }); + }); + } + async getProducts(query: PaginationQuery = {}) { try { const page = Number(query.page) || 1; diff --git a/backend/src/admin/dto/user.dto.ts b/backend/src/admin/dto/user.dto.ts new file mode 100644 index 00000000..6286fbb6 --- /dev/null +++ b/backend/src/admin/dto/user.dto.ts @@ -0,0 +1,78 @@ +import { IsNotEmpty, IsString, IsOptional, IsEmail, MinLength, IsNumber } from 'class-validator'; +import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; + +export class CreateUserDto { + @ApiProperty({ description: 'نام کاربر', example: 'علی' }) + @IsNotEmpty({ message: 'نام الزامی است' }) + @IsString() + firstName!: string; + + @ApiProperty({ description: 'نام خانوادگی کاربر', example: 'محمدی' }) + @IsNotEmpty({ message: 'نام خانوادگی الزامی است' }) + @IsString() + lastName!: string; + + @ApiProperty({ description: 'شماره موبایل', example: '09123456789' }) + @IsNotEmpty({ message: 'شماره موبایل الزامی است' }) + @IsString() + mobile!: string; + + @ApiPropertyOptional({ description: 'ایمیل کاربر', example: 'ali@example.com' }) + @IsOptional() + @IsEmail({}, { message: 'فرمت ایمیل نامعتبر است' }) + email?: string; + + @ApiPropertyOptional({ description: 'رمز عبور', example: 'Password123' }) + @IsOptional() + @IsString() + @MinLength(6, { message: 'رمز عبور باید حداقل ۶ کاراکتر باشد' }) + password?: string; + + @ApiPropertyOptional({ description: 'نقش کاربر', example: 'User_PetOwner' }) + @IsOptional() + @IsString() + role?: string; + + @ApiPropertyOptional({ description: 'موجودی اولیه کیف پول', example: 0 }) + @IsOptional() + @IsNumber({}, { message: 'موجودی کیف پول باید عدد باشد' }) + walletBalance?: number; +} + +export class UpdateUserDto { + @ApiPropertyOptional({ description: 'نام کاربر', example: 'علی' }) + @IsOptional() + @IsString() + firstName?: string; + + @ApiPropertyOptional({ description: 'نام خانوادگی کاربر', example: 'محمدی' }) + @IsOptional() + @IsString() + lastName?: string; + + @ApiPropertyOptional({ description: 'شماره موبایل', example: '09123456789' }) + @IsOptional() + @IsString() + mobile?: string; + + @ApiPropertyOptional({ description: 'ایمیل کاربر', example: 'ali@example.com' }) + @IsOptional() + @IsEmail({}, { message: 'فرمت ایمیل نامعتبر است' }) + email?: string; + + @ApiPropertyOptional({ description: 'رمز عبور جدید', example: 'NewPassword123' }) + @IsOptional() + @IsString() + @MinLength(6, { message: 'رمز عبور باید حداقل ۶ کاراکتر باشد' }) + password?: string; + + @ApiPropertyOptional({ description: 'نقش کاربر', example: 'User_PetOwner' }) + @IsOptional() + @IsString() + role?: string; + + @ApiPropertyOptional({ description: 'موجودی کیف پول', example: 500000 }) + @IsOptional() + @IsNumber({}, { message: 'موجودی کیف پول باید عدد باشد' }) + walletBalance?: number; +} diff --git a/frontend/admin-panel/src/pages/Users.tsx b/frontend/admin-panel/src/pages/Users.tsx index 964229d0..bd7963d2 100644 --- a/frontend/admin-panel/src/pages/Users.tsx +++ b/frontend/admin-panel/src/pages/Users.tsx @@ -1,5 +1,21 @@ import { useState, useEffect, useCallback } from 'react'; -import { Users as UsersIcon, Search, Edit3, Check, X, Eye, ShieldAlert, UserCheck, UserX } from 'lucide-react'; +import { + Users as UsersIcon, + Search, + Edit3, + Trash2, + Plus, + Check, + X, + Eye, + Wallet, + AlertTriangle, + Mail, + Phone, + Lock, + UserCheck, + Shield, +} from 'lucide-react'; import { toast } from 'react-hot-toast'; import api from '../services/api'; import Skeleton from '../components/ui/Skeleton'; @@ -16,7 +32,7 @@ export interface UserRecord { email?: string; role?: string; status?: string; - walletBalance?: number; + walletBalance?: number | string; createdAt?: string; addresses?: UserAddress[]; pets?: PetSummary[]; @@ -31,32 +47,64 @@ export default function Users() { const [search, setSearch] = useState(''); const [role, setRole] = useState(''); const [totalPages, setTotalPages] = useState(1); + const [totalCount, setTotalCount] = useState(0); - // Modals & Edit State + // Modals const [viewUser, setViewUser] = useState(null); const [editUser, setEditUser] = useState(null); + const [showCreateModal, setShowCreateModal] = useState(false); + const [userToDelete, setUserToDelete] = useState(null); + const [walletUser, setWalletUser] = useState(null); + + // Form States + const [createFormData, setCreateFormData] = useState({ + firstName: '', + lastName: '', + mobile: '', + email: '', + password: '', + role: 'User_PetOwner', + walletBalance: 0, + }); + const [editFormData, setEditFormData] = useState({ firstName: '', lastName: '', email: '', mobile: '', + password: '', role: 'User_PetOwner', - status: 'active' + walletBalance: 0, }); + + const [walletFormData, setWalletFormData] = useState<{ + amount: number; + type: 'deposit' | 'withdrawal' | 'refund'; + description: string; + }>({ + amount: 50000, + type: 'deposit', + description: '', + }); + const [isSaving, setIsSaving] = useState(false); + const [isDeleting, setIsDeleting] = useState(false); + const [isAdjustingWallet, setIsAdjustingWallet] = useState(false); const fetchUsers = useCallback(async () => { try { setIsLoading(true); const params = new URLSearchParams(); params.append('page', page.toString()); + params.append('limit', '10'); if (search) params.append('search', search); if (role) params.append('role', role); const response = await api.get(`/admin/users?${params.toString()}`); if (response.data?.success) { - setUsers(response.data.data); + setUsers(response.data.data || []); setTotalPages(response.data.meta?.lastPage || 1); + setTotalCount(response.data.meta?.total || 0); } } catch (err) { console.error('Failed to fetch users', err); @@ -68,11 +116,12 @@ export default function Users() { useEffect(() => { const delayDebounceFn = setTimeout(() => { fetchUsers(); - }, 500); + }, 400); return () => clearTimeout(delayDebounceFn); }, [fetchUsers]); + // Open Edit Modal const handleOpenEdit = (user: UserRecord) => { setEditUser(user); setEditFormData({ @@ -80,166 +129,306 @@ export default function Users() { lastName: user.lastName || '', email: user.email || '', mobile: user.mobile || '', + password: '', role: user.role || 'User_PetOwner', - status: user.status || 'active' + walletBalance: Number(user.walletBalance) || 0, }); }; - const handleSaveUser = async (e: React.FormEvent) => { + // Open Wallet Modal + const handleOpenWallet = (user: UserRecord) => { + setWalletUser(user); + setWalletFormData({ + amount: 50000, + type: 'deposit', + description: '', + }); + }; + + // Create User + const handleCreateUser = async (e: React.FormEvent) => { e.preventDefault(); - if (!editUser) return; + if (!createFormData.firstName.trim() || !createFormData.lastName.trim() || !createFormData.mobile.trim()) { + toast.error('لطفاً فیلدهای الزامی (نام، نام خانوادگی، شماره موبایل) را پر کنید'); + return; + } + try { setIsSaving(true); - await api.put(`/admin/users/${editUser.id}`, editFormData); - toast.success('اطلاعات کاربر با موفقیت بروزرسانی شد'); - setEditUser(null); - fetchUsers(); - } catch (err) { - console.error('Failed to update user', err); - toast.error('خطا در بروزرسانی اطلاعات کاربر'); + const payload: Record = { + firstName: createFormData.firstName.trim(), + lastName: createFormData.lastName.trim(), + mobile: createFormData.mobile.trim(), + role: createFormData.role, + walletBalance: Number(createFormData.walletBalance) || 0, + }; + if (createFormData.email.trim()) payload.email = createFormData.email.trim(); + if (createFormData.password.trim()) payload.password = createFormData.password.trim(); + + const res = await api.post('/admin/users', payload); + if (res.data?.success) { + toast.success('کاربر جدید با موفقیت ایجاد شد'); + setShowCreateModal(false); + setCreateFormData({ + firstName: '', + lastName: '', + mobile: '', + email: '', + password: '', + role: 'User_PetOwner', + walletBalance: 0, + }); + fetchUsers(); + } + } catch (err: unknown) { + console.error('Failed to create user', err); } finally { setIsSaving(false); } }; - const toggleUserStatus = async (user: UserRecord) => { - const newStatus = user.status === 'active' ? 'blocked' : 'active'; + // Save Edit User + const handleSaveUser = async (e: React.FormEvent) => { + e.preventDefault(); + if (!editUser) return; try { - await api.put(`/admin/users/${user.id}`, { status: newStatus }); - toast.success(`وضعیت کاربر به ${newStatus === 'active' ? 'فعال' : 'مسدود'} تغییر یافت`); + setIsSaving(true); + const payload: Record = { + firstName: editFormData.firstName.trim(), + lastName: editFormData.lastName.trim(), + mobile: editFormData.mobile.trim(), + role: editFormData.role, + walletBalance: Number(editFormData.walletBalance) || 0, + }; + if (editFormData.email.trim()) payload.email = editFormData.email.trim(); + if (editFormData.password.trim()) payload.password = editFormData.password.trim(); + + await api.put(`/admin/users/${editUser.id}`, payload); + toast.success('اطلاعات کاربر با موفقیت بروزرسانی شد'); + setEditUser(null); fetchUsers(); - } catch (err) { - console.error('Status change failed', err); - toast.error('خطا در تغییر وضعیت کاربر'); + } catch (err: unknown) { + console.error('Failed to update user', err); + } finally { + setIsSaving(false); + } + }; + + // Delete User + const handleDeleteUser = async () => { + if (!userToDelete) return; + try { + setIsDeleting(true); + await api.delete(`/admin/users/${userToDelete.id}`); + toast.success('کاربر و تمامی داده‌های مربوطه با موفقیت حذف شدند'); + setUserToDelete(null); + fetchUsers(); + } catch (err: unknown) { + console.error('Failed to delete user', err); + } finally { + setIsDeleting(false); + } + }; + + // Adjust Wallet + const handleAdjustWallet = async (e: React.FormEvent) => { + e.preventDefault(); + if (!walletUser) return; + try { + setIsAdjustingWallet(true); + await api.post(`/admin/users/${walletUser.id}/wallet-adjust`, { + amount: Number(walletFormData.amount), + type: walletFormData.type, + description: walletFormData.description || undefined, + }); + toast.success('موجودی کیف پول با موفقیت تغییر کرد'); + setWalletUser(null); + fetchUsers(); + } catch (err: unknown) { + console.error('Failed to adjust wallet', err); + } finally { + setIsAdjustingWallet(false); } }; return ( -
+
+ {/* Header */}

مدیریت کامل کاربران

-

مشاهده تمامی اطلاعات، تغییر نقش، ویرایش پروفایل و مدیریت دسترسی

+

+ افزودن، ویرایش، حذف، تغییر نقش و مدیریت مستقیم کیف پول ({totalCount.toLocaleString('fa-IR')} کاربر ثبت‌شده) +

+ + +
{ setSearch(e.target.value); setPage(1); }} + onChange={(e) => { + setSearch(e.target.value); + setPage(1); + }} />
+ {/* Users Table */}
- + + - {isLoading ? ( - Array.from({ length: 4 }).map((_, i) => ( + Array.from({ length: 5 }).map((_, i) => ( - - + + )) + ) : users.length === 0 ? ( + + + ) : ( - users.map((user) => ( - - - - - - - - + + + + - - )) + {user.role === 'User_Wholesale' + ? 'خریدار عمده' + : user.role?.includes('B2B') + ? 'همکار (B2B)' + : user.role?.toLowerCase().includes('admin') + ? 'مدیر سیستم' + : 'مشتری عادی'} + + + + + + + ); + }) )}
نام کاربر / کلینیکنام و نام خانوادگی شماره موبایل ایمیل نوع حسابموجودی کیف پول تاریخ عضویتوضعیت عملیات
+ هیچ کاربری با این مشخصات یافت نشد. +
{user.firstName || user.lastName ? `${user.firstName || ''} ${user.lastName || ''}`.trim() : 'بدون نام'}{user.mobile || '---'}{user.email || '---'} - - {user.role === 'User_Wholesale' ? 'خریدار عمده' : - user.role?.includes('B2B') ? 'همکار (B2B)' : - user.role === 'ADMIN' ? 'مدیر سیستم' : 'مشتری عادی'} - - - {user.createdAt ? new Date(user.createdAt).toLocaleDateString('fa-IR') : '---'} - - {user.status === 'blocked' ? ( - - - مسدود شده - - ) : ( - - - فعال - - )} - -
- - -
+
+ {fullName.charAt(0)} +
+
+
{fullName}
+ {isMainAdmin && ( + حساب اصلی مدیریت + )} +
+
+ {user.mobile || '---'} + + {user.email || '---'} + + - - - -
+ {balance.toLocaleString('fa-IR')} تومان + + {user.createdAt ? new Date(user.createdAt).toLocaleDateString('fa-IR') : '---'} + +
+ + + + {!isMainAdmin && ( + + )} +
+
@@ -247,16 +436,455 @@ export default function Users() {
- {/* View User Modal */} + {/* CREATE USER MODAL */} + {showCreateModal && ( +
+
+
+

+ + افزودن کاربر جدید +

+ +
+ +
+
+ + setCreateFormData({ ...createFormData, firstName: e.target.value })} + className="w-full px-3 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" + /> +
+ +
+ + setCreateFormData({ ...createFormData, lastName: e.target.value })} + className="w-full px-3 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" + /> +
+ +
+ +
+ + setCreateFormData({ ...createFormData, mobile: e.target.value })} + className="w-full pl-3 pr-9 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono text-left" + dir="ltr" + /> +
+
+ +
+ +
+ + setCreateFormData({ ...createFormData, email: e.target.value })} + className="w-full pl-3 pr-9 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono text-left" + dir="ltr" + /> +
+
+ +
+ +
+ + setCreateFormData({ ...createFormData, password: e.target.value })} + className="w-full pl-3 pr-9 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none text-left" + dir="ltr" + /> +
+
+ +
+ + +
+ +
+ + setCreateFormData({ ...createFormData, walletBalance: Number(e.target.value) })} + className="w-full px-3 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono" + /> +
+
+ +
+ + +
+
+
+ )} + + {/* EDIT USER MODAL */} + {editUser && ( +
+
+
+

+ + ویرایش اطلاعات کاربر +

+ +
+ +
+
+ + setEditFormData({ ...editFormData, firstName: e.target.value })} + className="w-full px-3 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" + /> +
+ +
+ + setEditFormData({ ...editFormData, lastName: e.target.value })} + className="w-full px-3 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" + /> +
+ +
+ + setEditFormData({ ...editFormData, mobile: e.target.value })} + className="w-full px-3 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono text-left" + dir="ltr" + /> +
+ +
+ + setEditFormData({ ...editFormData, email: e.target.value })} + className="w-full px-3 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono text-left" + dir="ltr" + /> +
+ +
+ + setEditFormData({ ...editFormData, password: e.target.value })} + className="w-full px-3 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none text-left" + dir="ltr" + /> +
+ +
+ + +
+ +
+ + setEditFormData({ ...editFormData, walletBalance: Number(e.target.value) })} + className="w-full px-3 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono" + /> +
+
+ +
+ + +
+
+
+ )} + + {/* WALLET ADJUST MODAL */} + {walletUser && ( +
+
+
+

+ + مدیریت کیف پول کاربر +

+ +
+ +
+
+ {walletUser.firstName} {walletUser.lastName} ({walletUser.mobile}) +
+
+ موجودی فعلی:{' '} + + {(Number(walletUser.walletBalance) || 0).toLocaleString('fa-IR')} تومان + +
+
+ +
+
+ +
+ + + +
+
+ +
+ + setWalletFormData({ ...walletFormData, amount: Number(e.target.value) })} + className="w-full px-3 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono font-bold text-sm" + /> +
+ +
+ + setWalletFormData({ ...walletFormData, description: e.target.value })} + className="w-full px-3 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" + /> +
+
+ +
+ + +
+
+
+ )} + + {/* DELETE CONFIRMATION MODAL */} + {userToDelete && ( +
+
+
+
+ +
+
+

تایید حذف کاربر

+

این عملیات غیرقابل بازگشت است

+
+
+ +

+ آیا از حذف کامل کاربر{' '} + + {userToDelete.firstName} {userToDelete.lastName} ({userToDelete.mobile}) + {' '} + اطمینان دارید؟ تمام سوابق آدرس‌ها، پت‌ها و تراکنش‌های مربوطه نیز پاک خواهند شد. +

+ +
+ + +
+
+
+ )} + + {/* VIEW USER DETAILS MODAL */} {viewUser && (
-
+

مشاهده جزئیات پروفایل کاربر

-
@@ -265,7 +893,9 @@ export default function Users() {
نام و نام خانوادگی: - {viewUser.firstName} {viewUser.lastName} + + {viewUser.firstName} {viewUser.lastName} +
نوع نقش: @@ -273,18 +903,22 @@ export default function Users() {
موبایل: - {viewUser.mobile || '---'} + + {viewUser.mobile || '---'} +
ایمیل: - {viewUser.email || '---'} + + {viewUser.email || '---'} +
موجودی کیف پول کاربر: - {(viewUser.walletBalance || 0).toLocaleString('fa-IR')} تومان + {(Number(viewUser.walletBalance) || 0).toLocaleString('fa-IR')} تومان
@@ -294,8 +928,12 @@ export default function Users() {
{viewUser.addresses.map((a: UserAddress, idx: number) => (
-

{a.title} - {a.receptorName}

-

{a.province}، {a.city}، {a.detail}

+

+ {a.title} - {a.receptorName} +

+

+ {a.province}، {a.city}، {a.detail} +

))}
@@ -308,7 +946,7 @@ export default function Users() {
@@ -316,107 +954,6 @@ export default function Users() {
)} - - {/* Edit User Modal */} - {editUser && ( -
-
-
-

- - ویرایش اطلاعات کاربر -

- -
- -
-
- - 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" - /> -
-
- - 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" - /> -
-
- - 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" - /> -
-
- - 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" - /> -
-
- - -
-
- - -
-
- -
- - -
-
-
- )}
); } -