feat(MED-131): show package analysis elements in comparison modal

This commit is contained in:
2025-08-04 11:51:38 +03:00
parent d7d089c11d
commit 8c4df731aa
7 changed files with 224 additions and 106 deletions

View File

@@ -85,6 +85,20 @@ export const listProducts = async ({
})
}
export const getAnalysisElementOriginalIds = async (products: HttpTypes.StoreProduct[]) => {
return products
.flatMap(({ metadata }) => {
const value = metadata?.analysisElementOriginalIds;
try {
return JSON.parse(value as string);
} catch (e) {
console.error("Failed to parse analysisElementOriginalIds from analysis package, possibly invalid format", e);
return [];
}
})
.filter(Boolean) as string[];
}
/**
* This will fetch 100 products to the Next.js cache and sort them based on the sortBy parameter.
* It will then return the paginated products based on the page and limit parameters.