Skip to content

Commit

Permalink
fix: update article if JSON changed
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNumericite committed Oct 29, 2024
1 parent 7674974 commit bbf5ed8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions webapp/src/server/api/routers/offer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,19 @@ export const offerRouter = createTRPCRouter({
...(updatedData.articles || []),
obiz_article,
];
} else {
const hasDifferentJson =
JSON.stringify(existingArticle.obizJson) !==
JSON.stringify(JSON.parse(obiz_article.obizJson));
if (hasDifferentJson) {
updatedData.articles = [
...obiz_offer.articles.filter(
(article) => article.reference !== obiz_article.reference
),
...(updatedData.articles || []),
{ id: existingArticle.id, ...obiz_article },
];
}
}
}

Expand Down

0 comments on commit bbf5ed8

Please sign in to comment.