refactor: remove remaining browser confirm dialogs from job actions
This commit is contained in:
@@ -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() });
|
||||
|
||||
Reference in New Issue
Block a user