import React, { useState, useEffect } from 'react';
import { Modal, Form, Button, } from 'react-bootstrap';

const PlayerDetail = ({ showPlayerDetail, setShowPlayerDetail, player }) => {
    const handleClose = () => setShowPlayerDetail(false);
    const handleShow = () => setShowPlayerDetail(true);

    if (player != null) {
        return (
            <>
                <Modal show={showPlayerDetail} onHide={handleClose} size="lg">
                    <Modal.Header closeButton>
                        <Modal.Title>
                            <Form.Control
                                type="text"
                                readOnly
                                className="form-control-plaintext"
                                value={player.name}
                            />
                        </Modal.Title>
                    </Modal.Header>
                    <Modal.Body>
                        <Form aria-disabled={true}>
                            <Form.Group className="mb-3 row" controlId="PlayerDetail">
                                <label className="col-sm-4 col-form-label">Position:</label>
                                <div className="col-sm-8">
                                    <input type="text" readOnly className="form-control-plaintext" value={player.position} />
                                </div>
                            </Form.Group>
                            <Form.Group className="mb-3 row" controlId="PlayerDetail">
                                <label className="col-sm-4 col-form-label">Dress number:</label>
                                <div className="col-sm-8">
                                    <input type="text" readOnly className="form-control-plaintext" value={player.dressNumber} />
                                </div>
                            </Form.Group>
                            <Form.Group className="mb-3 row" controlId="PlayerDetail">
                                <label className="col-sm-4 col-form-label">Height:</label>
                                <div className="col-sm-8">
                                    <input type="text" readOnly className="form-control-plaintext" value={player.height} />
                                </div>
                            </Form.Group>
                            <Form.Group className="mb-3 row" controlId="PlayerDetail">
                                <label className="col-sm-4 col-form-label">Weight:</label>
                                <div className="col-sm-8">
                                    <input type="text" readOnly className="form-control-plaintext" value={player.weight} />
                                </div>
                            </Form.Group>
                        </Form>
                    </Modal.Body>
                    <Modal.Footer>
                        <Button variant="secondary" onClick={handleClose}>
                            Close
                        </Button>
                    </Modal.Footer>
                </Modal>
            </>
        );
    }
}

export default PlayerDetail;