PR Review fixes
This commit is contained in:
@@ -25,12 +25,6 @@ import { defaultFields, defaultRelations } from "."
|
||||
* description: "The Address to be used for shipping."
|
||||
* anyOf:
|
||||
* - $ref: "#/components/schemas/address"
|
||||
* billing_address_id:
|
||||
* description: The id of an existing billing Address
|
||||
* type: string
|
||||
* shipping_address_id:
|
||||
* description: The id of an existing shipping Address
|
||||
* type: string
|
||||
* items:
|
||||
* description: The Line Items that have been received.
|
||||
* type: array
|
||||
@@ -98,15 +92,13 @@ import { defaultFields, defaultRelations } from "."
|
||||
export default async (req, res) => {
|
||||
const schema = Validator.object().keys({
|
||||
status: Validator.string()
|
||||
.valid("open", "awaiting", "completed")
|
||||
.valid("open", "completed")
|
||||
.optional(),
|
||||
email: Validator.string()
|
||||
.email()
|
||||
.required(),
|
||||
billing_address: Validator.address().optional(),
|
||||
shipping_address: Validator.address().optional(),
|
||||
billing_address_id: Validator.string().optional(),
|
||||
shipping_address_id: Validator.string().optional(),
|
||||
items: Validator.array()
|
||||
.items({
|
||||
variant_id: Validator.string()
|
||||
|
||||
@@ -66,10 +66,7 @@ export default async (req, res) => {
|
||||
.withTransaction(manager)
|
||||
.retrieve(id, { select: defaultFields, relations: ["cart"] })
|
||||
|
||||
if (
|
||||
draftOrder.status === "completed" ||
|
||||
draftOrder.status === "awaiting"
|
||||
) {
|
||||
if (draftOrder.status === "completed") {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.NOT_ALLOWED,
|
||||
"You are only allowed to update open draft orders"
|
||||
|
||||
@@ -35,10 +35,7 @@ export default async (req, res) => {
|
||||
.withTransaction(manager)
|
||||
.retrieve(id, { select: defaultFields })
|
||||
|
||||
if (
|
||||
draftOrder.status === "completed" ||
|
||||
draftOrder.status === "awaiting"
|
||||
) {
|
||||
if (draftOrder.status === "completed") {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.NOT_ALLOWED,
|
||||
"You are only allowed to update open draft orders"
|
||||
|
||||
@@ -67,11 +67,6 @@ export default async (req, res) => {
|
||||
code: Validator.string(),
|
||||
})
|
||||
.optional(),
|
||||
gift_cards: Validator.array()
|
||||
.items({
|
||||
code: Validator.string(),
|
||||
})
|
||||
.optional(),
|
||||
customer_id: Validator.string().optional(),
|
||||
})
|
||||
|
||||
@@ -86,7 +81,7 @@ export default async (req, res) => {
|
||||
|
||||
const draftOrder = await draftOrderService.retrieve(id)
|
||||
|
||||
if (draftOrder.status === "completed" || draftOrder.status === "awaiting") {
|
||||
if (draftOrder.status === "completed") {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.NOT_ALLOWED,
|
||||
"You are only allowed to update open draft orders"
|
||||
|
||||
@@ -64,10 +64,7 @@ export default async (req, res) => {
|
||||
relations: ["cart", "cart.items"],
|
||||
})
|
||||
|
||||
if (
|
||||
draftOrder.status === "completed" ||
|
||||
draftOrder.status === "awaiting"
|
||||
) {
|
||||
if (draftOrder.status === "completed") {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.NOT_ALLOWED,
|
||||
"You are only allowed to update open draft orders"
|
||||
|
||||
Reference in New Issue
Block a user