refactor: remove remaining browser confirm dialogs from job actions

This commit is contained in:
cesnimda
2026-03-22 14:19:48 +01:00
parent abac48847c
commit 0c28e22a1c
3 changed files with 36 additions and 12 deletions
@@ -24,7 +24,7 @@ import VisibilityOutlinedIcon from "@mui/icons-material/VisibilityOutlined";
import { api } from "../api";
import { useToast } from "../toast";
import { confirmAction, promptForValue } from "../dialogs";
import { useDialogActions } from "../dialogs";
interface AttachmentItem {
id: number;
@@ -59,6 +59,7 @@ function guessKind(fileName: string): string {
export default function Attachments({ jobId }: { jobId: number }) {
const { toast } = useToast();
const { confirmAction, promptForValue } = useDialogActions();
const [items, setItems] = useState<AttachmentItem[]>([]);
const [previewOpen, setPreviewOpen] = useState(false);
const [preview, setPreview] = useState<{ url: string; type: string; name: string } | null>(null);
@@ -83,7 +84,7 @@ export default function Attachments({ jobId }: { jobId: number }) {
}, [preview?.url]);
const rename = async (a: AttachmentItem) => {
const next = promptForValue("Rename attachment to:", a.fileName);
const next = await promptForValue("Rename attachment to:", a.fileName, { title: "Rename attachment", confirmLabel: "Rename" });
if (!next || next.trim() === a.fileName) return;
try {
await api.patch(`/attachments/${a.id}`, { fileName: next.trim() });