Skip to content

Commit

Permalink
Reverted to then-catch to make consistancy in code
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammad-ali-e committed Jan 29, 2025
1 parent 480f863 commit f3e46c7
Showing 1 changed file with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,30 +111,32 @@ function Pipelines({ type }) {
});
};

const handleSync = async (params) => {
const handleSync = (params) => {
const body = { ...params, pipeline_type: type.toUpperCase() };
const pipelineId = params?.pipeline_id;
const fieldsToUpdate = {
last_run_status: "processing",
};
handleLoaderInTableData(fieldsToUpdate, pipelineId);

try {
const res = await handleSyncApiReq(body);
const data = res?.data?.pipeline;
fieldsToUpdate.last_run_status = data?.last_run_status;
fieldsToUpdate.last_run_time = data?.last_run_time;
setAlertDetails({
type: "success",
content: "Pipeline Sync Initiated",
handleSyncApiReq(body)
.then((res) => {
const data = res?.data?.pipeline;
fieldsToUpdate.last_run_status = data?.last_run_status;
fieldsToUpdate.last_run_time = data?.last_run_time;
setAlertDetails({
type: "success",
content: "Pipeline Sync Initiated",
});
})
.catch((err) => {
setAlertDetails(handleException(err, "Failed to sync."));
fieldsToUpdate.last_run_status = "FAILURE";
fieldsToUpdate.last_run_time = new Date().toISOString();
})
.finally(() => {
handleLoaderInTableData(fieldsToUpdate, pipelineId);
});
} catch (err) {
setAlertDetails(handleException(err, "Failed to sync."));
fieldsToUpdate.last_run_status = "FAILURE";
fieldsToUpdate.last_run_time = new Date().toISOString();
} finally {
handleLoaderInTableData(fieldsToUpdate, pipelineId);
}
};

const handleStatusRefresh = (pipelineId) => {
Expand Down

0 comments on commit f3e46c7

Please sign in to comment.