diff --git a/api/latest_news/news.js b/api/latest_news/news.js index 92c0dd4..ef451ba 100644 --- a/api/latest_news/news.js +++ b/api/latest_news/news.js @@ -23,6 +23,30 @@ async function GetNews(token="", start = 0) { return res; } +async function GetDetailNews(id, token="") { + var res = await apollo.query( + ` + query($input: ID!) { + latestNews(where:{id:$input}) + { + id + title + description + img{ + url + } + } + } + `, + token, + { + "input": id + } + ); + return res; +} + module.exports = { GetNews: GetNews, + GetDetailNews: GetDetailNews, }; \ No newline at end of file diff --git a/api/product/product.js b/api/product/product.js index f0e9c45..c7994a3 100644 --- a/api/product/product.js +++ b/api/product/product.js @@ -27,11 +27,11 @@ import apollo from "../../lib/apollo.js"; // return res; // } -async function GetDetailProduct(token="") { +async function GetDetailProduct(id, token="") { var res = await apollo.query( ` - query{ - products + query($input: ID!){ + products(where:{id:$input}) { name price @@ -49,9 +49,13 @@ async function GetDetailProduct(token="") { film{ url } + stock } } `, - token + token, + { + "input": id + } ); return res; } @@ -79,6 +83,7 @@ async function GetProductYamaha(token="") { film{ url } + stock } }`, token @@ -109,6 +114,7 @@ async function GetProductSuzuki(token="") { film{ url } + stock } }`, token @@ -139,6 +145,7 @@ async function GetProductHonda(token="") { film{ url } + stock } }`, token @@ -169,6 +176,7 @@ async function GetProductHino(token="") { film{ url } + stock } }`, token @@ -199,6 +207,7 @@ async function GetProductMercedes(token="") { film{ url } + stock } }`, token @@ -229,6 +238,7 @@ async function GetProductBPR(token="") { film{ url } + stock } }`, token @@ -259,6 +269,7 @@ async function GetProductEmilia(token="") { film{ url } + stock } }`, token @@ -289,6 +300,7 @@ async function GetProductHomes(token="") { film{ url } + stock } }`, token diff --git a/assets/img/favicon.png b/assets/img/favicon.png index a95e8c3..d5c10d6 100644 Binary files a/assets/img/favicon.png and b/assets/img/favicon.png differ diff --git a/assets/img/favicons.png b/assets/img/favicons.png new file mode 100644 index 0000000..3f5aa81 Binary files /dev/null and b/assets/img/favicons.png differ diff --git a/pages-sections/latest_news/news.js b/pages-sections/latest_news/news.js index 6b3b6d4..ba7c468 100644 --- a/pages-sections/latest_news/news.js +++ b/pages-sections/latest_news/news.js @@ -14,6 +14,7 @@ import Card from "components/Card/Card.js"; import CardBody from "components/Card/CardBody.js"; import Button from "components/CustomButtons/Button.js"; import Paginations from "components/Pagination/Pagination.js"; +import Icon from "@material-ui/core/Icon"; const useStyles = makeStyles(styles); @@ -54,7 +55,9 @@ const DataLatestNews = function ({ backend, news, ...props }) { {/*

{data.title}

*/}

{data.title}

