"use client" import { getTaskWorkFlow } from "@/components/label/api/task" import { Button, Group, Modal, ScrollArea, Stack, Text } from "@mantine/core" import { notifications } from "@mantine/notifications" import { useEffect, useState } from "react" export default function WorkflowModal(props: { opened: boolean taskId: number | null onCloseAction: () => void }) { const { opened, taskId, onCloseAction } = props const [loading, setLoading] = useState(false) const [records, setRecords] = useState([]) useEffect(() => { if (!opened || !taskId) return const run = async () => { setLoading(true) try { const res = await getTaskWorkFlow(taskId) setRecords(res ?? []) } catch (e) { setRecords([]) notifications.show({ color: "red", title: "加载失败", message: e instanceof Error ? e.message : "请求失败", }) } finally { setLoading(false) } } run() }, [opened, taskId]) return ( {records.length ? ( records.map((r, idx) => ( {JSON.stringify(r, null, 2)} )) ) : ( {loading ? "加载中..." : "暂无数据"} )} ) }