refactor(sql): improved the return function to show data [] when not connected, prevents crashes
This commit is contained in:
@@ -29,13 +29,13 @@ export const abbottOrders = async (data: any, user: any) => {
|
||||
}
|
||||
|
||||
// articleInfo
|
||||
const { data: a, error: ae } = await tryCatch(
|
||||
const { data: article, error: ae } = await tryCatch(
|
||||
query(
|
||||
bulkOrderArticleInfo.replace("[articles]", articles),
|
||||
"Get Article data for bulk orders"
|
||||
)
|
||||
);
|
||||
|
||||
const a: any = article?.data;
|
||||
if (ae) {
|
||||
return {
|
||||
sucess: false,
|
||||
@@ -45,10 +45,12 @@ export const abbottOrders = async (data: any, user: any) => {
|
||||
}
|
||||
|
||||
// order state
|
||||
const { data: openOrders, error: oe } = await tryCatch(
|
||||
const { data: o, error: oe } = await tryCatch(
|
||||
query(orderState, "Gets the next 500 orders that have not been started")
|
||||
);
|
||||
|
||||
const openOrders: any = o?.data;
|
||||
|
||||
if (oe) {
|
||||
return {
|
||||
sucess: false,
|
||||
|
||||
@@ -24,10 +24,12 @@ export const energizerOrders = async (data: any, user: any) => {
|
||||
}
|
||||
|
||||
// order state
|
||||
const { data: openOrders, error: oe } = await tryCatch(
|
||||
const { data: o, error: oe } = await tryCatch(
|
||||
query(orderState, "Gets the next 500 orders that have not been started")
|
||||
);
|
||||
|
||||
const openOrders: any = o?.data;
|
||||
|
||||
if (oe) {
|
||||
return {
|
||||
sucess: false,
|
||||
@@ -37,9 +39,10 @@ export const energizerOrders = async (data: any, user: any) => {
|
||||
}
|
||||
|
||||
// order state
|
||||
const { data: i, error: ie } = await tryCatch(
|
||||
const { data: invoice, error: ie } = await tryCatch(
|
||||
query(invoiceAddress, "Gets invoices addresses")
|
||||
);
|
||||
const i: any = invoice?.data;
|
||||
|
||||
if (ie) {
|
||||
return {
|
||||
|
||||
@@ -25,10 +25,12 @@ export const standardOrders = async (data: any, user: any) => {
|
||||
}
|
||||
|
||||
// order state
|
||||
const { data: openOrders, error: oe } = await tryCatch(
|
||||
const { data: o, error: oe } = await tryCatch(
|
||||
query(orderState, "Gets the next 500 orders that have not been started")
|
||||
);
|
||||
|
||||
const openOrders: any = o?.data;
|
||||
|
||||
if (oe) {
|
||||
return {
|
||||
sucess: false,
|
||||
@@ -38,10 +40,10 @@ export const standardOrders = async (data: any, user: any) => {
|
||||
}
|
||||
|
||||
// order state
|
||||
const { data: i, error: ie } = await tryCatch(
|
||||
const { data: invoice, error: ie } = await tryCatch(
|
||||
query(invoiceAddress, "Gets invoices addresses")
|
||||
);
|
||||
|
||||
const i: any = invoice?.data;
|
||||
if (ie) {
|
||||
return {
|
||||
sucess: false,
|
||||
|
||||
Reference in New Issue
Block a user