|
- import React from "react";
- import Navbar from "@/components/_App/NavbarYamaha";
- import Footer from "@/components/_App/FooterYamaha";
- import PageBanner from "@/components/Common/PageBanner";
- import ProductCard from "@/components/Yamaha/Product/Motor";
-
- import Getproduct from "api/product/product.js";
-
- import Cookies from "cookies";
-
- const Shop = function ({ product, backend, user, ...props }) {
- return (
- <>
- <Navbar username={user} />
-
- <PageBanner pageTitle="Products" />
-
- <ProductCard product={product} backend={backend} user={user} />
-
- <Footer />
- </>
- );
- };
-
- export default Shop;
-
- export async function getServerSideProps(context) {
- var 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 Getproduct.GetProduct();
- if (res["STATUS"] === 1) {
- product = res["DATA"]["products"];
- }
- // console.log(res);
-
- return {
- props: {
- product,
- backend,
- user,
- }, // will be passed to the page component as props
- };
- }
|