@@ -2,7 +2,9 @@ import React from 'react'; | |||||
import Link from 'next/link'; | import Link from 'next/link'; | ||||
import * as Icon from 'react-feather'; | import * as Icon from 'react-feather'; | ||||
// import FaWhatsapp from "react-icons/fa"; | |||||
import { FaWhatsapp } from "react-icons/fa"; | |||||
import { FaRegEnvelope } from "react-icons/fa"; | |||||
import { FaPhoneAlt } from "react-icons/fa"; | |||||
const Sales = function ({ backend, sales, ...props }) { | const Sales = function ({ backend, sales, ...props }) { | ||||
@@ -27,13 +29,13 @@ const Sales = function ({ backend, sales, ...props }) { | |||||
</div> | </div> | ||||
<div align="center" style={{ marginTop: "-30px" }}> | <div align="center" style={{ marginTop: "-30px" }}> | ||||
<Link href={`tel:${data.telp}`}> | <Link href={`tel:${data.telp}`}> | ||||
<a style={{ padding: "20px" }} className="btn btn-primary"><i class="fas fa-camera"/> Call Us</a> | |||||
<a style={{ padding: "20px" }} className="btn btn-primary"><FaPhoneAlt /> Call Us</a> | |||||
</Link> | </Link> | ||||
<Link href={`mailto:${data.email}`}> | <Link href={`mailto:${data.email}`}> | ||||
<a style={{ padding: "20px" }} className="btn btn-primary"><Icon.Mail /> Email Us</a> | |||||
<a style={{ padding: "20px" }} className="btn btn-primary"><FaRegEnvelope /> Email Us</a> | |||||
</Link> | </Link> | ||||
<Link href={`https://wa.me/62${data.wa}`}> | <Link href={`https://wa.me/62${data.wa}`}> | ||||
<a style={{ padding: "20px" }} className="btn btn-primary"><Icon.Phone /> WA Us</a> | |||||
<a style={{ padding: "20px" }} className="btn btn-primary"><FaWhatsapp /> WA Us</a> | |||||
</Link> | </Link> | ||||
</div><br /> | </div><br /> | ||||
</div> | </div> | ||||
@@ -0,0 +1,68 @@ | |||||
import React from 'react'; | |||||
import Link from 'next/link'; | |||||
import * as Icon from 'react-feather'; | |||||
const Login = function ({ backend, dealers, ...props }) { | |||||
return ( | |||||
<div className="ptb-80" style={{ marginTop: "-50px" }}> | |||||
<div className="container"> | |||||
<div className="auth-form"> | |||||
<div className="auth-head"> | |||||
<img src="/images/Home/businees/ThamrinBrothers.png" width="300px" alt="logo" /> | |||||
<br /><br /> | |||||
<p>Tidak Punya Akun ? Silahkan <Link href="/yamaha/Register">Register</Link></p> | |||||
</div> | |||||
<form onSubmit={submitHandler}> | |||||
<div className="mb-3"> | |||||
<label className="form-label">Email</label> | |||||
<input type="email" className="form-control" id="email" | |||||
inputProps={{ | |||||
type: "email", | |||||
name: "email", | |||||
onChange: (event) => setEmail(event.target.value), | |||||
}} | |||||
/> | |||||
</div> | |||||
<div className="mb-3"> | |||||
<label className="form-label">Password</label> | |||||
<input type="password" className="form-control" id="pass" | |||||
inputProps={{ | |||||
name: "pass", | |||||
onChange: (event) => setPass(event.target.value), | |||||
type: "password", | |||||
autoComplete: "off", | |||||
}} | |||||
/> | |||||
</div> | |||||
<div className="mb-3"> | |||||
<p><Link href="/yamaha/ForgotPassword"><a>Lupa Password</a></Link></p> | |||||
</div> | |||||
<button type="submit" href="/yamaha" className="btn btn-primary">Login</button> | |||||
</form> | |||||
<div className="foot"> | |||||
<p>or connect with</p> | |||||
<ul> | |||||
<li> | |||||
<a href="#" target="_blank"> | |||||
<Icon.Mail /> | |||||
</a> | |||||
</li> | |||||
<li> | |||||
<a href="#" target="_blank"> | |||||
<Icon.Facebook /> | |||||
</a> | |||||
</li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
); | |||||
} | |||||
export default Login; |
@@ -1,7 +1,17 @@ | |||||
import React from 'react'; | import React from 'react'; | ||||
import * as Icon from 'react-feather'; | import * as Icon from 'react-feather'; | ||||
const CheckoutContent = () => { | |||||
//library yarn | |||||
import NumberFormat from 'react-number-format'; | |||||
const CheckoutContent = function ({ backend, checkout_product, ...props }) { | |||||
// const Checkout = checkout_product.map((data) => { | |||||
// return ( | |||||
// ) | |||||
// }) | |||||
return ( | return ( | ||||
<> | <> | ||||
<div className="checkout-area ptb-80"> | <div className="checkout-area ptb-80"> | ||||
@@ -25,7 +35,7 @@ const CheckoutContent = () => { | |||||
<div className="col-lg-12 col-md-12"> | <div className="col-lg-12 col-md-12"> | ||||
<div className="form-group"> | <div className="form-group"> | ||||
<label>Country <span className="required">*</span></label> | <label>Country <span className="required">*</span></label> | ||||
<div className="select-box"> | <div className="select-box"> | ||||
<select className="form-select"> | <select className="form-select"> | ||||
<option value="1">United Arab Emirates</option> | <option value="1">United Arab Emirates</option> | ||||
@@ -139,60 +149,31 @@ const CheckoutContent = () => { | |||||
</thead> | </thead> | ||||
<tbody> | <tbody> | ||||
<tr> | |||||
<td className="product-name"> | |||||
<a href="#">Smart Watch</a> | |||||
</td> | |||||
<td className="product-total"> | |||||
<span className="subtotal-amount">$30.00</span> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td className="product-name"> | |||||
<a href="#">TV</a> | |||||
</td> | |||||
<td className="product-total"> | |||||
<span className="subtotal-amount">$30.00</span> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td className="product-name"> | |||||
<a href="#">Book</a> | |||||
</td> | |||||
<td className="product-total"> | |||||
<span className="subtotal-amount">$30.00</span> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td className="product-name"> | |||||
<a href="#">Smart Watch</a> | |||||
</td> | |||||
<td className="product-total"> | |||||
<span className="subtotal-amount">$30.00</span> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td className="product-name"> | |||||
<a href="#">TV</a> | |||||
</td> | |||||
{checkout_product.length ? checkout_product.map(data => ( | |||||
<tr key={data.id}> | |||||
<td className="product-name"> | |||||
<a href="#">{data.product_name}</a> | |||||
</td> | |||||
<td className="product-total"> | |||||
<span className="subtotal-amount"> | |||||
<NumberFormat | |||||
name="product_total" | |||||
value={data.product_total} | |||||
displayType={'text'} thousandSeparator={true} | |||||
prefix={'Rp. '} | |||||
/> | |||||
</span> | |||||
</td> | |||||
</tr> | |||||
)) : ( | |||||
<tr> | |||||
<td colSpan="5" className="text-center">Tidak Ada Product di Keranjang</td> | |||||
</tr> | |||||
)} | |||||
<td className="product-total"> | |||||
<span className="subtotal-amount">$30.00</span> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td className="product-name"> | |||||
<a href="#">Book</a> | |||||
</td> | |||||
<td className="product-total"> | |||||
<span className="subtotal-amount">$30.00</span> | |||||
</td> | |||||
</tr> | |||||
</tbody> | |||||
<tbody> | |||||
<tr> | <tr> | ||||
<td className="order-subtotal"> | <td className="order-subtotal"> | ||||
<span>Cart Subtotal</span> | <span>Cart Subtotal</span> | ||||
@@ -224,7 +205,7 @@ const CheckoutContent = () => { | |||||
</table> | </table> | ||||
</div> | </div> | ||||
<div className="payment-method"> | |||||
{/* <div className="payment-method"> | |||||
<p> | <p> | ||||
<input type="radio" id="direct-bank-transfer" name="radio-group" defaultChecked /> | <input type="radio" id="direct-bank-transfer" name="radio-group" defaultChecked /> | ||||
<label htmlFor="direct-bank-transfer">Direct Bank Transfer</label> | <label htmlFor="direct-bank-transfer">Direct Bank Transfer</label> | ||||
@@ -239,9 +220,9 @@ const CheckoutContent = () => { | |||||
<input type="radio" id="cash-on-delivery" name="radio-group" /> | <input type="radio" id="cash-on-delivery" name="radio-group" /> | ||||
<label htmlFor="cash-on-delivery">Cash on Delivery</label> | <label htmlFor="cash-on-delivery">Cash on Delivery</label> | ||||
</p> | </p> | ||||
</div> | |||||
</div> */} | |||||
<a href="#" className="btn btn-primary order-btn">Place Order</a> | |||||
<a href="#" className="btn btn-primary order-btn">Lanjutkan Pembayaran</a> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
@@ -117,15 +117,18 @@ export default function NavbarYamaha({ username, ...props }) { | |||||
<a onClick={toggleNavbar} className="nav-link">Contact</a> | <a onClick={toggleNavbar} className="nav-link">Contact</a> | ||||
</Link> | </Link> | ||||
</li> | </li> | ||||
<li className="nav-item"> | |||||
<Link href="/yamaha/Shop/Cart"> | |||||
<a className="cart-wrapper-btn"> | |||||
<Icon.ShoppingCart /> | |||||
</a> | |||||
</Link> | |||||
</li> | |||||
</ul> | </ul> | ||||
</div> | </div> | ||||
<div className="others-option"> | <div className="others-option"> | ||||
<Link href="/yamaha/Shop/Cart"> | |||||
<a className="cart-wrapper-btn"> | |||||
<Icon.ShoppingCart /> | |||||
</a> | |||||
</Link> | |||||
<Link href="/yamaha/login"> | <Link href="/yamaha/login"> | ||||
{!username || username == "" ? ( | {!username || username == "" ? ( | ||||
@@ -133,33 +136,55 @@ export default function NavbarYamaha({ username, ...props }) { | |||||
<a className="btn btn-primary">Login</a> | <a className="btn btn-primary">Login</a> | ||||
</Link> | </Link> | ||||
) : ( | ) : ( | ||||
<li className="nav-item"> | |||||
<Link href="#"> | |||||
<a onClick={e => e.preventDefault()} className="nav-link"> | |||||
Product <Icon.ChevronDown /> | |||||
</a> | |||||
</Link> | |||||
<ul className="dropdown-menu"> | |||||
<li className="nav-item"> | |||||
<Link href="/yamaha/Product/Motor" activeClassName="active"> | |||||
<a onClick={toggleNavbar} className="nav-link">Motor Product</a> | |||||
</Link> | |||||
</li> | |||||
<li className="nav-item"> | |||||
<Link href="/yamaha/Product/Sparepart" activeClassName="active"> | |||||
<a onClick={toggleNavbar} className="nav-link">Sparepart Product</a> | |||||
</Link> | |||||
</li> | |||||
<li className="nav-item"> | |||||
<Link href="https://booking.thamrin.co.id/" activeClassName="active"> | |||||
<a target="_blank" onClick={toggleNavbar} className="nav-link">Service Product</a> | |||||
</Link> | |||||
</li> | |||||
</ul> | |||||
</li> | |||||
<ul className="navbar-nav ms-auto"> | |||||
<li className="nav-item"> | |||||
<Link href="#"> | |||||
<a onClick={e => e.preventDefault()} className="nav-link" > | |||||
{username} <Icon.ChevronDown /> | |||||
</a> | |||||
</Link> | |||||
<ul className="dropdown-menu"> | |||||
<li className="nav-item"> | |||||
<Link href="/yamaha/Product/Motor" activeClassName="active"> | |||||
<a onClick={toggleNavbar} className="nav-link">Profile</a> | |||||
</Link> | |||||
</li> | |||||
<li className="nav-item"> | |||||
<Link href="/yamaha/Product/Sparepart" activeClassName="active"> | |||||
<a onClick={toggleNavbar} className="nav-link">Pesanan Saya</a> | |||||
</Link> | |||||
</li> | |||||
<li className="nav-item"> | |||||
<div | |||||
onClick={async (e) => { | |||||
e.preventDefault(); | |||||
fetch("/api/auth/logout", { | |||||
method: "POST", | |||||
headers: { | |||||
"Content-Type": "application/json", | |||||
}, | |||||
body: JSON.stringify({ p: "YAMAHA" }), | |||||
}).then((res) => { | |||||
//if (res.ok) { | |||||
window.location.href = "../yamaha"; | |||||
/*} | |||||
else{ | |||||
}*/ | |||||
}); | |||||
}} | |||||
> | |||||
<Link href="https://booking.thamrin.co.id/" activeClassName="active"> | |||||
<a target="_blank" onClick={toggleNavbar} className="nav-link">Logout</a> | |||||
</Link> | |||||
</div> | |||||
</li> | |||||
</ul> | |||||
</li> | |||||
</ul> | |||||
// <CustomDropdown | // <CustomDropdown | ||||
// noLiPadding | // noLiPadding | ||||
// navDropdown | // navDropdown | ||||
@@ -6,10 +6,12 @@ import AboutUS from '@/components/Yamaha/AboutUs/AboutUs'; | |||||
import GetLatestNews from "api/latest_news/news.js" | import GetLatestNews from "api/latest_news/news.js" | ||||
const News = function ({ backend, news, othernews, ...props }) { | |||||
import Cookies from "cookies"; | |||||
const News = function ({ backend, news, othernews, user, ...props }) { | |||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<PageBanner pageTitle="About Us" /> | <PageBanner pageTitle="About Us" /> | ||||
@@ -32,12 +34,27 @@ export async function getServerSideProps(context) { | |||||
news = res["DATA"]["latestNews"]; | news = res["DATA"]["latestNews"]; | ||||
} | } | ||||
var { req, resp } = context; | |||||
const cookies = new Cookies(req, resp); | |||||
var user = ""; | |||||
var userObj = (await cookies.get("user")) | |||||
? JSON.parse(await cookies.get("user")) | |||||
: null; | |||||
if (userObj) { | |||||
let sessionId = userObj["partners_login_states"].filter(function (i) { | |||||
return ( | |||||
i.business_partner && i.business_partner.name.toUpperCase() == "YAMAHA" | |||||
); | |||||
}); | |||||
if (sessionId.length != 0) user = userObj["username"]; | |||||
} | |||||
var res = await GetLatestNews.GetOtherNewsYamaha(); | var res = await GetLatestNews.GetOtherNewsYamaha(); | ||||
if (res["STATUS"] === 1) { | if (res["STATUS"] === 1) { | ||||
othernews = res["DATA"]["latestNews"]; | othernews = res["DATA"]["latestNews"]; | ||||
} | } | ||||
return { | return { | ||||
props: { news, othernews, backend }, // will be passed to the page component as props | |||||
props: { news, othernews, backend, user }, // will be passed to the page component as props | |||||
}; | }; | ||||
} | } |
@@ -4,10 +4,12 @@ import Footer from "@/components/_App/FooterYamaha"; | |||||
import PageBanner from '@/components/Common/PageBanner'; | import PageBanner from '@/components/Common/PageBanner'; | ||||
import ContactUs from '@/components/Yamaha/ContactUs/ContactUs'; | import ContactUs from '@/components/Yamaha/ContactUs/ContactUs'; | ||||
const Contact = () => { | |||||
import Cookies from "cookies"; | |||||
const Contact = function ({ user, ...props }) { | |||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<PageBanner pageTitle="Contact Us" /> | <PageBanner pageTitle="Contact Us" /> | ||||
@@ -18,4 +20,26 @@ const Contact = () => { | |||||
) | ) | ||||
} | } | ||||
export async function getServerSideProps(context) { | |||||
var { req, resp } = context; | |||||
const cookies = new Cookies(req, resp); | |||||
var user = ""; | |||||
var userObj = (await cookies.get("user")) | |||||
? JSON.parse(await cookies.get("user")) | |||||
: null; | |||||
if (userObj) { | |||||
let sessionId = userObj["partners_login_states"].filter(function (i) { | |||||
return ( | |||||
i.business_partner && i.business_partner.name.toUpperCase() == "YAMAHA" | |||||
); | |||||
}); | |||||
if (sessionId.length != 0) user = userObj["username"]; | |||||
} | |||||
return { | |||||
props: { user }, // will be passed to the page component as props | |||||
}; | |||||
} | |||||
export default Contact; | export default Contact; |
@@ -6,10 +6,12 @@ import LatestNewsDetail from '@/components/Yamaha/LatestNews/LatestNewsDetail'; | |||||
import GetLatestNews from "api/latest_news/news.js" | import GetLatestNews from "api/latest_news/news.js" | ||||
const NewsDetail = function ({ backend, news, othernews, ...props }) { | |||||
import Cookies from "cookies"; | |||||
const NewsDetail = function ({ backend, news, othernews, user, ...props }) { | |||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<LatestNewsDetail news={news} othernews={othernews} backend={backend} /> | <LatestNewsDetail news={news} othernews={othernews} backend={backend} /> | ||||
@@ -26,6 +28,21 @@ export async function getServerSideProps(context) { | |||||
var othernews = []; | var othernews = []; | ||||
const backend = process.env.BACKEND_SERVER_URI; | const backend = process.env.BACKEND_SERVER_URI; | ||||
var { req, resp } = context; | |||||
const cookies = new Cookies(req, resp); | |||||
var user = ""; | |||||
var userObj = (await cookies.get("user")) | |||||
? JSON.parse(await cookies.get("user")) | |||||
: null; | |||||
if (userObj) { | |||||
let sessionId = userObj["partners_login_states"].filter(function (i) { | |||||
return ( | |||||
i.business_partner && i.business_partner.name.toUpperCase() == "YAMAHA" | |||||
); | |||||
}); | |||||
if (sessionId.length != 0) user = userObj["username"]; | |||||
} | |||||
var res = await GetLatestNews.GetDetailNews(query.s||0); | var res = await GetLatestNews.GetDetailNews(query.s||0); | ||||
if (res["STATUS"] === 1) { | if (res["STATUS"] === 1) { | ||||
news = res["DATA"]["latestNews"]; | news = res["DATA"]["latestNews"]; | ||||
@@ -37,6 +54,6 @@ export async function getServerSideProps(context) { | |||||
} | } | ||||
return { | return { | ||||
props: { news, othernews, backend }, // will be passed to the page component as props | |||||
props: { news, othernews, backend, user }, // will be passed to the page component as props | |||||
}; | }; | ||||
} | } |
@@ -6,10 +6,12 @@ import LatestNews from '@/components/Yamaha/LatestNews/LatestNews'; | |||||
import GetLatestNews from "api/latest_news/news.js" | import GetLatestNews from "api/latest_news/news.js" | ||||
const News = function ({ backend, news, othernews, ...props }) { | |||||
import Cookies from "cookies"; | |||||
const News = function ({ backend, news, othernews, user, ...props }) { | |||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<PageBanner pageTitle="Latest News" /> | <PageBanner pageTitle="Latest News" /> | ||||
@@ -27,6 +29,21 @@ export async function getServerSideProps(context) { | |||||
var othernews = []; | var othernews = []; | ||||
const backend = process.env.BACKEND_SERVER_URI; | const backend = process.env.BACKEND_SERVER_URI; | ||||
var { req, resp } = context; | |||||
const cookies = new Cookies(req, resp); | |||||
var user = ""; | |||||
var userObj = (await cookies.get("user")) | |||||
? JSON.parse(await cookies.get("user")) | |||||
: null; | |||||
if (userObj) { | |||||
let sessionId = userObj["partners_login_states"].filter(function (i) { | |||||
return ( | |||||
i.business_partner && i.business_partner.name.toUpperCase() == "YAMAHA" | |||||
); | |||||
}); | |||||
if (sessionId.length != 0) user = userObj["username"]; | |||||
} | |||||
var res = await GetLatestNews.GetNewsYamaha(); | var res = await GetLatestNews.GetNewsYamaha(); | ||||
if (res["STATUS"] === 1) { | if (res["STATUS"] === 1) { | ||||
news = res["DATA"]["latestNews"]; | news = res["DATA"]["latestNews"]; | ||||
@@ -38,6 +55,6 @@ export async function getServerSideProps(context) { | |||||
} | } | ||||
return { | return { | ||||
props: { news, othernews, backend }, // will be passed to the page component as props | |||||
props: { news, othernews, backend, user }, // will be passed to the page component as props | |||||
}; | }; | ||||
} | } |
@@ -10,7 +10,7 @@ import Cookies from "cookies"; | |||||
const Shop = function ({ detailaccessories, backend, user, ...props }) { | const Shop = function ({ detailaccessories, backend, user, ...props }) { | ||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<ProductCard detailaccessories={detailaccessories} backend={backend} user={user} /> | <ProductCard detailaccessories={detailaccessories} backend={backend} user={user} /> | ||||
@@ -10,7 +10,7 @@ import Cookies from "cookies"; | |||||
const Shop = function ({ detailapparel, backend, user, ...props }) { | const Shop = function ({ detailapparel, backend, user, ...props }) { | ||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<ProductCard detailapparel={detailapparel} backend={backend} user={user} /> | <ProductCard detailapparel={detailapparel} backend={backend} user={user} /> | ||||
@@ -10,7 +10,7 @@ import Cookies from "cookies"; | |||||
const Shop = function ({ detailhelmet, backend, user, ...props }) { | const Shop = function ({ detailhelmet, backend, user, ...props }) { | ||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<ProductCard detailhelmet={detailhelmet} backend={backend} user={user} /> | <ProductCard detailhelmet={detailhelmet} backend={backend} user={user} /> | ||||
@@ -11,7 +11,7 @@ import Cookies from "cookies"; | |||||
const Shop = function ({ product, backend, user, ...props }) { | const Shop = function ({ product, backend, user, ...props }) { | ||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<PageBanner pageTitle="Products" /> | <PageBanner pageTitle="Products" /> | ||||
@@ -10,7 +10,7 @@ import Cookies from "cookies"; | |||||
const Shop = function ({ detailproduct, backend, user, ...props }) { | const Shop = function ({ detailproduct, backend, user, ...props }) { | ||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<ProductCard detailproduct={detailproduct} backend={backend} user={user}/> | <ProductCard detailproduct={detailproduct} backend={backend} user={user}/> | ||||
@@ -8,10 +8,10 @@ import GetSparepart from "api/sparepart/sparepart.js"; | |||||
import Cookies from "cookies"; | import Cookies from "cookies"; | ||||
const Shop = function ({ ygp, yamalube, helmet, apparel, accessories, backend, ...props }) { | |||||
const Shop = function ({ ygp, yamalube, helmet, apparel, accessories, backend, user, ...props }) { | |||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<PageBanner pageTitle="Sparepart" /> | <PageBanner pageTitle="Sparepart" /> | ||||
@@ -40,6 +40,21 @@ export async function getServerSideProps(context) { | |||||
const backend = process.env.BACKEND_SERVER_URI; | const backend = process.env.BACKEND_SERVER_URI; | ||||
var { req, resp } = context; | |||||
const cookies = new Cookies(req, resp); | |||||
var user = ""; | |||||
var userObj = (await cookies.get("user")) | |||||
? JSON.parse(await cookies.get("user")) | |||||
: null; | |||||
if (userObj) { | |||||
let sessionId = userObj["partners_login_states"].filter(function (i) { | |||||
return ( | |||||
i.business_partner && i.business_partner.name.toUpperCase() == "YAMAHA" | |||||
); | |||||
}); | |||||
if (sessionId.length != 0) user = userObj["username"]; | |||||
} | |||||
var res = await GetSparepart.GetSparepartYGP(); | var res = await GetSparepart.GetSparepartYGP(); | ||||
if (res["STATUS"] === 1) { | if (res["STATUS"] === 1) { | ||||
ygp = res["DATA"]["ygParts"]; | ygp = res["DATA"]["ygParts"]; | ||||
@@ -73,6 +88,7 @@ export async function getServerSideProps(context) { | |||||
apparel, | apparel, | ||||
accessories, | accessories, | ||||
backend, | backend, | ||||
user, | |||||
}, // will be passed to the page component as props | }, // will be passed to the page component as props | ||||
}; | }; | ||||
} | } |
@@ -10,7 +10,7 @@ import Cookies from "cookies"; | |||||
const Shop = function ({ detailyamalube, backend, user, ...props }) { | const Shop = function ({ detailyamalube, backend, user, ...props }) { | ||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<ProductCard detailyamalube={detailyamalube} backend={backend} user={user} /> | <ProductCard detailyamalube={detailyamalube} backend={backend} user={user} /> | ||||
@@ -10,7 +10,7 @@ import Cookies from "cookies"; | |||||
const Shop = function ({ detailygp, backend, user, ...props }) { | const Shop = function ({ detailygp, backend, user, ...props }) { | ||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<ProductCard detailygp={detailygp} backend={backend} user={user} /> | <ProductCard detailygp={detailygp} backend={backend} user={user} /> | ||||
@@ -26,9 +26,7 @@ export async function getServerSideProps(context) { | |||||
var detailygp = []; | var detailygp = []; | ||||
const backend = process.env.BACKEND_SERVER_URI; | const backend = process.env.BACKEND_SERVER_URI; | ||||
console.log("backend :", backend); | |||||
var { req, resp } = context; | var { req, resp } = context; | ||||
const cookies = new Cookies(req, resp); | const cookies = new Cookies(req, resp); | ||||
var user = ""; | var user = ""; | ||||
@@ -5,12 +5,13 @@ import PageBanner from '@/components/Common/PageBanner' | |||||
import CartContent from '@/components/Yamaha/Shop/Cart' | import CartContent from '@/components/Yamaha/Shop/Cart' | ||||
import GetproductCart from 'api/shop/cart'; | import GetproductCart from 'api/shop/cart'; | ||||
import Cookies from "cookies"; | import Cookies from "cookies"; | ||||
const Cart = function ({ cart_product, backend, ...props }) { | |||||
const Cart = function ({ cart_product, backend, user, ...props }) { | |||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<PageBanner pageTitle="Cart" /> | <PageBanner pageTitle="Cart" /> | ||||
@@ -31,16 +32,31 @@ const Cart = function ({ cart_product, backend, ...props }) { | |||||
export default Cart; | export default Cart; | ||||
export async function getServerSideProps() { | |||||
export async function getServerSideProps(context) { | |||||
var cart_product = []; | var cart_product = []; | ||||
const backend = process.env.BACKEND_SERVER_URI; | const backend = process.env.BACKEND_SERVER_URI; | ||||
var { req, resp } = context; | |||||
const cookies = new Cookies(req, resp); | |||||
var user = ""; | |||||
var userObj = (await cookies.get("user")) | |||||
? JSON.parse(await cookies.get("user")) | |||||
: null; | |||||
if (userObj) { | |||||
let sessionId = userObj["partners_login_states"].filter(function (i) { | |||||
return ( | |||||
i.business_partner && i.business_partner.name.toUpperCase() == "YAMAHA" | |||||
); | |||||
}); | |||||
if (sessionId.length != 0) user = userObj["username"]; | |||||
} | |||||
var res = await GetproductCart.GetCartProduct(); | var res = await GetproductCart.GetCartProduct(); | ||||
if (res["STATUS"] === 1) { | if (res["STATUS"] === 1) { | ||||
cart_product = res["DATA"]["carts"]; | cart_product = res["DATA"]["carts"]; | ||||
} | } | ||||
return { | return { | ||||
props: { cart_product, backend }, // will be passed to the page component as props | |||||
props: { cart_product, backend, user }, // will be passed to the page component as props | |||||
}; | }; | ||||
} | } |
@@ -7,10 +7,12 @@ import * as Icon from 'react-feather'; | |||||
import CheckoutProduct from "api/shop/checkout"; | import CheckoutProduct from "api/shop/checkout"; | ||||
const Checkout = function ({ backend, checkout_product, ...props }) { | |||||
import Cookies from "cookies"; | |||||
const Checkout = function ({ backend, checkout_product, user, ...props }) { | |||||
return ( | return ( | ||||
<> | <> | ||||
<Navbar /> | |||||
<Navbar username={user} /> | |||||
<PageBanner pageTitle="Checkout" /> | <PageBanner pageTitle="Checkout" /> | ||||
@@ -23,10 +25,25 @@ const Checkout = function ({ backend, checkout_product, ...props }) { | |||||
export default Checkout; | export default Checkout; | ||||
export async function getServerSideProps() { | |||||
export async function getServerSideProps(context) { | |||||
var checkout_product = []; | var checkout_product = []; | ||||
const backend = process.env.BACKEND_SERVER_URI; | const backend = process.env.BACKEND_SERVER_URI; | ||||
var { req, resp } = context; | |||||
const cookies = new Cookies(req, resp); | |||||
var user = ""; | |||||
var userObj = (await cookies.get("user")) | |||||
? JSON.parse(await cookies.get("user")) | |||||
: null; | |||||
if (userObj) { | |||||
let sessionId = userObj["partners_login_states"].filter(function (i) { | |||||
return ( | |||||
i.business_partner && i.business_partner.name.toUpperCase() == "YAMAHA" | |||||
); | |||||
}); | |||||
if (sessionId.length != 0) user = userObj["username"]; | |||||
} | |||||
var res = await CheckoutProduct.GetCheckoutproduct(); | var res = await CheckoutProduct.GetCheckoutproduct(); | ||||
if (res["STATUS"] === 1) { | if (res["STATUS"] === 1) { | ||||
checkout_product = res["DATA"]["checkouts"]; | checkout_product = res["DATA"]["checkouts"]; | ||||
@@ -34,6 +51,6 @@ export async function getServerSideProps() { | |||||
console.log(checkout_product); | console.log(checkout_product); | ||||
return { | return { | ||||
props: { checkout_product, backend }, // will be passed to the page component as props | |||||
props: { checkout_product, backend, user }, // will be passed to the page component as props | |||||
}; | }; | ||||
} | } |
@@ -21,12 +21,12 @@ const Index = function ({ | |||||
}) { | }) { | ||||
return ( | return ( | ||||
<> | <> | ||||
<NavbarYamaha /> | |||||
<NavbarYamaha username={user} /> | |||||
<MainBanner /> | <MainBanner /> | ||||
<PartnerStyleTwo /> | <PartnerStyleTwo /> | ||||
<OurServices /> | <OurServices /> | ||||
<FeatureProduct /> | <FeatureProduct /> | ||||
<Dealer dealers={dealers} backend={backend} /> | |||||
<Dealer dealers={dealers} user={user} backend={backend} /> | |||||
<Testimoni /> | <Testimoni /> | ||||
<Summary /> | <Summary /> | ||||
<Footer /> | <Footer /> | ||||