import {Modal, ModalSelect} from '@components';
import {FC} from 'react';
import {useFormState} from './hooks';

type Props = {
  visible: boolean;
  id: string;
  type: string;
  onClose: () => void;
  onFetch: () => void;
};

const options = [
  {label: '暂无', value: ''},
  {label: '原材料仓库', value: '0'},
  {label: '半成品仓库', value: '1'},
  {label: '产成品仓库', value: '2'},
];

const StorageModal: FC<Props> = function ({
  id,
  type,
  visible,
  onClose,
  onFetch,
}) {
  const [{isLoading, control}, {onSubmit}] = useFormState({
    type,
    id,
    onClose,
    onFetch,
  });

  return (
    <Modal
      title='修改仓库类型'
      height='450px'
      width='600px'
      isLoading={isLoading}
      visible={visible}
      onSubmit={onSubmit}
      onClose={onClose}
      testId='dicionary_modal'
    >
      <ModalSelect
        label='仓库类型'
        control={control}
        data={options}
        name='storageType'
      />
    </Modal>
  );
};

export default StorageModal;
