refactor(sql): improved the return function to show data [] when not connected, prevents crashes

This commit is contained in:
2025-04-24 21:24:39 -05:00
parent 3573fd1a5b
commit ead63d4b41
36 changed files with 323 additions and 141 deletions

View File

@@ -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;
}

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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

View File

@@ -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 {