diff --git a/client/public/components/product-list.mjs b/client/public/components/product-list.mjs index 1019f19..bca0f6c 100644 --- a/client/public/components/product-list.mjs +++ b/client/public/components/product-list.mjs @@ -12,7 +12,7 @@ class ProductList extends Component { const products = await fetch(route).then(response => response.json()); this.setState({ ...this.getState, - products: products.data, + products, current_page: products.page.current_page, last_page: products.page.last_page, total: products.page.total, diff --git a/src/controllers/set-controller.js b/src/controllers/set-controller.js index 19e692a..b0815ea 100644 --- a/src/controllers/set-controller.js +++ b/src/controllers/set-controller.js @@ -16,6 +16,18 @@ function ValidateQuery(query) { }; } +async function GetSet(setId) { + await Database.Query('BEGIN TRANSACTION;'); + const dbres = await Database.Query(` + SELECT id, name, price, new_price AS "discount", inv.stock + FROM lego_set + LEFT JOIN lego_set_inventory AS inv ON inv.set_id = lego_set.id + WHERE id = $1::int; + `); + console.log(dbres); + await Database.Query('END TRANSACTION;'); +} + async function GetSets(page, resPerPage) { // query for the set await Database.Query('BEGIN TRANSACTION;'); @@ -44,5 +56,6 @@ async function GetSets(page, resPerPage) { module.exports = { ValidateQuery, + GetSet, GetSets, };