import { Dropdown, Radio, Select } from "antd"
import React from "react"
import { RadioButtonGroupText, RadioButtonGroupWrapper } from "./styled"

interface RadioItem {
  value?: string
  label?: string
}
interface RadioButtonProps {
  onChange: (value: string) => void
  value?: string
  datas?: RadioItem[],
  title?: string
}

const ProductCodeSelect = ({ onChange, title, datas }: RadioButtonProps) => {
  if (!datas || datas.length === 0) return null
  return (
    <RadioButtonGroupWrapper>
      <RadioButtonGroupText>{title}</RadioButtonGroupText>
      <Select
        placeholder={title}
        onChange={onChange}
        options={datas}
        defaultValue={datas[0].value}
        style={{minWidth: "200px"}}
      />
    </RadioButtonGroupWrapper>
  )
}

export default ProductCodeSelect
