fix(portal-shell): 管理域 UI 规范合规与 TypeScript 修复
- 替换 41 处原生 select 为 Select 组件封装 - 替换 5 处 window.confirm 为 shadcn AlertDialog - 修复 lesson-plans delete-confirm-dialog 为 AlertDialog - 修复 5 处 Tailwind 任意值 text-[10px] - 修复 graphql-data.ts mutation case 缺少 id 定义 - 修复 use-position-persistence.ts eslint 规则引用
This commit is contained in:
@@ -20,6 +20,16 @@ import { useTranslations } from "next-intl";
|
||||
|
||||
import { useAdminClasses, useAutoSchedule } from "@/lib/api";
|
||||
import { notify } from "@/shared/lib/notify";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/shared/components/ui/alert-dialog";
|
||||
import { Button } from "@/shared/components/ui/button";
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state";
|
||||
import {
|
||||
@@ -59,7 +69,6 @@ export function AutoScheduleClient(): React.ReactElement {
|
||||
const classes = data ?? [];
|
||||
|
||||
const handleStart = async (classId: string): Promise<void> => {
|
||||
if (!window.confirm(t("startConfirm"))) return;
|
||||
// 标记为 pending(覆盖之前结果)
|
||||
setResults((prev) => ({
|
||||
...prev,
|
||||
@@ -157,6 +166,8 @@ function AutoScheduleTable({
|
||||
onStart: (classId: string) => Promise<void>;
|
||||
}): React.ReactElement {
|
||||
const t = useTranslations("admin.scheduling.auto");
|
||||
const tCommon = useTranslations("common");
|
||||
const [confirmId, setConfirmId] = useState<string | null>(null);
|
||||
return (
|
||||
<div className="overflow-x-auto rounded-xl border">
|
||||
<table className="w-full text-sm">
|
||||
@@ -200,7 +211,7 @@ function AutoScheduleTable({
|
||||
<Button
|
||||
size="sm"
|
||||
disabled={running}
|
||||
onClick={() => void onStart(cls.id)}
|
||||
onClick={() => setConfirmId(cls.id)}
|
||||
>
|
||||
{t("startButton")}
|
||||
</Button>
|
||||
@@ -210,6 +221,30 @@ function AutoScheduleTable({
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
<AlertDialog
|
||||
open={confirmId !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setConfirmId(null);
|
||||
}}
|
||||
>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("startButton")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>{t("startConfirm")}</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{tCommon("cancel")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={() => {
|
||||
if (confirmId) void onStart(confirmId);
|
||||
setConfirmId(null);
|
||||
}}
|
||||
>
|
||||
{t("startButton")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user