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

import Header from "components/Header/Header.js";
import HeaderLinks from "components/Header/HeaderLinks.js";
import Footer from "components/Footer/Footer.js";
import AccessoriesDetail from "pages-sections/product/accessories_details.js";
import Parallax from "components/Parallax/Parallax.js";
import styles from "assets/jss/nextjs-material-kit/pages/components.js";
import GetDetailAccessories from "../../api/product/accessories.js"

const useStyles = makeStyles(styles);

const AccessoriesDetails = function ({ backend, detailaccessories, ...props })  {
    const classes = useStyles();
    const { ...rest } = props;
    return (
        <div>
        <Header
            rightLinks={<HeaderLinks/>}
            fixed
            color="info"
            changeColorOnScroll={{
            height: 400,
            color: "white"
            }}
            {...rest}
        />
        <Parallax image={require("assets/img/yamalube.jpg")} width="200px"/>
        <div className={classNames(classes.main, classes.mainRaised)}>
            <AccessoriesDetail detailaccessories={detailaccessories} backend={backend}/>  
        </div>
        <Footer />
        </div>
    );
}

export default AccessoriesDetails;

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

	var res = await GetDetailAccessories.GetDetailAccessories(query.s||0);
	if (res["STATUS"] === 1) {
		detailaccessories = res["DATA"]["accessories"];
	}
    console.log(detailaccessories);

	return {
		props: { detailaccessories, backend }, // will be passed to the page component as props
	};
}