Initial content

This commit is contained in:
Adam Freeman
2024-05-29 18:54:49 +01:00
parent 2dbc1a8088
commit 5215a1d919
1944 changed files with 203378 additions and 0 deletions
@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCartDetail = void 0;
const _1 = require(".");
const getCartDetail = async (cart) => {
const ids = cart.lines.map(l => l.productId);
const db_data = await _1.catalog_repository.getProductDetails(ids);
const products = Object.fromEntries(db_data.map(p => [p.id, p]));
const lines = cart.lines.map(line => ({
product: products[line.productId],
quantity: line.quantity,
subtotal: products[line.productId].price * line.quantity
}));
const total = lines.reduce((total, line) => total + line.subtotal, 0);
return { lines, total };
};
exports.getCartDetail = getCartDetail;