u
This commit is contained in:
@@ -169,9 +169,8 @@ const actions = {
|
||||
actions.setArticleName(key, body.name);
|
||||
}
|
||||
try {
|
||||
const res = await articleApi.update(key, body);
|
||||
actions.setArticle(res.article);
|
||||
return res;
|
||||
await articleApi.update(key, body);
|
||||
return { article: await actions.reloadArticle(key) };
|
||||
} catch (err) {
|
||||
if (nameChange) {
|
||||
// The optimistic patch was wrong: drop the index entry and refetch.
|
||||
@@ -192,9 +191,8 @@ const actions = {
|
||||
* @returns {Promise<object>} Response body containing the fresh `article`.
|
||||
*/
|
||||
async setEans(sku, eans) {
|
||||
const res = await articleApi.setEansBySku(String(sku), eans);
|
||||
actions.setArticle(res.article);
|
||||
return res;
|
||||
await articleApi.setEansBySku(String(sku), eans);
|
||||
return { article: await actions.reloadArticle(sku) };
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -205,9 +203,8 @@ const actions = {
|
||||
* @returns {Promise<object>} Response body containing the fresh `article`.
|
||||
*/
|
||||
async setBrand(sku, body) {
|
||||
const res = await articleApi.setBrandIdBySku(String(sku), body?.brandId);
|
||||
actions.setArticle(res.article);
|
||||
return res;
|
||||
await articleApi.setBrandIdBySku(String(sku), body?.brandId);
|
||||
return { article: await actions.reloadArticle(sku) };
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -218,9 +215,8 @@ const actions = {
|
||||
* @returns {Promise<object>} Response body containing the fresh `article`.
|
||||
*/
|
||||
async setCategories(sku, categoryIds) {
|
||||
const res = await articleApi.setCategories(String(sku), categoryIds);
|
||||
actions.setArticle(res.article);
|
||||
return res;
|
||||
await articleApi.setCategories(String(sku), categoryIds);
|
||||
return { article: await actions.reloadArticle(sku) };
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -231,9 +227,8 @@ const actions = {
|
||||
* @returns {Promise<object>} Response body containing the fresh `article`.
|
||||
*/
|
||||
async setPrices(sku, prices) {
|
||||
const res = await articleApi.setPrices(String(sku), prices);
|
||||
actions.setArticle(res.article);
|
||||
return res;
|
||||
await articleApi.setPrices(String(sku), prices);
|
||||
return { article: await actions.reloadArticle(sku) };
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -244,9 +239,8 @@ const actions = {
|
||||
* @returns {Promise<object>} Response body containing the fresh `article`.
|
||||
*/
|
||||
async setWeight(sku, body) {
|
||||
const res = await articleApi.setWeight(String(sku), body);
|
||||
actions.setArticle(res.article);
|
||||
return res;
|
||||
await articleApi.setWeight(String(sku), body);
|
||||
return { article: await actions.reloadArticle(sku) };
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -257,9 +251,8 @@ const actions = {
|
||||
* @returns {Promise<object>} Response body containing the fresh `article`.
|
||||
*/
|
||||
async setTrackStock(sku, body) {
|
||||
const res = await articleApi.setTrackStock(String(sku), body);
|
||||
if (res?.article) actions.setArticle(res.article);
|
||||
return res;
|
||||
await articleApi.setTrackStock(String(sku), body);
|
||||
return { article: await actions.reloadArticle(sku) };
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -213,8 +213,8 @@ const actions = {
|
||||
* @param {{ parentId: number|string, name: string }} param0
|
||||
*/
|
||||
async createArticle({ parentId, name }) {
|
||||
const res = await articleApi.create({ categoryId: parentId, name });
|
||||
const created = res.article;
|
||||
const { sku } = await articleApi.create({ categoryId: parentId, name });
|
||||
const { article: created } = await articleApi.getBySku(sku);
|
||||
if (created) appendArticlesToCategoryViews({ categoryId: parentId, articles: [created] });
|
||||
return created;
|
||||
},
|
||||
@@ -228,8 +228,9 @@ const actions = {
|
||||
if (list.length === 0) throw new Error('Keine Namen übergeben.');
|
||||
const created = [];
|
||||
for (const name of list) {
|
||||
const res = await articleApi.create({ categoryId: parentId, name });
|
||||
if (res.article) created.push(res.article);
|
||||
const { sku } = await articleApi.create({ categoryId: parentId, name });
|
||||
const { article: created1 } = await articleApi.getBySku(sku);
|
||||
if (created1) created.push(created1);
|
||||
}
|
||||
appendArticlesToCategoryViews({ categoryId: parentId, articles: created });
|
||||
return created;
|
||||
|
||||
Reference in New Issue
Block a user