18 lines
641 B
JavaScript
18 lines
641 B
JavaScript
const { productInsideOrder } = require("../lib/utils")
|
|
|
|
;(function () {
|
|
if (!context?.user?.auth()?.id) {
|
|
if (!context.data) throw { status: 400, error: "No data provided" }
|
|
// @ts-ignore
|
|
productInsideOrder(context.data)
|
|
/** @type {ProductRating[]} */ // @ts-ignore
|
|
let ratings = context.db.find("rating", {
|
|
filter: {
|
|
bigcommerceOrderId: context?.data?.bigcommerceOrderId,
|
|
bigCommerceProductId: context?.data?.bigCommerceProductId,
|
|
},
|
|
})
|
|
if (ratings.length) throw { status: 400, error: "Rating already existing" }
|
|
}
|
|
})()
|