From 572b6a41796a544d40056eb9c4553c6ab753adfd Mon Sep 17 00:00:00 2001 From: yusmar Date: Mon, 5 Jul 2021 09:36:16 +0700 Subject: [PATCH] login logout --- api/dealer/dealer.js | 25 ++++++++------- api/product/product.js | 24 +++++++++++++- components/Header/HeaderLinks.js | 9 ------ pages-sections/yamaha/product/product.js | 2 +- pages-sections/yamaha/product/product_details.js | 17 ++++++---- pages/api/auth/login.js | 41 ++++++++++++++++++++++++ pages/api/auth/logout.js | 36 +++++++++++++++++++++ pages/yamaha/home.js | 2 +- pages/yamaha/product/product_detail.js | 15 ++++++--- 9 files changed, 137 insertions(+), 34 deletions(-) create mode 100644 pages/api/auth/login.js create mode 100644 pages/api/auth/logout.js diff --git a/api/dealer/dealer.js b/api/dealer/dealer.js index 0078188..349c1bc 100644 --- a/api/dealer/dealer.js +++ b/api/dealer/dealer.js @@ -24,25 +24,28 @@ async function GetDealers(filter, token="") { return res; } -async function GetHomeDealer(token="") { +async function GetHomeDealer(token="", start = 0) { var res = await apollo.query( ` - query{ - dealers{ + query($start: Int!) { + dealers(limit:6,start:$start){ id - name - kota_dealer - address - telp - email - location + name + kota_dealer + address + telp + email + location img{ url } } } `, - token + token, + { + start: start, + } ); return res; } @@ -50,4 +53,4 @@ async function GetHomeDealer(token="") { module.exports = { GetDealers: GetDealers, GetHomeDealer: GetHomeDealer, -}; \ No newline at end of file +}; diff --git a/api/product/product.js b/api/product/product.js index 058fd4d..0c25f66 100644 --- a/api/product/product.js +++ b/api/product/product.js @@ -11,7 +11,8 @@ async function GetDetailProduct(id, token = "") { price price1 price2 - product_otrs{ + product_otrs { + id name price } @@ -75,6 +76,26 @@ async function GetDetailProduct(id, token = "") { return res; } +async function GetProductImgColor(id, token = "") { + var res = await apollo.query( + ` + query($input: ID!) { + productImageColors(where:{id:$input}) { + id + name + img{ + url + } + } + } + `, + token, { + "input": id + } + ); + return res; +} + async function GetProduct(token = "") { var res = await apollo.query( ` @@ -311,6 +332,7 @@ async function GetProductHino(token = "") { module.exports = { + GetProductImgColor: GetProductImgColor, GetProduct: GetProduct, //yamaha diff --git a/components/Header/HeaderLinks.js b/components/Header/HeaderLinks.js index 259bf6c..82ff872 100644 --- a/components/Header/HeaderLinks.js +++ b/components/Header/HeaderLinks.js @@ -154,15 +154,6 @@ export default function HeaderLinks({ username, ...props }) { - - - {!username || username == "" ? (