From 51906d5440dd07c44ffd5028e6f8511bdf06c5b0 Mon Sep 17 00:00:00 2001 From: Michael Leon Putra Widhi <leonmichael463@gmail.com> Date: Sat, 7 Oct 2023 09:06:22 +0700 Subject: [PATCH] fix : admin page navbar routing --- scripts/client/public/js/navigation.js | 18 +++--------------- scripts/server/app/models/ProductModel.php | 9 +++++---- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/scripts/client/public/js/navigation.js b/scripts/client/public/js/navigation.js index 31efff1..fde676f 100644 --- a/scripts/client/public/js/navigation.js +++ b/scripts/client/public/js/navigation.js @@ -6,9 +6,9 @@ function putNavbar(userRole) { { text: "Topup", icon: "topup.png", onClick: "http://localhost:8000/pages/topup" } ], admin: [ - { text: "Edit Product", icon: "edit-product.png", onClick: redirectToAdminProduct }, - { text: "Handle Topup", icon: "topup.png", onClick: redirectToAdminTopUp }, - { text: "Users", icon: "user-manage.png", onClick: redirectToAdminUser } + { text: "Edit Product", icon: "edit-product.png", onClick: "http://localhost:8000/pages/admin-product" }, + { text: "Handle Topup", icon: "topup.png", onClick: "http://localhost:8000/pages/admin-top-up" }, + { text: "Users", icon: "user-manage.png", onClick: "http://localhost:8000/pages/admin-user" } ], guest : [], }; @@ -51,10 +51,6 @@ function redirectToSettings() { window.location.href = "http://localhost:8000/pages/settings"; } -function redirectToAdminProduct() { - window.location.href = "http://localhost:8000/pages/admin-product"; -} - function redirectToCreateProduct() { window.location.href = "http://localhost:8000/pages/admin-product-create"; } @@ -63,18 +59,10 @@ function redirectToEditProduct(id) { window.location.href = "http://localhost:8000/pages/admin-product-edit?id=" + id; } -function redirectToAdminTopUp() { - window.location.href = "http://localhost:8000/pages/admin-top-up"; -} - function redirectToCreateTopUp() { window.location.href = "http://localhost:8000/pages/admin-top-up-create"; } -function redirectToAdminUser() { - window.location.href = "http://localhost:8000/pages/admin-user"; -} - function redirectToCreateUser() { window.location.href = "http://localhost:8000/pages/admin-user-create"; } diff --git a/scripts/server/app/models/ProductModel.php b/scripts/server/app/models/ProductModel.php index 77fb923..20bddfd 100644 --- a/scripts/server/app/models/ProductModel.php +++ b/scripts/server/app/models/ProductModel.php @@ -43,7 +43,7 @@ class ProductModel { product.price, product.stock FROM product - INNER JOIN category ON product.idCategory = category.id + INNER JOIN category ON product.idCategory = category.id WHERE stock > 0 ORDER BY product.name'); return $this->db->resultSet(); @@ -59,7 +59,7 @@ class ProductModel { price, stock FROM product - INNER JOIN category ON product.idCategory = category.id + INNER JOIN category ON product.idCategory = category.id WHERE product.id = :id ORDER BY product.name'); $this->db->bind(':id', (int) $id); @@ -83,7 +83,7 @@ class ProductModel { product.price, product.stock FROM product - INNER JOIN category ON product.idCategory = category.id + INNER JOIN category ON product.idCategory = category.id WHERE product.id = :id ORDER BY product.name'); $this->db->bind(':id', (int) $id); @@ -102,7 +102,8 @@ class ProductModel { product.price, product.stock FROM product - INNER JOIN category ON product.idCategory = category.id + INNER JOIN category ON product.idCategory = category.id + WHERE stock > 0 ORDER BY product.name LIMIT :limit OFFSET :offset'); -- GitLab