import {ModalField, ModalSelect} from '@components';
import {FC} from 'react';
import {useControl, useWatchId} from './hooks';
import {useDictionaryOptions} from '@hooks';

type Props = {id: string};

const options = [
  {label: '是', value: '1'},
  {label: '否', value: '0'},
];

const Info: FC<Props> = function ({id}) {
  const control = useControl();
  const {data: typeOptions, isFetching: typeIsFetching} = useDictionaryOptions(
    '物料类型',
    false,
    state => state.name,
  );
  useWatchId(id);

  return (
    <>
      <ModalField label='物料类别' name='goodsPartType' control={control} />
      <ModalSelect
        label='物料类型'
        name='goodsType'
        control={control}
        data={typeOptions}
        loading={typeIsFetching}
      />
      <ModalField
        label='物料存放容量'
        control={control}
        name='goodsSize'
        type='number'
      />
      <ModalField
        label='最大存储容量'
        control={control}
        name='goodsMaxNum'
        type='number'
      />
      <ModalField
        label='最小存储容量'
        control={control}
        name='goodsMinNum'
        type='number'
      />
      <ModalSelect
        label='混合放置'
        name='goodsMixin'
        control={control}
        data={options}
      />
      <ModalSelect
        label='推荐库位'
        name='goodsRecommend'
        control={control}
        data={options}
      />
    </>
  );
};

export default Info;
