46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
import { Select } from "antd";
|
|
import React, { forwardRef } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
//To be used as a form element only.
|
|
const { Option } = Select;
|
|
const BillLineSearchSelect = ({ options, disabled, ...restProps }, ref) => {
|
|
const { t } = useTranslation();
|
|
|
|
return (
|
|
<Select
|
|
disabled={disabled}
|
|
ref={ref}
|
|
showSearch
|
|
optionFilterProp="line_desc"
|
|
notFoundContent={"Removed."}
|
|
{...restProps}
|
|
>
|
|
<Select.Option key={null} value={"noline"} cost={0} line_desc={""}>
|
|
{t("billlines.labels.other")}
|
|
</Select.Option>
|
|
{options
|
|
? options.map((item) => (
|
|
<Option
|
|
disabled={item.removed}
|
|
key={item.id}
|
|
value={item.id}
|
|
cost={item.act_price ? item.act_price : 0}
|
|
part_type={item.part_type}
|
|
line_desc={item.line_desc}
|
|
part_qty={item.part_qty}
|
|
style={{
|
|
...(item.removed ? { textDecoration: "line-through" } : {}),
|
|
}}
|
|
>
|
|
{`${item.removed ? `(REMOVED) ` : ""}${item.line_desc}${
|
|
item.oem_partno ? ` - ${item.oem_partno}` : ""
|
|
}`}
|
|
</Option>
|
|
))
|
|
: null}
|
|
</Select>
|
|
);
|
|
};
|
|
export default forwardRef(BillLineSearchSelect);
|