import DetailProduct from "../../../api/product/product";

export default async function handler(req, res) {
    console.log("masuk");
    if (req.method == "POST") {
        var id = req.body.id;
            var detailproduct = await DetailProduct.GetDetailProduct(id);
            if (detailproduct["STATUS"] == 0) {
                res.status(200).json(detailproduct);
            } else if (detailproduct["DATA"]["products"] == null) {
                res
                    .status(200)
                    .json({
                        STATUS: 0,
                        DATA: "Product Tidak Ditemukan"
                    });
            } else {
                res.status(200).json({
                    STATUS: 1,
                    DATA: detailproduct["DATA"]["products"],
                });
            }
    } else {
        console.log("masukas");
        res.status(200).send("NOT FOUND");
    }
}