refactor: 消除所有 api-services-raw 残留调用,API 口径完全统一
- dashboardApi 新增 resolveTodo/ignoreTodo/batchResolveTodos/batchIgnoreTodos - notificationsApi 新增 checkContracts/test - settingsApi 新增 confirmRetirementPolicy - socialInsuranceApi 新增 monthlyChanges/housingMonthlyChanges/housingActiveDeclaration - Dashboard.tsx 替换 4 处 apiPatch - Settings.tsx 替换 4 处 apiPost - Notifications.tsx 替换 1 处 apiPost - SocialInsurance.tsx 替换 4 处 apiGet - AIAssistant.tsx 移除未使用的 apiPost 导入 - 所有页面零 api-services-raw 依赖
This commit is contained in:
@@ -3,7 +3,6 @@ import { toast } from 'sonner'
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { Building2, Users, CreditCard, Plus, Bell, Download, Upload, FileSpreadsheet, Clock, CheckCircle, AlertCircle, ClipboardList } from 'lucide-react'
|
||||
import { settingsApi, notificationsApi } from '../lib/api-services'
|
||||
import { post as apiPost, patch as apiPatch } from '../lib/api-services-raw'
|
||||
import { useAuthStore } from '../store/authStore'
|
||||
import Card from '../components/ui/Card'
|
||||
import Button from '../components/ui/Button'
|
||||
@@ -158,7 +157,7 @@ function RetirementSection({ enabled, onToggle }: { enabled: boolean; onToggle:
|
||||
})
|
||||
|
||||
const confirmMutation = useMutation({
|
||||
mutationFn: (id: string) => apiPost(`/settings/retirement-policy/${id}/confirm`),
|
||||
mutationFn: (id: string) => settingsApi.confirmRetirementPolicy(id),
|
||||
onSuccess: () => {
|
||||
toast.success('退休政策已确认生效')
|
||||
setConfirming(false)
|
||||
@@ -762,7 +761,7 @@ function NotificationSettings() {
|
||||
})
|
||||
|
||||
const checkMutation = useMutation({
|
||||
mutationFn: () => apiPost('/notifications/check-contracts') as any,
|
||||
mutationFn: () => notificationsApi.checkContracts() as any,
|
||||
onSuccess: (res: any) => {
|
||||
setCheckResult(`检查完成:发现 ${res.data.checked} 个即将到期的合同,已发送 ${res.data.notified} 条通知`)
|
||||
queryClient.invalidateQueries({ queryKey: ['notification-logs'] })
|
||||
@@ -770,14 +769,14 @@ function NotificationSettings() {
|
||||
})
|
||||
|
||||
const testWechatMutation = useMutation({
|
||||
mutationFn: () => apiPost('/notifications/test', { channel: 'wechat' }) as any,
|
||||
mutationFn: () => notificationsApi.test('wechat') as any,
|
||||
onSuccess: (res: any) => {
|
||||
toast.success(res.success ? res.data.message : (res.error?.message || '测试失败'))
|
||||
},
|
||||
})
|
||||
|
||||
const testEmailMutation = useMutation({
|
||||
mutationFn: () => apiPost('/notifications/test', { channel: 'email' }) as any,
|
||||
mutationFn: () => notificationsApi.test('email') as any,
|
||||
onSuccess: (res: any) => {
|
||||
toast.success(res.success ? res.data.message : (res.error?.message || '测试失败'))
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user