Просмотр исходного кода

♻️ refactor(admin): update modal usage in AuditButtons component

- replace Modal static method with app.modal instance for better context management
- rename actionType variable to okType for clearer meaning
yourname 8 месяцев назад
Родитель
Сommit
b3d35bf10e
1 измененных файлов с 9 добавлено и 8 удалено
  1. 9 8
      src/client/admin/components/AuditButtons.tsx

+ 9 - 8
src/client/admin/components/AuditButtons.tsx

@@ -1,5 +1,5 @@
 import React from 'react';
-import { Button, Space, message, Modal } from 'antd';
+import { Button, Space, message, App } from 'antd';
 import { useMutation, useQueryClient } from '@tanstack/react-query';
 import { clientClient } from '@/client/api';
 import type { InferResponseType } from 'hono/client';
@@ -12,11 +12,12 @@ interface AuditButtonsProps {
   onSuccess?: () => void;
 }
 
-const AuditButtons: React.FC<AuditButtonsProps> = ({ 
-  recordId, 
-  currentStatus, 
-  onSuccess 
+const AuditButtons: React.FC<AuditButtonsProps> = ({
+  recordId,
+  currentStatus,
+  onSuccess
 }) => {
+  const { modal } = App.useApp();
   const queryClient = useQueryClient();
 
   // 审核客户
@@ -44,14 +45,14 @@ const AuditButtons: React.FC<AuditButtonsProps> = ({
 
   const handleAudit = (auditStatus: number) => {
     const actionText = auditStatus === 1 ? '通过审核' : '拒绝审核';
-    const actionType = auditStatus === 1 ? 'success' : 'error';
+    const okType = auditStatus === 1 ? 'primary' : 'danger';
     
-    Modal.confirm({
+    modal.confirm({
       title: '确认审核操作',
       content: `确定要${actionText}该客户吗?此操作不可撤销。`,
       okText: '确认',
       cancelText: '取消',
-      okType: actionType,
+      okType: okType,
       centered: true,
       onOk: () => {
         auditClient.mutate({ id: recordId, auditStatus });