42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
import { Select, Space, Tag } from "antd";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
const { Option } = Select;
|
|
//To be used as a form element only.
|
|
|
|
const EmployeeSearchSelect = ({ options, showEmail, ...props }) => {
|
|
const { t } = useTranslation();
|
|
|
|
return (
|
|
<Select
|
|
showSearch={{
|
|
optionFilterProp: "search"
|
|
}}
|
|
// value={option}
|
|
style={{
|
|
width: 400
|
|
}}
|
|
{...props}
|
|
>
|
|
{options
|
|
? options.map((o) => (
|
|
<Option key={o.id} value={o.id} search={`${o.employee_number} ${o.first_name} ${o.last_name}`}>
|
|
<Space size="small">
|
|
{`${o.employee_number ?? ""} ${o.first_name} ${o.last_name}`}
|
|
<Tag color="green" style={{ padding: "0.1 0.1rem", marginRight: "1px", marginLeft: "1px" }}>
|
|
{o.flat_rate ? t("timetickets.labels.flat_rate") : t("timetickets.labels.straight_time")}
|
|
</Tag>
|
|
{showEmail && o.user_email ? (
|
|
<Tag color="blue" style={{ padding: "0.1 0.1rem", marginRight: "1px", marginLeft: "1px" }}>
|
|
{o.user_email}
|
|
</Tag>
|
|
) : null}
|
|
</Space>
|
|
</Option>
|
|
))
|
|
: null}
|
|
</Select>
|
|
);
|
|
};
|
|
export default EmployeeSearchSelect;
|