From e56d072b1fde28dce7709d0f8d08916fb6f4c5d8 Mon Sep 17 00:00:00 2001 From: Yusmardianto Date: Mon, 22 Mar 2021 09:14:02 +0700 Subject: [PATCH] fix model apparel --- api/latest_news/news.js | 25 +++ api/product/apparel.js | 182 +++++++++++++++++++ api/product/part.js | 0 pages-sections/carrer/carrer_details.js | 64 +++++-- pages-sections/dealers/dealers.js | 5 +- pages-sections/latest_news/news_details.js | 121 ++++++++----- pages-sections/product/apparel.js | 91 ++++++++-- pages-sections/product/apparel_details.js | 13 +- pages-sections/product/helmet.js | 272 +++++++++++++++-------------- pages-sections/product/product.js | 256 ++++++++++++++++----------- pages-sections/product/yamalube.js | 34 ++-- pages-sections/product/ygp.js | 31 ++-- pages/latestnews_details.js | 13 +- pages/product/apparel.js | 74 +++++++- pages/product/apparel_details.js | 7 +- 15 files changed, 826 insertions(+), 362 deletions(-) create mode 100644 api/product/apparel.js create mode 100644 api/product/part.js diff --git a/api/latest_news/news.js b/api/latest_news/news.js index 0e6753d..9f3c2a2 100644 --- a/api/latest_news/news.js +++ b/api/latest_news/news.js @@ -24,6 +24,30 @@ async function GetNews(token="", start = 0) { return res; } +async function GetOtherNews(token="", start = 0) { + var res = await apollo.query( + ` + query($start: Int!) { + latestNews(limit:3,start:$start) + { + id + title + description + img{ + url + } + published_at + } + } + `, + token, + { + start: start, + } + ); + return res; +} + async function GetDetailNews(id, token="") { var res = await apollo.query( ` @@ -51,4 +75,5 @@ async function GetDetailNews(id, token="") { module.exports = { GetNews: GetNews, GetDetailNews: GetDetailNews, + GetOtherNews:GetOtherNews, }; \ No newline at end of file diff --git a/api/product/apparel.js b/api/product/apparel.js new file mode 100644 index 0000000..d156fc3 --- /dev/null +++ b/api/product/apparel.js @@ -0,0 +1,182 @@ +import apollo from "../../lib/apollo.js"; + +async function GetApparel(filter, token="") { + var res = await apollo.query( + ` + query { + apparels(where: { category: "RConcept" ${(filter!="")?`name: "${filter}"`:""}}) { + id + name + price + img { + url + } + } + }`, + token + ); + return res; +} + +async function GetApparel46Asia(filter, token="") { + var res = await apollo.query( + ` + query { + apparels(where: { category: "Asia" ${(filter!="")?`name: "${filter}"`:""}}) { + id + name + price + img { + url + } + } + }`, + token + ); + return res; +} + +async function GetApparelBasic(filter, token="") { + var res = await apollo.query( + ` + query { + apparels(where: { category: "Basic" ${(filter!="")?`name: "${filter}"`:""}}) { + id + name + price + img { + url + } + } + }`, + token + ); + return res; +} + +async function GetApparelMerchandise(filter, token="") { + var res = await apollo.query( + ` + query { + apparels(where: { category: "Merchandise" ${(filter!="")?`name: "${filter}"`:""}}) { + id + name + price + img { + url + } + } + }`, + token + ); + return res; +} + +async function GetApparelMaxi(filter, token="") { + var res = await apollo.query( + ` + query { + apparels(where: { category: "Maxi" ${(filter!="")?`name: "${filter}"`:""}}) { + id + name + price + img { + url + } + } + }`, + token + ); + return res; +} + +async function GetApparelRainSuit(filter, token="") { + var res = await apollo.query( + ` + query { + apparels(where: { category: "RainSuit" ${(filter!="")?`name: "${filter}"`:""}}) { + id + name + price + img { + url + } + } + }`, + token + ); + return res; +} + +async function GetApparelMotoGP(filter, token="") { + var res = await apollo.query( + ` + query { + apparels(where: { category: "motoGP" ${(filter!="")?`name: "${filter}"`:""}}) { + id + name + price + img { + url + } + } + }`, + token + ); + return res; +} + +async function GetApparelOffRoad(filter, token="") { + var res = await apollo.query( + ` + query { + apparels(where: { category: "OffRoad" ${(filter!="")?`name: "${filter}"`:""}}) { + id + name + price + img { + url + } + } + }`, + token + ); + return res; +} + +async function GetDetailApparel(id, token="") { + var res = await apollo.query( + ` + query($input: ID!){ + apparels(where:{id:$input}) + { + id + name + description + price + part_code + img { + url + } + stock + } + } `, + token, + { + "input": id + } + ); + return res; +} + +module.exports = { + GetApparel:GetApparel, + GetApparel46Asia:GetApparel46Asia, + GetApparelBasic:GetApparelBasic, + GetApparelMerchandise:GetApparelMerchandise, + GetApparelMaxi:GetApparelMaxi, + GetApparelRainSuit:GetApparelRainSuit, + GetApparelMotoGP:GetApparelMotoGP, + GetApparelOffRoad:GetApparelOffRoad, + GetDetailApparel:GetDetailApparel, +}; \ No newline at end of file diff --git a/api/product/part.js b/api/product/part.js new file mode 100644 index 0000000..e69de29 diff --git a/pages-sections/carrer/carrer_details.js b/pages-sections/carrer/carrer_details.js index 98afeab..4feb2ab 100644 --- a/pages-sections/carrer/carrer_details.js +++ b/pages-sections/carrer/carrer_details.js @@ -1,24 +1,62 @@ import React from 'react'; -import { makeStyles } from "@material-ui/core/styles"; import ReactHtmlParser from "react-html-parser"; +import { makeStyles } from "@material-ui/core/styles"; +import classNames from "classnames"; +import GridContainer from "components/Grid/GridContainer.js"; +import Grid from '@material-ui/core/Grid'; +import GridItem from "components/Grid/GridItem.js"; import Card from "components/Card/Card.js"; -import CardBody from "components/Card/CardBody.js"; -import CardHeader from "components/Card/CardHeader.js"; +import Carousel from "react-slick"; +import styles from "assets/jss/nextjs-material-kit/pages/componentsSections/notificationsStyles.js"; +const useStyles = makeStyles(styles); const DataCarrer = function ({ backend, detailcarrer, ...props }) { + const classes = useStyles(); + const imageClasses = classNames( + classes.imgRaised, + classes.imgRoundedCircle, + classes.imgFluid + ); + const settings = { + dots: true, + infinite: true, + speed: 500, + slidesToShow: 1, + slidesToScroll: 1, + autoplay: true, + time: 5 + }; + const navImageClasses = classNames(classes.imgRounded, classes.imgGallery); const carrer = detailcarrer.map((data) => { return ( - -

{data.name}

- -
- First slide -
-
Masa Pendaftaran : {data.start_regis} s/d {data.until_regis}
-
{ReactHtmlParser(data.description)}
-
-
+ + +
+
+
+ + + + + First slide + + + + +
+
+
+
+ +

{data.name}

+

{data.published_at}

+
+
+

{ReactHtmlParser(data.description)}

+
+
+
); }) return ( diff --git a/pages-sections/dealers/dealers.js b/pages-sections/dealers/dealers.js index 6a0abc7..2c3f4ef 100644 --- a/pages-sections/dealers/dealers.js +++ b/pages-sections/dealers/dealers.js @@ -19,7 +19,7 @@ const DataDealer = function ({ selected, handleName, backend, dealers, ...props const Dealers = dealers.map((data) => { return (
- +
{data.name}
@@ -59,8 +59,7 @@ const DataDealer = function ({ selected, handleName, backend, dealers, ...props onChange={values => handleName(values)} />

- - {Dealers} + {Dealers}
diff --git a/pages-sections/latest_news/news_details.js b/pages-sections/latest_news/news_details.js index cd751c1..aa2655d 100644 --- a/pages-sections/latest_news/news_details.js +++ b/pages-sections/latest_news/news_details.js @@ -1,62 +1,93 @@ import React, { useState, useEffect } from "react"; -import Router, { withRouter } from "next/router"; import ReactHtmlParser from "react-html-parser"; // @material-ui/core components import { makeStyles } from "@material-ui/core/styles"; import ReactPaginate from "react-paginate"; +import classNames from "classnames"; +import GridContainer from "components/Grid/GridContainer.js"; +import Grid from '@material-ui/core/Grid'; +import GridItem from "components/Grid/GridItem.js"; +import Card from "components/Card/Card.js"; +import Carousel from "react-slick"; +import CardBody from "components/Card/CardBody.js"; +import Button from "components/CustomButtons/Button.js"; +import Icon from "@material-ui/core/Icon"; import styles from "assets/jss/nextjs-material-kit/pages/componentsSections/notificationsStyles.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 DataLatestNews = function ({ backend, news, othernews,...props }) { const classes = useStyles(); + const imageClasses = classNames( + classes.imgRaised, + classes.imgRoundedCircle, + classes.imgFluid + ); + const settings = { + dots: true, + infinite: true, + speed: 500, + slidesToShow: 1, + slidesToScroll: 1, + autoplay: true, + time: 5 + }; + const navImageClasses = classNames(classes.imgRounded, classes.imgGallery); + const otherlatnews = othernews.map((data) => { + return ( + + + + +

{data.title}

+ +
+
+
+ ); + }) const latnews = news.map((data) => { return ( -
-
-

{data.title}

-
-

-

-
- First slide -
-

- {data.published_at} + + + +
+
+
+ + + + + First slide + + +
+
+

Other Latest News

+

{otherlatnews}

+
+
+
+
+
+
+
+ +

{data.title}

+

{data.published_at}

+
+
+

{ReactHtmlParser(data.description)}

-
-

-
{ReactHtmlParser(data.description)}
-
+ + ); }); return
{latnews}
; diff --git a/pages-sections/product/apparel.js b/pages-sections/product/apparel.js index cb4fc0e..53f4383 100644 --- a/pages-sections/product/apparel.js +++ b/pages-sections/product/apparel.js @@ -9,10 +9,11 @@ import styles from "assets/jss/nextjs-material-kit/pages/componentsSections/noti import Card from "components/Card/Card.js"; import CardBody from "components/Card/CardBody.js"; import GridContainer from "components/Grid/GridContainer.js"; +import SnackbarContent from "components/Snackbar/SnackbarContent.js"; const useStyles = makeStyles(styles); -const DataApparel = function ({ selected, handleName, backend, apparel, ...props }) { +const DataApparel = function ({ selected, handleName, backend, apparel, asia, basic, merchand, maxi, rainsuit, motogp, offroad, ...props }) { const classes = useStyles(); const { ...rest } = props; const imageClasses = classNames( @@ -21,18 +22,49 @@ const DataApparel = function ({ selected, handleName, backend, apparel, ...props classes.imgFluid ); const navImageClasses = classNames(classes.imgRounded, classes.imgGallery); - const ProductApparel = apparel.map((data) => { - return ( -
+ const ProductApparelRCon = apparel.map((data) => { + return ( +
+ + +
+ ... +
+
{data.name}
+
Rp.{data.price}
+ +
+
+
+
+
+ ); + }) + const ProductApparelAsia = asia.map((data) => { + return ( +
+ + +
...
-

{data.name}

-

Rp.{data.price}

+
{data.name}
+
Rp.{data.price}
+
+
+
); }) return (
- + -
+

Yamaha Apparel