import { desc } from "drizzle-orm";
import { db } from "../../../../database/dbclient.js";
import { qualityRequest } from "../../../../database/schema/qualityRequest.js";
import { tryCatch } from "../../../globalUtils/tryCatch.js";
import qualityBlockingMonitor from "../../notifications/controller/notifications/qualityBlocking.js";

export const getRequest = async () => {
    const { data, error } = await tryCatch(
        db.select().from(qualityRequest).orderBy(desc(qualityRequest.add_date))
    );

    if (error) {
        return {
            success: false,
            message: "There was an error getting the quality request",
            data: error,
        };
    }

    return {
        success: true,
        message: "Quality request pallets.",
        data,
    };
};
