/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ import { Button, MiddleTextTruncation, Modal, ModalButtonBar, Text } from "@itwin/itwinui-react"; import React, { useState } from "react"; import "./DeleteModal.scss"; import { handleError, LoadingSpinner } from "./utils"; export interface DeleteModalProps { entityName: string; show: boolean; setShow: React.Dispatch>; onDelete: () => Promise; refresh: () => Promise; } export const DeleteModal = ({ entityName, show, setShow, onDelete, refresh }: DeleteModalProps) => { const [isLoading, setIsLoading] = useState(false); const deleteCallback = async () => { try { setIsLoading(true); await onDelete(); setShow(false); await refresh(); } catch (error: any) { handleError(error.status); } finally { setIsLoading(false); } }; return ( { setShow(false); }} >
Are you sure you want to delete
{isLoading && (
)}
); };