import React from "react";
import Tooltip from "../ToolTip";
import Typography, { ITypo, ITypoColor } from "../Typography";
import classes from "./classes.module.scss";

type IProps = {
	children: React.ReactNode;
	name: string;
	toolTip?: string;
	defaultChecked?: boolean;
	onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
};

export default class RadioBox extends React.Component<IProps> {
	public override render(): JSX.Element {
		return (
			<Typography typo={ITypo.P_ERR_16} color={ITypoColor.BLACK}>
				<label className={classes["root"]}>
					<input type="radio" name={this.props.name} defaultChecked={this.props.defaultChecked} onChange={this.props.onChange} />
					{this.props.children}
					{this.props.toolTip && <Tooltip className={classes["tooltip"]} text={this.props.toolTip} />}
				</label>
			</Typography>
		);
	}
}
