﻿import React, { Fragment } from 'react';


export default class checkbox extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            value: {}

        };
    }


    render() {

        const { id, col, attributes, value, label, onChange } = this.props;
        const readOnlyAttr = attributes == undefined ? { disabled: 'disabled' } : (attributes.readOnly ? { disabled: 'disabled' } : {});
        const stilo = { display: !!attributes.hidden ? attributes.hidden : 'unset', float: attributes.float == undefined ? 'left' : attributes.float };
        return (

            <div className={"col-sm-" + col + " col-md-" + col} style={stilo}>
                <div className="form-groupCK">
                    <div className="custom-controlck custom-checkbox">
                        <input type="checkbox" className="custom-control-input" name={id} id={id} checked={value} onChange={onChange} {...readOnlyAttr} />
                        <label className="custom-control-label" htmlFor={id}> {label} </label>
                    </div>
                </div>
            </div>

        )
    }
}
