IO-934 Refactor some search select fields & save employee on new ticket

This commit is contained in:
Patrick Fic
2021-04-26 14:57:04 -07:00
parent 438692ea7c
commit 485e1c4497
3 changed files with 17 additions and 38 deletions

View File

@@ -1,33 +1,21 @@
import { Select, Space, Tag } from "antd";
import React, { forwardRef, useEffect, useState } from "react";
import React, { forwardRef } from "react";
import { useTranslation } from "react-i18next";
const { Option } = Select;
//To be used as a form element only.
const EmployeeSearchSelect = (
{ value, onChange, options, onSelect, onBlur, ...restProps },
ref
) => {
const [option, setOption] = useState(value);
const EmployeeSearchSelect = ({ options, ...props }, ref) => {
const { t } = useTranslation();
useEffect(() => {
if (value !== option && onChange) {
onChange(option);
}
}, [value, option, onChange]);
return (
<Select
showSearch
value={option}
// value={option}
style={{
width: 400,
}}
onChange={setOption}
optionFilterProp="search"
onSelect={onSelect}
onBlur={onBlur}
{...restProps}
{...props}
>
{options
? options.map((o) => (