import React from "react";
import classNames from "classnames";
import { makeStyles } from "@material-ui/core/styles";

import Header from "components/Header/Header.js";
import HeaderHonda from "components/Header/HeaderHonda.js";
import FooterHonda from "components/Footer/FooterHonda.js";
import Parallax from "components/Parallax/Parallax.js";
import styles from "assets/jss/nextjs-material-kit/pages/components.js";

import GetLatestNews from "api/latest_news/news.js"
import DataSnackbarContent from "pages-sections/suzuki/snackbar.js";
import DataLatestNews from "pages-sections/honda/latest_news/news.js";

const useStyles = makeStyles(styles);

const LatestNews = function ({ backend, news, ...props }) {
    const classes = useStyles();
    const { ...rest } = props;
    <DataLatestNews news={props.news}/>
    return (
        <div>
        <Header
            rightLinks={<HeaderHonda />}
            fixed
            color="info"
            changeColorOnScroll={{
            height: 400,
            color: "white"
            }}
            {...rest}
        />
        <Parallax image={require("assets/img/honda.jpg")} width="200px"/>
        <div className={classNames(classes.main, classes.mainRaised)}>
            <DataLatestNews news={news} backend={backend}/> 
        </div>
        <FooterHonda />
        </div>
    );
}

export default LatestNews;

export async function getServerSideProps(context) {
	var news = [];
    const backend = process.env.BACKEND_SERVER_URI;

	var res = await GetLatestNews.GetNewsHonda();
	if (res["STATUS"] === 1) {
		news = res["DATA"]["latestNews"];
	}
	return {
		props: { news, backend }, // will be passed to the page component as props
	};
}