Skip to content

Commit

Permalink
Improved: changed the scheduleService action indentations(#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Sourabh committed Dec 31, 2024
1 parent b47f49e commit 1f01cbb
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions src/store/modules/stock/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,49 +150,49 @@ const actions: ActionTree<StockState, RootState> = {
async scheduleService({ dispatch }, { params, restockName, scheduledTime }) {
let resp;

const job = await dispatch("fetchDraftJob")
const job = await dispatch("fetchDraftJob")

if(!job.jobId || !job.serviceName || job.serviceName == '_NA_') {
showToast(translate("Configuration missing"))
return;
}
if(!job.jobId || !job.serviceName || job.serviceName == '_NA_') {
showToast(translate("Configuration missing"))
return;
}

const payload = {
'JOB_NAME': restockName || `Created ${DateTime.now().toLocaleString(DateTime.DATETIME_MED)}`,
'SERVICE_NAME': job.serviceName,
'SERVICE_COUNT': '0',
'SERVICE_TEMP_EXPR': job.jobStatus,
'SERVICE_RUN_AS_SYSTEM':'Y',
'jobFields': {
const payload = {
'JOB_NAME': restockName || `Created ${DateTime.now().toLocaleString(DateTime.DATETIME_MED)}`,
'SERVICE_NAME': job.serviceName,
'SERVICE_COUNT': '0',
'SERVICE_TEMP_EXPR': job.jobStatus,
'SERVICE_RUN_AS_SYSTEM':'Y',
'jobFields': {
'systemJobEnumId': job.systemJobEnumId,
'tempExprId': job.jobStatus, // Need to remove this as we are passing frequency in SERVICE_TEMP_EXPR, currently kept it for backward compatibility
'parentJobId': job.parentJobId,
'runAsUser': 'system', //default system, but empty in run now. TODO Need to remove this as we are using SERVICE_RUN_AS_SYSTEM, currently kept it for backward compatibility
'recurrenceTimeZone': this.state.user.current.userTimeZone,
'createdByUserLogin': this.state.user.current.userLoginId,
'lastModifiedByUserLogin': this.state.user.current.userLoginId,
},
'statusId': "SERVICE_PENDING",
'systemJobEnumId': job.systemJobEnumId,
'tempExprId': job.jobStatus, // Need to remove this as we are passing frequency in SERVICE_TEMP_EXPR, currently kept it for backward compatibility
'parentJobId': job.parentJobId,
'runAsUser': 'system', //default system, but empty in run now. TODO Need to remove this as we are using SERVICE_RUN_AS_SYSTEM, currently kept it for backward compatibility
'recurrenceTimeZone': this.state.user.current.userTimeZone,
'createdByUserLogin': this.state.user.current.userLoginId,
'lastModifiedByUserLogin': this.state.user.current.userLoginId,
},
'statusId': "SERVICE_PENDING",
'systemJobEnumId': job.systemJobEnumId,
...params
}
...params
}

job?.priority && (payload['SERVICE_PRIORITY'] = job.priority.toString())
payload['SERVICE_TIME'] = scheduledTime.toString()
job?.sinceId && (payload['sinceId'] = job.sinceId)
job?.priority && (payload['SERVICE_PRIORITY'] = job.priority.toString())
payload['SERVICE_TIME'] = scheduledTime.toString()
job?.sinceId && (payload['sinceId'] = job.sinceId)

try {
resp = await StockService.scheduleJob({ ...payload });
if (resp.status == 200 && !hasError(resp)) {
showToast(translate('Service has been scheduled'));
} else {
try {
resp = await StockService.scheduleJob({ ...payload });
if (resp.status == 200 && !hasError(resp)) {
showToast(translate('Service has been scheduled'));
} else {
showToast(translate('Something went wrong'))
}
} catch (err) {
showToast(translate('Something went wrong'))
logger.error(err)
}
} catch (err) {
showToast(translate('Something went wrong'))
logger.error(err)
}
return {};
return {};
},

async fetchDraftJob() {
Expand Down

0 comments on commit 1f01cbb

Please sign in to comment.