feat(08-05-interaction-pattern-unification): 统一前端交互与反馈模式
这个提交包含在:
@@ -1,8 +1,7 @@
|
||||
import { resolveErrorMessage as resolveUserErrorMessage } from "../lib/resolveErrorMessage";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { toast } from "sonner";
|
||||
import { mapApiErrorMessage } from "../api/errorMessages";
|
||||
import { isApiError } from "../api/types";
|
||||
import { createDelegation, fetchMyDelegations, revokeDelegation } from "../api/delegations";
|
||||
import { fetchWorkflowApprovers } from "../api/workflow";
|
||||
import { PageHeader } from "../components/common/PageHeader";
|
||||
@@ -50,7 +49,7 @@ export function DelegationsPage() {
|
||||
toast.success("委派已创建");
|
||||
},
|
||||
onError: (err) => {
|
||||
const msg = isApiError(err) ? `${err.code}: ${mapApiErrorMessage(err.code, err.details, err.message)}` : err instanceof Error ? err.message : "创建委派失败";
|
||||
const msg = resolveUserErrorMessage(err, "创建委派失败");
|
||||
setError(msg);
|
||||
toast.error(msg);
|
||||
},
|
||||
@@ -64,7 +63,7 @@ export function DelegationsPage() {
|
||||
toast.success("已撤销");
|
||||
},
|
||||
onError: (err) => {
|
||||
const msg = isApiError(err) ? `${err.code}: ${mapApiErrorMessage(err.code, err.details, err.message)}` : err instanceof Error ? err.message : "撤销委派失败";
|
||||
const msg = resolveUserErrorMessage(err, "撤销委派失败");
|
||||
setError(msg);
|
||||
toast.error(msg);
|
||||
},
|
||||
@@ -161,13 +160,7 @@ export function DelegationsPage() {
|
||||
{listQuery.isLoading ? <TableSkeleton columns={5} rows={3} /> : null}
|
||||
{listQuery.isError ? (
|
||||
<p className="text-sm text-red-600">
|
||||
{isApiError(listQuery.error)
|
||||
? `${listQuery.error.code}: ${mapApiErrorMessage(
|
||||
listQuery.error.code,
|
||||
listQuery.error.details,
|
||||
listQuery.error.message,
|
||||
)}`
|
||||
: "加载委派列表失败"}
|
||||
{resolveUserErrorMessage(listQuery.error, "加载委派列表失败")}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
@@ -259,4 +252,3 @@ export function DelegationsPage() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户