Resolved issues for job search select & updated packages.

This commit is contained in:
Patrick Fic
2022-06-09 11:51:01 -07:00
parent 92fb519642
commit c01f402f92
5 changed files with 305 additions and 326 deletions

View File

@@ -42,7 +42,6 @@ export function BillInventoryTable({
}
}, [inventoryData, form, billEnterModal.context.consumeinventoryid]);
console.log(form.getFieldsValue());
return (
<Form.Item
shouldUpdate={(prev, cur) => prev.vendorid !== cur.vendorid}

View File

@@ -37,7 +37,7 @@ export function InventoryBillRo({
isinhouse: true,
date: moment(),
total: 0,
billlines: [{}],
// billlines: selectedLines.map((p) => {
// return {
// joblineid: p.id,

View File

@@ -1,8 +1,7 @@
import { LoadingOutlined } from "@ant-design/icons";
import { useLazyQuery } from "@apollo/client";
import { Empty, Select, Space, Tag } from "antd";
import { Select, Space, Tag } from "antd";
import _ from "lodash";
import React, { forwardRef, useEffect } from "react";
import React, { forwardRef, useState, useEffect } from "react";
import { useTranslation } from "react-i18next";
import {
SEARCH_JOBS_BY_ID_FOR_AUTOCOMPLETE,
@@ -24,31 +23,35 @@ const JobSearchSelect = (
ref
) => {
const { t } = useTranslation();
const [theOptions, setTheOptions] = useState([]);
const [callSearch, { loading, error, data }] = useLazyQuery(
SEARCH_JOBS_FOR_AUTOCOMPLETE,
{
...(convertedOnly || notExported
? {
variables: {
...(convertedOnly ? { isConverted: true } : {}),
...(notExported ? { notExported: true } : {}),
...(notInvoiced ? { notInvoiced: true } : {}),
},
}
: {}),
}
{}
);
const [callIdSearch, { loading: idLoading, error: idError, data: idData }] =
useLazyQuery(SEARCH_JOBS_BY_ID_FOR_AUTOCOMPLETE);
const executeSearch = (v) => {
callSearch(v);
if (v && v !== "") callSearch(v);
};
const debouncedExecuteSearch = _.debounce(executeSearch, 500);
const handleSearch = (value) => {
debouncedExecuteSearch({ variables: { search: value } });
debouncedExecuteSearch({
variables: {
search: value,
...(convertedOnly || notExported
? {
variables: {
...(convertedOnly ? { isConverted: true } : {}),
...(notExported ? { notExported: true } : {}),
...(notInvoiced ? { notInvoiced: true } : {}),
},
}
: {}),
},
});
};
useEffect(() => {
@@ -57,13 +60,17 @@ const JobSearchSelect = (
}
}, [restProps.value, callIdSearch]);
const theOptions = _.uniqBy(
[
...(idData && idData.jobs_by_pk ? [idData.jobs_by_pk] : []),
...(data && data.search_jobs ? data.search_jobs : []),
],
"id"
);
useEffect(() => {
setTheOptions(
_.uniqBy(
[
...(idData && idData.jobs_by_pk ? [idData.jobs_by_pk] : []),
...(data && data.search_jobs ? data.search_jobs : []),
],
"id"
)
);
}, [data, idData]);
return (
<div>
@@ -77,7 +84,8 @@ const JobSearchSelect = (
}}
filterOption={false}
onSearch={handleSearch}
notFoundContent={loading ? <LoadingOutlined /> : <Empty />}
loading={loading || idLoading}
//notFoundContent={loading ? <LoadingOutlined /> : <Empty />}
{...restProps}
>
{theOptions
@@ -99,7 +107,6 @@ const JobSearchSelect = (
))
: null}
</Select>
{idLoading || loading ? <LoadingOutlined /> : null}
{error ? <AlertComponent message={error.message} type="error" /> : null}
{idError ? (
<AlertComponent message={idError.message} type="error" />