import React, { FC } from 'react'
import Radio from './Radio'
import { RadioGroupProps } from './RadioGroup.types'

const RadioGroup: FC<RadioGroupProps> = ({value='', onChange, list=[], name='', labelDir='column', isDisabled=false}) => {
  return (
    <div style={{
      display: 'flex',
      width: '100%',
      flexDirection: labelDir
    }}>
    {list.map(({ label, value: _value, id }: any, index: any) => (
        <Radio
            key={index}
            id={id}
            value={_value}
            group={name}
            label={label}
            checked={value === _value}
            onChange={onChange}
            isDisabled={isDisabled}
        />
    ))}
    </div>
  )
}

export default RadioGroup