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 CarrerDetail from "pages-sections/carrer/carrer_details.js";
import Parallax from "components/Parallax/Parallax.js";
import styles from "assets/jss/nextjs-material-kit/pages/components.js";
import GetDetailcarrer from "../api/carrer/carrer.js"

const useStyles = makeStyles(styles);

const CarrerDetails = function ({ backend, detailcarrer, ...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/carrer.png")} height="50px"/>
        <div className={classNames(classes.main, classes.mainRaised)}>
            <CarrerDetail detailcarrer={detailcarrer} backend={backend}/>  
        </div>
        <Footer />
        </div>
    );
}

export default CarrerDetails;

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

	var res = await GetDetailcarrer.GetDetailCarrer(query.s||0);
	if (res["STATUS"] === 1) {
		detailcarrer = res["DATA"]["carrers"];
	}

    console.log(res);

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