mirror of
https://github.com/formbricks/formbricks.git
synced 2026-03-04 21:40:43 -06:00
feat: loader in deleteAction
This commit is contained in:
@@ -42,6 +42,7 @@ export default function ActionSettingsTab({ environmentId, actionClass, setOpen
|
||||
},
|
||||
});
|
||||
const [isUpdatingAction, setIsUpdatingAction] = useState(false);
|
||||
const [isDeletingAction, setIsDeletingAction] = useState(false);
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
const filteredNoCodeConfig = filterNoCodeConfig(data.noCodeConfig as NoCodeConfig);
|
||||
@@ -81,6 +82,20 @@ export default function ActionSettingsTab({ environmentId, actionClass, setOpen
|
||||
if (match === "no") toast.error("Your survey would not be shown.");
|
||||
};
|
||||
|
||||
const handleDeleteAction = async () => {
|
||||
try {
|
||||
setIsDeletingAction(true);
|
||||
await deleteActionClass(environmentId, actionClass.id);
|
||||
router.refresh();
|
||||
toast.success("Action deleted successfully");
|
||||
setOpen(false);
|
||||
} catch (error) {
|
||||
toast.error("Something went wrong. Please try again.");
|
||||
} finally {
|
||||
setIsDeletingAction(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<form className="space-y-4" onSubmit={handleSubmit(onSubmit)}>
|
||||
@@ -288,18 +303,10 @@ export default function ActionSettingsTab({ environmentId, actionClass, setOpen
|
||||
<DeleteDialog
|
||||
open={openDeleteDialog}
|
||||
setOpen={setOpenDeleteDialog}
|
||||
isDeleting={isDeletingAction}
|
||||
deleteWhat={"Action"}
|
||||
text="Are you sure you want to delete this action? This also removes this action as a trigger from all your surveys."
|
||||
onDelete={async () => {
|
||||
setOpen(false);
|
||||
try {
|
||||
await deleteActionClass(environmentId, actionClass.id);
|
||||
router.refresh();
|
||||
toast.success("Action deleted successfully");
|
||||
} catch (error) {
|
||||
toast.error("Something went wrong. Please try again.");
|
||||
}
|
||||
}}
|
||||
onDelete={handleDeleteAction}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user