選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

148 行
3.6 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 ({
  21. backend,
  22. yamaha,
  23. suzuki,
  24. honda,
  25. hino,
  26. mercedes,
  27. bpr,
  28. emilia,
  29. homes,
  30. ...props
  31. }) {
  32. const classes = useStyles();
  33. const { ...rest } = props;
  34. return (
  35. <div>
  36. <Header
  37. rightLinks={<HeaderLinks />}
  38. fixed
  39. color="info"
  40. changeColorOnScroll={{
  41. height: 400,
  42. color: "white",
  43. }}
  44. {...rest}
  45. />
  46. <Parallax image={require("assets/img/Promotion_2-1.jpg")} width="200px">
  47. <div className={classes.container}>
  48. <GridContainer>
  49. <GridItem>
  50. {/* <div className={classes.brand}>
  51. <h1 className={classes.title}>NextJS Material Kit.</h1>
  52. <h3 className={classes.subtitle}>
  53. A Badass Material Kit based on Material-UI and NextJS.
  54. </h3>
  55. </div> */}
  56. </GridItem>
  57. </GridContainer>
  58. </div>
  59. </Parallax>
  60. <div className={classNames(classes.main, classes.mainRaised)}>
  61. <DataProduct
  62. yamaha={yamaha}
  63. suzuki={suzuki}
  64. honda={honda}
  65. hino={hino}
  66. mercedes={mercedes}
  67. bpr={bpr}
  68. emilia={emilia}
  69. homes={homes}
  70. backend={backend}
  71. />
  72. </div>
  73. <Footer />
  74. </div>
  75. );
  76. };
  77. export default Product;
  78. export async function getServerSideProps(context) {
  79. var yamaha = [];
  80. var suzuki = [];
  81. var honda = [];
  82. var hino = [];
  83. var mercedes = [];
  84. var bpr = [];
  85. var emilia = [];
  86. var homes = [];
  87. const backend = process.env.BACKEND_SERVER_URI;
  88. var res = await Getproduct.GetProductYamaha();
  89. if (res["STATUS"] === 1) {
  90. yamaha = res["DATA"]["products"];
  91. }
  92. var res = await Getproduct.GetProductSuzuki();
  93. if (res["STATUS"] === 1) {
  94. suzuki = res["DATA"]["products"];
  95. }
  96. var res = await Getproduct.GetProductHonda();
  97. if (res["STATUS"] === 1) {
  98. honda = res["DATA"]["products"];
  99. }
  100. var res = await Getproduct.GetProductHino();
  101. if (res["STATUS"] === 1) {
  102. hino = res["DATA"]["products"];
  103. }
  104. var res = await Getproduct.GetProductMercedes();
  105. if (res["STATUS"] === 1) {
  106. mercedes = res["DATA"]["products"];
  107. }
  108. var res = await Getproduct.GetProductBPR();
  109. if (res["STATUS"] === 1) {
  110. bpr = res["DATA"]["products"];
  111. }
  112. var res = await Getproduct.GetProductEmilia();
  113. if (res["STATUS"] === 1) {
  114. emilia = res["DATA"]["products"];
  115. }
  116. var res = await Getproduct.GetProductHomes();
  117. if (res["STATUS"] === 1) {
  118. homes = res["DATA"]["products"];
  119. }
  120. return {
  121. props: {
  122. yamaha,
  123. suzuki,
  124. honda,
  125. hino,
  126. mercedes,
  127. bpr,
  128. emilia,
  129. homes,
  130. backend,
  131. }, // will be passed to the page component as props
  132. };
  133. }