/**
 * 生效时间
 */

import React, { FC, useMemo } from "react";
import { TimeInForceEnum } from "@shared/types";
import { PlaceSelect } from "@components/PlaceOrder/PlaceSelect";

export interface Props {
  value?: TimeInForceEnum;
  onChange: (val: TimeInForceEnum) => void;
  disable?: boolean;
}

export const TimeInForce: FC<Props> = props => {
  const { value, disable } = props;

  const list = useMemo(() => {
    return [
      { value: TimeInForceEnum.GTC, label: "一直有效至取消" },
      { value: TimeInForceEnum.IOC, label: "立即成交或取消" },
      { value: TimeInForceEnum.FOK, label: "全部成交或取消" }
    ];
  }, []);

  return <PlaceSelect value={value} list={list} onChange={props.onChange} disable={disable} />;
};
TimeInForce.defaultProps = {
  value: TimeInForceEnum.GTC
};
