| @@ -2,7 +2,9 @@ import React from 'react'; | |||
| import Link from 'next/link'; | |||
| 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 }) { | |||
| @@ -27,13 +29,13 @@ const Sales = function ({ backend, sales, ...props }) { | |||
| </div> | |||
| <div align="center" style={{ marginTop: "-30px" }}> | |||
| <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 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 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> | |||
| </div><br /> | |||
| </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 * 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 ( | |||
| <> | |||
| <div className="checkout-area ptb-80"> | |||
| @@ -25,7 +35,7 @@ const CheckoutContent = () => { | |||
| <div className="col-lg-12 col-md-12"> | |||
| <div className="form-group"> | |||
| <label>Country <span className="required">*</span></label> | |||
| <div className="select-box"> | |||
| <select className="form-select"> | |||
| <option value="1">United Arab Emirates</option> | |||
| @@ -139,60 +149,31 @@ const CheckoutContent = () => { | |||
| </thead> | |||
| <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> | |||
| <td className="order-subtotal"> | |||
| <span>Cart Subtotal</span> | |||
| @@ -224,7 +205,7 @@ const CheckoutContent = () => { | |||
| </table> | |||
| </div> | |||
| <div className="payment-method"> | |||
| {/* <div className="payment-method"> | |||
| <p> | |||
| <input type="radio" id="direct-bank-transfer" name="radio-group" defaultChecked /> | |||
| <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" /> | |||
| <label htmlFor="cash-on-delivery">Cash on Delivery</label> | |||
| </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> | |||
| @@ -117,15 +117,18 @@ export default function NavbarYamaha({ username, ...props }) { | |||
| <a onClick={toggleNavbar} className="nav-link">Contact</a> | |||
| </Link> | |||
| </li> | |||
| <li className="nav-item"> | |||
| <Link href="/yamaha/Shop/Cart"> | |||
| <a className="cart-wrapper-btn"> | |||
| <Icon.ShoppingCart /> | |||
| </a> | |||
| </Link> | |||
| </li> | |||
| </ul> | |||
| </div> | |||
| <div className="others-option"> | |||
| <Link href="/yamaha/Shop/Cart"> | |||
| <a className="cart-wrapper-btn"> | |||
| <Icon.ShoppingCart /> | |||
| </a> | |||
| </Link> | |||
| <Link href="/yamaha/login"> | |||
| {!username || username == "" ? ( | |||
| @@ -133,33 +136,55 @@ export default function NavbarYamaha({ username, ...props }) { | |||
| <a className="btn btn-primary">Login</a> | |||
| </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 | |||
| // noLiPadding | |||
| // navDropdown | |||
| @@ -6,10 +6,12 @@ import AboutUS from '@/components/Yamaha/AboutUs/AboutUs'; | |||
| 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 ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <PageBanner pageTitle="About Us" /> | |||
| @@ -32,12 +34,27 @@ export async function getServerSideProps(context) { | |||
| 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(); | |||
| if (res["STATUS"] === 1) { | |||
| othernews = res["DATA"]["latestNews"]; | |||
| } | |||
| 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 ContactUs from '@/components/Yamaha/ContactUs/ContactUs'; | |||
| const Contact = () => { | |||
| import Cookies from "cookies"; | |||
| const Contact = function ({ user, ...props }) { | |||
| return ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <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; | |||
| @@ -6,10 +6,12 @@ import LatestNewsDetail from '@/components/Yamaha/LatestNews/LatestNewsDetail'; | |||
| 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 ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <LatestNewsDetail news={news} othernews={othernews} backend={backend} /> | |||
| @@ -26,6 +28,21 @@ export async function getServerSideProps(context) { | |||
| var othernews = []; | |||
| 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); | |||
| if (res["STATUS"] === 1) { | |||
| news = res["DATA"]["latestNews"]; | |||
| @@ -37,6 +54,6 @@ export async function getServerSideProps(context) { | |||
| } | |||
| 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" | |||
| const News = function ({ backend, news, othernews, ...props }) { | |||
| import Cookies from "cookies"; | |||
| const News = function ({ backend, news, othernews, user, ...props }) { | |||
| return ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <PageBanner pageTitle="Latest News" /> | |||
| @@ -27,6 +29,21 @@ export async function getServerSideProps(context) { | |||
| var othernews = []; | |||
| 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(); | |||
| if (res["STATUS"] === 1) { | |||
| news = res["DATA"]["latestNews"]; | |||
| @@ -38,6 +55,6 @@ export async function getServerSideProps(context) { | |||
| } | |||
| 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 }) { | |||
| return ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <ProductCard detailaccessories={detailaccessories} backend={backend} user={user} /> | |||
| @@ -10,7 +10,7 @@ import Cookies from "cookies"; | |||
| const Shop = function ({ detailapparel, backend, user, ...props }) { | |||
| return ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <ProductCard detailapparel={detailapparel} backend={backend} user={user} /> | |||
| @@ -10,7 +10,7 @@ import Cookies from "cookies"; | |||
| const Shop = function ({ detailhelmet, backend, user, ...props }) { | |||
| return ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <ProductCard detailhelmet={detailhelmet} backend={backend} user={user} /> | |||
| @@ -11,7 +11,7 @@ import Cookies from "cookies"; | |||
| const Shop = function ({ product, backend, user, ...props }) { | |||
| return ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <PageBanner pageTitle="Products" /> | |||
| @@ -10,7 +10,7 @@ import Cookies from "cookies"; | |||
| const Shop = function ({ detailproduct, backend, user, ...props }) { | |||
| return ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <ProductCard detailproduct={detailproduct} backend={backend} user={user}/> | |||
| @@ -8,10 +8,10 @@ import GetSparepart from "api/sparepart/sparepart.js"; | |||
| 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 ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <PageBanner pageTitle="Sparepart" /> | |||
| @@ -40,6 +40,21 @@ export async function getServerSideProps(context) { | |||
| 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(); | |||
| if (res["STATUS"] === 1) { | |||
| ygp = res["DATA"]["ygParts"]; | |||
| @@ -73,6 +88,7 @@ export async function getServerSideProps(context) { | |||
| apparel, | |||
| accessories, | |||
| backend, | |||
| user, | |||
| }, // will be passed to the page component as props | |||
| }; | |||
| } | |||
| @@ -10,7 +10,7 @@ import Cookies from "cookies"; | |||
| const Shop = function ({ detailyamalube, backend, user, ...props }) { | |||
| return ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <ProductCard detailyamalube={detailyamalube} backend={backend} user={user} /> | |||
| @@ -10,7 +10,7 @@ import Cookies from "cookies"; | |||
| const Shop = function ({ detailygp, backend, user, ...props }) { | |||
| return ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <ProductCard detailygp={detailygp} backend={backend} user={user} /> | |||
| @@ -26,9 +26,7 @@ export async function getServerSideProps(context) { | |||
| var detailygp = []; | |||
| const backend = process.env.BACKEND_SERVER_URI; | |||
| console.log("backend :", backend); | |||
| var { req, resp } = context; | |||
| const cookies = new Cookies(req, resp); | |||
| var user = ""; | |||
| @@ -5,12 +5,13 @@ import PageBanner from '@/components/Common/PageBanner' | |||
| import CartContent from '@/components/Yamaha/Shop/Cart' | |||
| import GetproductCart from 'api/shop/cart'; | |||
| import Cookies from "cookies"; | |||
| const Cart = function ({ cart_product, backend, ...props }) { | |||
| const Cart = function ({ cart_product, backend, user, ...props }) { | |||
| return ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <PageBanner pageTitle="Cart" /> | |||
| @@ -31,16 +32,31 @@ const Cart = function ({ cart_product, backend, ...props }) { | |||
| export default Cart; | |||
| export async function getServerSideProps() { | |||
| export async function getServerSideProps(context) { | |||
| var cart_product = []; | |||
| 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(); | |||
| if (res["STATUS"] === 1) { | |||
| cart_product = res["DATA"]["carts"]; | |||
| } | |||
| 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"; | |||
| const Checkout = function ({ backend, checkout_product, ...props }) { | |||
| import Cookies from "cookies"; | |||
| const Checkout = function ({ backend, checkout_product, user, ...props }) { | |||
| return ( | |||
| <> | |||
| <Navbar /> | |||
| <Navbar username={user} /> | |||
| <PageBanner pageTitle="Checkout" /> | |||
| @@ -23,10 +25,25 @@ const Checkout = function ({ backend, checkout_product, ...props }) { | |||
| export default Checkout; | |||
| export async function getServerSideProps() { | |||
| export async function getServerSideProps(context) { | |||
| var checkout_product = []; | |||
| 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(); | |||
| if (res["STATUS"] === 1) { | |||
| checkout_product = res["DATA"]["checkouts"]; | |||
| @@ -34,6 +51,6 @@ export async function getServerSideProps() { | |||
| console.log(checkout_product); | |||
| 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 ( | |||
| <> | |||
| <NavbarYamaha /> | |||
| <NavbarYamaha username={user} /> | |||
| <MainBanner /> | |||
| <PartnerStyleTwo /> | |||
| <OurServices /> | |||
| <FeatureProduct /> | |||
| <Dealer dealers={dealers} backend={backend} /> | |||
| <Dealer dealers={dealers} user={user} backend={backend} /> | |||
| <Testimoni /> | |||
| <Summary /> | |||
| <Footer /> | |||