import React, { useState, useEffect } from "react";
import classNames from "classnames";
import { makeStyles } from "@material-ui/core/styles";
import ReactHtmlParser from "react-html-parser";
import Dashboard from "@material-ui/icons/Dashboard";
import Icon from "@material-ui/core/Icon";

import GridContainer from "components/Grid/GridContainer.js";
import Grid from '@material-ui/core/Grid';
import GridItem from "components/Grid/GridItem.js";
import NavPills from "components/NavPills/NavPills.js";
import Card from "components/Card/Card.js";
import CardBody from "components/Card/CardBody.js";
import CardHeader from "components/Card/CardHeader.js";
import CardFooter from "components/Card/CardFooter.js";
import Button from "components/CustomButtons/Button.js";
import styles from "assets/jss/nextjs-material-kit/pages/profilePage.js";
import Carousel from "react-slick";

const useStyles = makeStyles(styles);

const DetailDataApparel = function ({ backend, detailapparel, ...props })  {
    const classes = useStyles();
    const { ...rest } = props;
    const imageClasses = classNames(
        classes.imgRaised,
        classes.imgRoundedCircle,
        classes.imgFluid
        );
        const settings = {
        dots: true,
        infinite: true,
        speed: 500,
        slidesToShow: 1,
        slidesToScroll: 1,
        autoplay: true,
        time: 5
    };
    const navImageClasses = classNames(classes.imgRounded, classes.imgGallery);
    const Appareldetails = detailapparel.map((data) => {
        return (
            <div>
                <GridContainer>
                    <Grid fluid xs={5}> 
                    <div className={classes.section} id="notifications">
                        <div className={classes.section}>
                            <div className={classes.container}>
                            <GridContainer>
                                <GridItem className={classes.marginAuto}>
                                    <Card carousel>
                                        <Carousel {...settings}>
                                            <img className={navImageClasses} width="300px" alt="First slide" src={`${backend}${data.img["url"]}`} />
                                        </Carousel>
                                    </Card>
                                </GridItem>
                            </GridContainer>
                            </div>
                        </div>
                    </div>
                    </Grid>
                    <Grid xs={7} style={{padding:"40px", marginTop:"-30px"}}>
                        <h3>{data.name}</h3>
                        <h3>Rp.{data.price}</h3>
                        <hr></hr>
                        <ul>
                            <li><h4>Stock : {data.stock}</h4></li>
                            <li><h4>Part Code : {ReactHtmlParser(data.part_code)}</h4></li>
                        </ul>
                    </Grid>
                </GridContainer>
                <div align="center">
                    <hr></hr>
                    <h2>Deskripsi</h2>
                </div>
                <div align="justify">
                    <p>{ReactHtmlParser(data.description)}</p>
                </div>
            </div> 
        );
    })
    return (
        <Card className={classes.textCenter}>
            <div align="center">
                <CardHeader color="info">Product Detail</CardHeader>
            </div>
            <CardBody>
                <div> 
                    {Appareldetails}
                </div>
            </CardBody>
            <CardFooter className={classes.textMuted} textAlign="center">
                © 2020 , All Right Reserved by @Thamrin Brother Company
            </CardFooter>
        </Card>
    );
}

export default DetailDataApparel;