import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import Select from 'react-select';

import GridContainer from "components/Grid/GridContainer.js";
import Grid from '@material-ui/core/Grid';
import Card from "components/Card/Card.js";
import CardBody from "components/Card/CardBody.js";
import CardHeader from "components/Card/CardHeader.js";
import Quote from "components/Typography/Quote.js"
import Icon from "@material-ui/core/Icon";
import Button from "components/CustomButtons/Button.js";
import styles from "assets/jss/nextjs-material-kit/pages/componentsSections/notificationsStyles.js";

const useStyles = makeStyles(styles);
const DataDealer = function ({ selected, handleName, backend, dealers, ...props })  {
    const classes = useStyles();

    const Dealers = dealers.map((data) => {
        return (
            <div>
                <Grid style={{width:"350px", padding:"10px"}}>
                    <Card>
                        <CardHeader color="danger"><div align="center">{data.name}</div></CardHeader>
                        <CardBody>
                            <Quote
                            text={data.kota_dealer}
                            author={data.address}
                            />
                            <Quote
                            text={data.telp}
                            author={data.email}
                            />
                            <div align="center">
                                <Button color="danger" round href={data.location} target="_blank">
                                    <Icon className={classes.icons}>room</Icon>View Location
                                </Button>
                            </div>
                        </CardBody>
                    </Card>
                </Grid>
            </div>
            );
        })
        return (
        <div>
            <Card className={classes.textCenter} align="center" style={{padding:"5px"}}>
                <CardBody>
                <div align="center" style={{marginTop:"-50px"}}>
                    <h2>Yamaha Dealers</h2>
                    <Select
                        value={(selected)?accessories.filter((i)=>i.id==selected):null} 
                        getOptionLabel={option => `${option.name}`}
                        getOptionValue={option => option.id}
                        options={dealers}
                        isMulti
                        instanceId="name"
                        placeholder="filter by Nama Part"
                        onChange={values => handleName(values)}
                    />
                    <br></br>
                    <GridContainer justify="center">
                        {Dealers}
                    </GridContainer>
                </div> 
                </CardBody>
            </Card>
        </div>
    );
}

export default DataDealer;