refactor: streamline modal close handlers and completion callbacks across various components

This commit is contained in:
Victor Santos
2025-10-31 18:43:34 -03:00
parent 7d8b28367e
commit b26fb73053
116 changed files with 1865 additions and 2949 deletions
@@ -28,26 +28,19 @@ export const DeleteSecretScanningDataSourceModal = ({
const handleDeleteDataSource = async () => {
const dataSourceType = SECRET_SCANNING_DATA_SOURCE_MAP[type].name;
try {
await deleteDataSource.mutateAsync({
dataSourceId,
type,
projectId
});
await deleteDataSource.mutateAsync({
dataSourceId,
type,
projectId
});
createNotification({
text: `Successfully deleted ${dataSourceType} Data Source`,
type: "success"
});
createNotification({
text: `Successfully deleted ${dataSourceType} Data Source`,
type: "success"
});
if (onComplete) onComplete();
onOpenChange(false);
} catch {
createNotification({
text: `Failed to delete ${dataSourceType} Data Source`,
type: "error"
});
}
if (onComplete) onComplete();
onOpenChange(false);
};
return (
@@ -73,21 +73,13 @@ export const SecretScanningDataSourceForm = ({
connectionId: connection?.id,
projectId: currentProject.id
});
try {
const source = await mutation;
const source = await mutation;
createNotification({
text: `Successfully ${source ? "updated" : "created"} ${sourceType} Data Source`,
type: "success"
});
onComplete(source);
} catch (err: any) {
createNotification({
title: `Failed to ${dataSource ? "update" : "create"} ${sourceType} Data Source`,
text: err.message,
type: "error"
});
}
createNotification({
text: `Successfully ${source ? "updated" : "created"} ${sourceType} Data Source`,
type: "success"
});
onComplete(source);
};
const handlePrev = () => {