Files

40 lines
1.0 KiB
TypeScript

import { tryCatch } from "../../../../globalUtils/tryCatch.js";
import { query } from "../../../sqlServer/prodSqlServer.js";
import { lotQuery } from "../../../sqlServer/querys/ocp/lots.js";
type LotInfo = {
success: boolean;
message: string;
data: any[];
};
export const getLots = async () => {
const { data: l, error: lotError } = await tryCatch(
query(lotQuery, "Alplalabel online lots")
);
const lotInfo = l as LotInfo;
if (lotError) {
console.log("lot error", lotError);
return {
success: false,
message: "There was an error getting the lots",
data: [],
};
}
if (lotInfo.success) {
return {
success: true,
message: "Current active lots that are technically released.",
data: lotInfo.data,
};
} else {
return {
success: true,
message: `Error getting lot info due to: ${lotInfo.message}.`,
data: [],
};
}
};