You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

116 regels
3.4 KiB

  1. import React from "react";
  2. // nodejs library that concatenates classes
  3. import classNames from "classnames";
  4. // react components for routing our app without refresh
  5. import Link from "next/link";
  6. // @material-ui/core components
  7. import { makeStyles } from "@material-ui/core/styles";
  8. // @material-ui/icons
  9. // core components
  10. import Header from "components/Header/Header.js";
  11. import HeaderLinks from "components/Header/HeaderLinks.js";
  12. import Footer from "components/Footer/Footer.js";
  13. import GridContainer from "components/Grid/GridContainer.js";
  14. import GridItem from "components/Grid/GridItem.js";
  15. import DataProduct from "pages-sections/product/product.js";
  16. import Parallax from "components/Parallax/Parallax.js";
  17. import styles from "assets/jss/nextjs-material-kit/pages/components.js";
  18. import Getproduct from "../api/product/product.js"
  19. const useStyles = makeStyles(styles);
  20. const Product = function ({ backend, yamaha, suzuki, honda, hino, mercedes, bpr, emilia, homes, ...props }) {
  21. const classes = useStyles();
  22. const { ...rest } = props;
  23. return (
  24. <div>
  25. <Header
  26. rightLinks={<HeaderLinks/>}
  27. fixed
  28. color="info"
  29. changeColorOnScroll={{
  30. height: 400,
  31. color: "white"
  32. }}
  33. {...rest}
  34. />
  35. <Parallax image={require("assets/img/Promotion_2-1.jpg")} width="200px">
  36. <div className={classes.container}>
  37. <GridContainer>
  38. <GridItem>
  39. {/* <div className={classes.brand}>
  40. <h1 className={classes.title}>NextJS Material Kit.</h1>
  41. <h3 className={classes.subtitle}>
  42. A Badass Material Kit based on Material-UI and NextJS.
  43. </h3>
  44. </div> */}
  45. </GridItem>
  46. </GridContainer>
  47. </div>
  48. </Parallax>
  49. <div className={classNames(classes.main, classes.mainRaised)}>
  50. <DataProduct yamaha={yamaha} suzuki={suzuki} honda={honda} hino={hino} mercedes={mercedes} bpr={bpr} emilia={emilia} homes={homes} backend={backend}/>
  51. </div>
  52. <Footer />
  53. </div>
  54. );
  55. }
  56. export default Product;
  57. export async function getServerSideProps(context) {
  58. var yamaha = [];
  59. var suzuki = [];
  60. var honda = [];
  61. var hino = [];
  62. var mercedes = [];
  63. var bpr = [];
  64. var emilia = [];
  65. var homes = [];
  66. const backend = process.env.BACKEND_SERVER_URI;
  67. var res = await Getproduct.GetProductYamaha();
  68. if (res["STATUS"] === 1) {
  69. yamaha = res["DATA"]["products"];
  70. }
  71. var res = await Getproduct.GetProductSuzuki();
  72. if (res["STATUS"] === 1) {
  73. suzuki = res["DATA"]["products"];
  74. }
  75. var res = await Getproduct.GetProductHonda();
  76. if (res["STATUS"] === 1) {
  77. honda = res["DATA"]["products"];
  78. }
  79. var res = await Getproduct.GetProductHino();
  80. if (res["STATUS"] === 1) {
  81. hino = res["DATA"]["products"];
  82. }
  83. var res = await Getproduct.GetProductMercedes();
  84. if (res["STATUS"] === 1) {
  85. mercedes = res["DATA"]["products"];
  86. }
  87. var res = await Getproduct.GetProductBPR();
  88. if (res["STATUS"] === 1) {
  89. bpr = res["DATA"]["products"];
  90. }
  91. var res = await Getproduct.GetProductEmilia();
  92. if (res["STATUS"] === 1) {
  93. emilia = res["DATA"]["products"];
  94. }
  95. var res = await Getproduct.GetProductHomes();
  96. if (res["STATUS"] === 1) {
  97. homes = res["DATA"]["products"];
  98. }
  99. return {
  100. props: { yamaha, suzuki, honda, hino, mercedes, bpr, emilia, homes, backend }, // will be passed to the page component as props
  101. };
  102. }