import { Card, Col, Row, Table } from "antd";
import { LocationSaleOrderStatus } from "./location-wise-sale-order";
import { TotalSaleOrders } from "./sale-order";
import './dashboard.css'
import React, { useEffect, useState } from "react";
import Donut from "./donut";
import Barchart from "./barchat";
import Line from "./line";
import Column from "./column";
import Highdonut from "./donut";
import Highline from "./line";
import Highbar from "./barchat";
import Highcolumn from "./column";




export const Dashboard = () => {

    const Data = new LocationSaleOrderStatus('kakinada', 100);
    const Data1 = new LocationSaleOrderStatus('Unit1', 150);
    const Data2 = new LocationSaleOrderStatus('Unit2', 180);
    const data1 = new TotalSaleOrders(430, 430, [Data, Data1, Data2]);
    const data2 = new TotalSaleOrders(430, 430, [Data, Data1, Data2]);
    const data3 = new TotalSaleOrders(430, 430, [Data, Data1, Data2]);
    const constructLocationDetail = (locDetail: LocationSaleOrderStatus[]) => {
        return locDetail.map(loc =>
            <><br /><br /><br />{loc.locationName} : {loc.totalSaleOrders}<br /></>
        )
    }
    // const newData = JsonData.map((JsonData)=>{
    return (
        <>
            <div >
                <Row >
                    <Col className="cardComp" xs={{ span: 24 }} sm={{ span: 24 }} md={{ span: 7 }} lg={{ span: 7 }} xl={{ span: 7 }}>
                        <Card className="totalsocard" title={<><span style={{ fontSize: '10px' }}>(YTD)</span><br /><br /><br /><span>Total S.O Count:<b>{data1.totalSaleorders}</b></span><br /><br /><br /><span>Total S.O Qty: <b>{data1.saleOrderQuantity}</b></span></>} bordered={false}>
                            <Card.Grid style={{ width: '50%', textAlign: 'center', height: '100%' }}><b>S.O Count: </b><br /><br />{constructLocationDetail(data1.locationDetails)}</Card.Grid>
                            <Card.Grid style={{ width: '50%', textAlign: 'center', height: '100%' }}><b>S.O Qty: </b><br /><br />{constructLocationDetail(data1.locationDetails)}</Card.Grid>
                        </Card>
                    </Col>
                    <Col className="cardComp" xs={{ span: 24 }} sm={{ span: 24 }} md={{ span: 7, offset: 1 }} lg={{ span: 7, offset: 1 }} xl={{ span: 7, offset: 1 }}>
                        <Card className="totalopensocard" title={<><span style={{ fontSize: '10px' }}>(YTD)</span><br /><br /><br /><span>Total Open S.O Count:<b>{data1.totalSaleorders}</b></span><br /><br /><br /><span>Total Open S.O Qty: <b>{data1.saleOrderQuantity}</b></span></>} bordered={false} style={{ backgroundColor: 'green' }} >
                            <Card.Grid style={{ width: '50%', textAlign: 'center', height: '100%' }}><b>S.O Count: </b><br /><br />{constructLocationDetail(data1.locationDetails)}</Card.Grid>
                            <Card.Grid style={{ width: '50%', textAlign: 'center', height: '100%' }}><b>S.O Qty: </b><br /><br />{constructLocationDetail(data1.locationDetails)}</Card.Grid>
                        </Card>
                    </Col>
                    <Col className="cardComp" xs={{ span: 24 }} sm={{ span: 24 }} md={{ span: 7, offset: 1 }} lg={{ span: 7, offset: 1 }} xl={{ span: 7, offset: 1 }}>
                        <Card className="shipedsocard" title={<><span style={{ fontSize: '10px' }}>(YTD)</span><br /><br /><br /><span>Total Shipped S.O Count:<b>{data1.totalSaleorders}</b></span><br /><br /><br /><span>Total Shipped S.O Qty: <b>{data1.saleOrderQuantity}</b></span></>} bordered={false} style={{ backgroundColor: 'cyan' }} >
                            <Card.Grid style={{ width: '50%', textAlign: 'center', height: '100%' }}><b>S.O Count: </b><br /><br />{constructLocationDetail(data1.locationDetails)}</Card.Grid>
                            <Card.Grid style={{ width: '50%', textAlign: 'center', height: '100%' }}><b>S.O Qty: </b><br /><br />{constructLocationDetail(data1.locationDetails)}</Card.Grid>
                        </Card>
                    </Col>
                </Row>
                <br/><br/>
                <Row>
                    <Col id="mark" style={{ position: 'absolute', marginRight: '20%' }}>
                        <Highdonut doNutData={undefined} />
                    </Col>
                    <Col style={{ marginLeft: '50%' }}>
                        <Highbar request={new BarChartRequest} />
                    </Col>
                </Row>
                <br/><br/>
                <Row>
                    <Col style={{ position: 'absolute', marginRight: '20%' }}>
                        <Highline />
                    </Col>
                    <Col style={{ marginLeft: '50%' }} >
                        <Highcolumn />
                    </Col>
                </Row>
            </div>
        </>
    );
    // })
}
export default Dashboard;