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

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

type Props = {
  id: string;
};

const StoreModalInfo: FC<Props> = function ({id}) {
  const control = useFormInstance();
  useFormInfoValue(id);
  const {data: storageOptions, isFetching: isStorageFetching} =
    useDictionaryOptions('仓库');
  const {data: typeOptions, isFetching: isTypeFetching} = useDictionaryOptions(
    '物料类型',
    false,
    state => state.name,
  );

  return (
    <>
      <ModalField
        name='storageLocationCode'
        label='库位编号'
        control={control}
      />
      <ModalField
        name='storageLocationName'
        label='库位名称'
        control={control}
      />
      <ModalSelect
        name='storageWarehouse'
        label='所属仓库'
        control={control}
        data={storageOptions}
        loading={isStorageFetching}
      />
      <ModalSelect
        name='storageIsNotDisable'
        label='混合库位'
        control={control}
        data={stateOptions}
      />
      <ModalSelect
        name='storageIsProduct'
        label='产成品库位'
        control={control}
        data={stateOptions}
      />
      <ModalSelect
        name='storageMaterialType'
        label='物料类型'
        control={control}
        data={typeOptions}
        multiple
        required={false}
        loading={isTypeFetching}
      />
    </>
  );
};

export default StoreModalInfo;
