import React, { useState, useEffect } from 'react';
import { InputRadio } from '../../../../../UI'
interface Props {
    updateData: (value: number) => void;
    masImg: string[],
    name: string,
    label: string,
    value: string,
  }

export const RadioButton: React.FC<Props> = ({masImg, updateData }) => {
    const [variable, setVariable] = useState<number>(0);

    const inputHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
        const value:number = event.target.value;
        setVariable(value);
        updateData(value);
      };

    return(
        <div className='fieldset'>
            {masImg.map((name, num) =>
                <InputRadio
                    key={name}
                    num={num}
                    variable={variable}
                    onChange={inputHandler}
                />
            )}
        </div>
    )
}