Option edits

This commit is contained in:
Sebastian Rindom
2020-07-04 19:36:22 +02:00
parent e9c80e80a4
commit 45e0338c58
2 changed files with 20 additions and 15 deletions
@@ -4,7 +4,7 @@ export default async (req, res) => {
const { id } = req.params
const schema = Validator.object().keys({
option_title: Validator.string().required(),
title: Validator.string().required(),
})
const { value, error } = schema.validate(req.body)
if (error) {
@@ -13,18 +13,21 @@ export default async (req, res) => {
try {
const productService = req.scope.resolve("productService")
const newProduct = await productService.addOption(id, value.option_title)
const newProduct = await productService.addOption(id, value.title)
const data = await productService.decorate(newProduct, [
"title",
"description",
"tags",
"handle",
"images",
"options",
"variants",
"published",
])
const data = await productService.decorate(
newProduct,
[
"title",
"description",
"tags",
"handle",
"images",
"options",
"published",
],
["variants"]
)
res.json({ product: data })
} catch (err) {
throw err