refactor(sql): improved the return function to show data [] when not connected, prevents crashes
This commit is contained in:
@@ -4,7 +4,8 @@ import { activeArticle } from "../../sqlServer/querys/dataMart/article.js";
|
||||
export const getActiveAv = async () => {
|
||||
let articles: any = [];
|
||||
try {
|
||||
articles = await query(activeArticle, "Get active articles");
|
||||
const res = await query(activeArticle, "Get active articles");
|
||||
articles = res?.data;
|
||||
} catch (error) {
|
||||
articles = error;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,15 @@ export const getCurrentCustomerInv = async (customer: any | null) => {
|
||||
);
|
||||
}
|
||||
try {
|
||||
const inventory = await query(updatedQuery, "Get active inventory");
|
||||
const inventory: any = await query(
|
||||
updatedQuery,
|
||||
"Get active inventory"
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "All customer inventory minus holds",
|
||||
data: inventory,
|
||||
data: inventory.data,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
|
||||
@@ -17,7 +17,7 @@ export const getDeliveryByDateRange = async (data: any | null) => {
|
||||
data: plantError,
|
||||
};
|
||||
}
|
||||
let deliverys = [];
|
||||
let deliverys: any = [];
|
||||
|
||||
let updatedQuery = deliveryByDateRange;
|
||||
|
||||
@@ -40,7 +40,11 @@ export const getDeliveryByDateRange = async (data: any | null) => {
|
||||
}
|
||||
|
||||
try {
|
||||
deliverys = await query(updatedQuery, "Get Delivery by date range");
|
||||
const res: any = await query(
|
||||
updatedQuery,
|
||||
"Get Delivery by date range"
|
||||
);
|
||||
deliverys - res.data;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return {
|
||||
|
||||
@@ -16,7 +16,7 @@ export const getOpenOrders = async (data: any | null) => {
|
||||
data: plantError,
|
||||
};
|
||||
}
|
||||
let orders = [];
|
||||
let orders: any = [];
|
||||
|
||||
let updatedQuery = openOrders;
|
||||
|
||||
@@ -37,7 +37,11 @@ export const getOpenOrders = async (data: any | null) => {
|
||||
try {
|
||||
orders = await query(updatedQuery, "Get active openorders");
|
||||
} catch (error) {
|
||||
return { success: false, message: "Current open orders", data: orders };
|
||||
return {
|
||||
success: false,
|
||||
message: "Current open orders",
|
||||
data: orders.data,
|
||||
};
|
||||
}
|
||||
|
||||
// add plant token in
|
||||
|
||||
@@ -22,7 +22,7 @@ export const getINV = async (rn: boolean) => {
|
||||
|
||||
try {
|
||||
inventory = await query(updatedQuery, "Gets Curruent inv");
|
||||
return { success: true, message: "Current inv", data: inventory };
|
||||
return { success: true, message: "Current inv", data: inventory.data };
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user