fix : delete btn is not disabling when clicking #1519 (#1575)

This commit is contained in:
Sachin Mittal
2023-11-05 19:16:22 +05:30
committed by GitHub
parent 1ff14e7714
commit f1849dcff8

View File

@@ -26,16 +26,19 @@ const DeleteProductRender: React.FC<DeleteProductRenderProps> = ({
}) => {
const router = useRouter();
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
const [isDeleting, setIsDeleting] = useState(false);
const handleDeleteProduct = async () => {
try {
setIsDeleting(true);
const deletedProduct = await deleteProductAction(environmentId, userId, product.id);
if (!!deletedProduct?.id) {
toast.success("Product deleted successfully.");
router.push("/");
}
setIsDeleting(false);
} catch (err) {
setIsDeleting(false);
toast.error("Could not delete product.");
setIsDeleteDialogOpen(false);
}
@@ -77,6 +80,7 @@ const DeleteProductRender: React.FC<DeleteProductRenderProps> = ({
product.name,
30
)}"? This action cannot be undone.`}
isDeleting={isDeleting}
/>
</div>
);