feat: response in mobile and accouting
This commit is contained in:
@@ -11,6 +11,7 @@ import UserEditForm from '@/components/admin/users/UserEditForm';
|
||||
import PackageSelector from '@/components/admin/users/PackageSelector';
|
||||
import PageHeader from '@/components/admin/PageHeader';
|
||||
import StepIndicator from '@/components/admin/StepIndicator';
|
||||
import ConfirmDialog from '@/components/admin/ConfirmDialog';
|
||||
import { showToast } from '@/components/Toast';
|
||||
import { User, Product, UpdateUserProfileData } from '@/types/user';
|
||||
import { PackageName } from '@/types/package';
|
||||
@@ -159,7 +160,9 @@ export default function UsersPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteUser = async () => {
|
||||
const [isDeleteConfirmOpen, setIsDeleteConfirmOpen] = useState(false);
|
||||
|
||||
const handleDeleteUser = () => {
|
||||
if (!user) return;
|
||||
const identifier = user.email || user.mobile;
|
||||
if (!identifier) {
|
||||
@@ -167,9 +170,13 @@ export default function UsersPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm('آیا از حذف این کاربر اطمینان دارید؟ این عملیات قابل بازگشت نیست.')) {
|
||||
return;
|
||||
}
|
||||
setIsDeleteConfirmOpen(true);
|
||||
};
|
||||
|
||||
const confirmDeleteUser = async () => {
|
||||
if (!user) return;
|
||||
const identifier = user.email || user.mobile;
|
||||
if (!identifier) return;
|
||||
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
@@ -178,6 +185,7 @@ export default function UsersPage() {
|
||||
await usersApi.deleteUser(identifier, token!);
|
||||
showToast('success', 'کاربر با موفقیت حذف شد');
|
||||
setUser(null);
|
||||
setIsDeleteConfirmOpen(false);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'خطا در حذف کاربر');
|
||||
} finally {
|
||||
@@ -324,6 +332,16 @@ export default function UsersPage() {
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
)}
|
||||
|
||||
<ConfirmDialog
|
||||
open={isDeleteConfirmOpen && !!user}
|
||||
title="حذف کاربر"
|
||||
message="آیا از حذف این کاربر اطمینان دارید؟ این عملیات قابل بازگشت نیست."
|
||||
confirmLabel="حذف کاربر"
|
||||
isLoading={isLoading}
|
||||
onConfirm={confirmDeleteUser}
|
||||
onCancel={() => setIsDeleteConfirmOpen(false)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user