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.
 
 

128 regels
2.8 KiB

  1. import React from "react";
  2. import classNames from "classnames";
  3. import { makeStyles } from "@material-ui/core/styles";
  4. import Header from "components/Header/Header.js";
  5. import HeaderLinks from "components/Header/HeaderLinks.js";
  6. import Footer from "components/Footer/Footer.js";
  7. import DataProduct from "pages-sections/product/product.js";
  8. import Parallax from "components/Parallax/Parallax.js";
  9. import styles from "assets/jss/nextjs-material-kit/pages/components.js";
  10. import Getproduct from "../api/product/product.js";
  11. const useStyles = makeStyles(styles);
  12. const Product = function ({
  13. backend,
  14. yamaha,
  15. suzuki,
  16. honda,
  17. hino,
  18. mercedes,
  19. bpr,
  20. emilia,
  21. homes,
  22. ...props
  23. }) {
  24. const classes = useStyles();
  25. const { ...rest } = props;
  26. return (
  27. <div>
  28. <Header
  29. rightLinks={<HeaderLinks />}
  30. fixed
  31. color="info"
  32. changeColorOnScroll={{
  33. height: 400,
  34. color: "white",
  35. }}
  36. {...rest}
  37. />
  38. <Parallax image={require("assets/img/Promotion_2-1.jpg")} width="200px"/>
  39. <div className={classNames(classes.main, classes.mainRaised)}>
  40. <DataProduct
  41. yamaha={yamaha}
  42. suzuki={suzuki}
  43. honda={honda}
  44. hino={hino}
  45. mercedes={mercedes}
  46. bpr={bpr}
  47. emilia={emilia}
  48. homes={homes}
  49. backend={backend}
  50. />
  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: {
  101. yamaha,
  102. suzuki,
  103. honda,
  104. hino,
  105. mercedes,
  106. bpr,
  107. emilia,
  108. homes,
  109. backend,
  110. }, // will be passed to the page component as props
  111. };
  112. }