- +
@@ -68,7 +71,6 @@ const DataLatestNews = function ({ backend, news, ...props }) {
{latnews} - {latnews}
diff --git a/pages-sections/latest_news/news_details.js b/pages-sections/latest_news/news_details.js index e69de29..9802753 100644 --- a/pages-sections/latest_news/news_details.js +++ b/pages-sections/latest_news/news_details.js @@ -0,0 +1,61 @@ +import React, { useState, useEffect } from 'react'; +import Router, { withRouter } from 'next/router' + +// @material-ui/core components +import { makeStyles } from "@material-ui/core/styles"; +import ReactPaginate from 'react-paginate'; + +// component +import styles from "assets/jss/nextjs-material-kit/pages/componentsSections/notificationsStyles.js"; +import Paginations from "components/Pagination/Pagination.js"; + +const useStyles = makeStyles(styles); + +const DataLatestNews = function ({ backend, news, ...props }) { + const [isLoading, setLoading] = useState(false); //State for the loading indicator + const startLoading = () => setLoading(true); + const stopLoading = () => setLoading(false); + useEffect(() => { //After the component is mounted set router event handlers + Router.events.on('routeChangeStart', startLoading); + Router.events.on('routeChangeComplete', stopLoading); + + return () => { + Router.events.off('routeChangeStart', startLoading); + Router.events.off('routeChangeComplete', stopLoading); + } + }, []) + const pagginationHandler = (page) => { + const currentPath = props.router.pathname; + const currentQuery = props.router.query; + currentQuery.page = page.selected + 1; + + props.router.push({ + pathname: currentPath, + query: currentQuery, + }); + }; + + const classes = useStyles(); + const latnews = news.map((data) => { + return ( +
+
+

{data.title}

+




+
+ First slide +




+
+ {data.description} +
+
+ ); + }) + return ( +
+ {latnews} +
+ ); +} + +export default DataLatestNews; diff --git a/pages-sections/product/product.js b/pages-sections/product/product.js index 9272f5b..e9831e8 100644 --- a/pages-sections/product/product.js +++ b/pages-sections/product/product.js @@ -45,7 +45,7 @@ const DataProduct = function ({ backend, yamaha, suzuki, honda, hino, mercedes,

Rp.{data.price}

@@ -67,7 +67,7 @@ const DataProduct = function ({ backend, yamaha, suzuki, honda, hino, mercedes,

Rp.{data.price}

@@ -89,7 +89,7 @@ const DataProduct = function ({ backend, yamaha, suzuki, honda, hino, mercedes,

Rp.{data.price}

@@ -111,7 +111,7 @@ const DataProduct = function ({ backend, yamaha, suzuki, honda, hino, mercedes,

Rp.{data.price}

@@ -133,7 +133,7 @@ const DataProduct = function ({ backend, yamaha, suzuki, honda, hino, mercedes,

Rp.{data.price}

@@ -155,7 +155,7 @@ const DataProduct = function ({ backend, yamaha, suzuki, honda, hino, mercedes,

Rp.{data.price}

@@ -177,7 +177,7 @@ const DataProduct = function ({ backend, yamaha, suzuki, honda, hino, mercedes,

Rp.{data.price}

@@ -199,7 +199,7 @@ const DataProduct = function ({ backend, yamaha, suzuki, honda, hino, mercedes,

Rp.{data.price}

diff --git a/pages-sections/product/product_details.js b/pages-sections/product/product_details.js index ed65441..4d4d295 100644 --- a/pages-sections/product/product_details.js +++ b/pages-sections/product/product_details.js @@ -35,7 +35,6 @@ const DataProduct = function ({ backend, detailproduct, ...props }) { ); const navImageClasses = classNames(classes.imgRounded, classes.imgGallery); const Productdetails = detailproduct.map((data) => { - console.log(data); return (
@@ -54,7 +53,7 @@ const DataProduct = function ({ backend, detailproduct, ...props }) {

{data.name}

Rp.{data.price}


-

{data.description}

+

{data.description} ---- Stock Unit : {data.stock}

@@ -121,7 +120,7 @@ const DataProduct = function ({ backend, detailproduct, ...props }) {
- {Productdetails[0]} + {Productdetails}
diff --git a/pages/_document.js b/pages/_document.js index 4880d27..71095f3 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -13,7 +13,7 @@ class MyDocument extends Document { content="width=device-width, initial-scale=1, shrink-to-fit=no" /> - + + return ( +
+
} + fixed + color="info" + changeColorOnScroll={{ + height: 400, + color: "white" + }} + {...rest} + /> + +
+ + + {/*
+

NextJS Material Kit.

+

+ A Badass Material Kit based on Material-UI and NextJS. +

+
*/} +
+
+
+
+
+ + +
+
+ ); +} + +export default detailLatestNews; + +export async function getServerSideProps(context) { + var {query} = context; + var news = []; + const backend = process.env.BACKEND_SERVER_URI; + var res = await GetLatestNews.GetDetailNews(query.s||0); + if (res["STATUS"] === 1) { + news = res["DATA"]["latestNews"]; + } + return { + props: { news, backend }, // will be passed to the page component as props + }; +} \ No newline at end of file diff --git a/pages/product_detail.js b/pages/product_detail.js index 88d8974..2b6c6cf 100644 --- a/pages/product_detail.js +++ b/pages/product_detail.js @@ -59,10 +59,11 @@ const ProductDetails = function ({ backend, detailproduct, ...props }) { export default ProductDetails; export async function getServerSideProps(context) { + var {query} = context; var detailproduct = []; const backend = process.env.BACKEND_SERVER_URI; - var res = await GetDetailproduct.GetDetailProduct(); + var res = await GetDetailproduct.GetDetailProduct(query.s||0); if (res["STATUS"] === 1) { detailproduct = res["DATA"]["products"]; }