u
This commit is contained in:
@@ -10,6 +10,24 @@ export function primaryPhoto(article) {
|
||||
return photos[0] ?? null;
|
||||
}
|
||||
|
||||
/** Map POST /api/article/:sku/image → photos[] entry shape. */
|
||||
export function photoFromUploadedImage(image) {
|
||||
return {
|
||||
sort: image.sort,
|
||||
thumbW: image.thumb.w,
|
||||
thumbH: image.thumb.h,
|
||||
thumbHash: image.thumbHash,
|
||||
};
|
||||
}
|
||||
|
||||
export function articleWithUploadedPhoto(article, image) {
|
||||
const photo = photoFromUploadedImage(image);
|
||||
const photos = sortedPhotos(article).filter((row) => row.sort !== photo.sort);
|
||||
photos.push(photo);
|
||||
photos.sort((a, b) => a.sort - b.sort);
|
||||
return { ...article, photos };
|
||||
}
|
||||
|
||||
export function primaryPrice(article) {
|
||||
if (!Array.isArray(article?.prices) || article.prices.length === 0) return null;
|
||||
return article.prices.find((row) => row.minmultiplier === 1) ?? article.prices[0];
|
||||
|
||||
Reference in New Issue
Block a user