- Changes required by ESLint.
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -1,25 +1,34 @@
|
|||||||
import { useLazyQuery } from "@apollo/client";
|
import {useLazyQuery} from "@apollo/client";
|
||||||
import { Select, Space, Spin, Tag } from "antd";
|
import {Select, Space, Spin, Tag} from "antd";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import React, { forwardRef, useEffect, useState } from "react";
|
import React, {forwardRef, useEffect, useState} from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import {useTranslation} from "react-i18next";
|
||||||
import { SEARCH_JOBS_BY_ID_FOR_AUTOCOMPLETE, SEARCH_JOBS_FOR_AUTOCOMPLETE } from "../../graphql/jobs.queries";
|
import {
|
||||||
|
SEARCH_JOBS_BY_ID_FOR_AUTOCOMPLETE,
|
||||||
|
SEARCH_JOBS_FOR_AUTOCOMPLETE
|
||||||
|
} from "../../graphql/jobs.queries";
|
||||||
import AlertComponent from "../alert/alert.component";
|
import AlertComponent from "../alert/alert.component";
|
||||||
import { OwnerNameDisplayFunction } from "../owner-name-display/owner-name-display.component";
|
import {OwnerNameDisplayFunction} from "../owner-name-display/owner-name-display.component";
|
||||||
import { SearchOutlined } from "@ant-design/icons";
|
import {LoadingOutlined} from "@ant-design/icons";
|
||||||
import { LoadingOutlined } from "@ant-design/icons";
|
|
||||||
|
|
||||||
const { Option } = Select;
|
const {Option} = Select;
|
||||||
|
|
||||||
const JobSearchSelect = (
|
const JobSearchSelect = (
|
||||||
{ disabled, convertedOnly = false, notInvoiced = false, notExported = true, clm_no = false, ...restProps },
|
{
|
||||||
|
disabled,
|
||||||
|
convertedOnly = false,
|
||||||
|
notInvoiced = false,
|
||||||
|
notExported = true,
|
||||||
|
clm_no = false,
|
||||||
|
...restProps
|
||||||
|
},
|
||||||
ref
|
ref
|
||||||
) => {
|
) => {
|
||||||
const { t } = useTranslation();
|
const {t} = useTranslation();
|
||||||
const [theOptions, setTheOptions] = useState([]);
|
const [theOptions, setTheOptions] = useState([]);
|
||||||
const [callSearch, { loading, error, data }] = useLazyQuery(SEARCH_JOBS_FOR_AUTOCOMPLETE, {});
|
const [callSearch, {loading, error, data}] = useLazyQuery(SEARCH_JOBS_FOR_AUTOCOMPLETE, {});
|
||||||
|
|
||||||
const [callIdSearch, { loading: idLoading, error: idError, data: idData }] = useLazyQuery(
|
const [callIdSearch, {loading: idLoading, error: idError, data: idData}] = useLazyQuery(
|
||||||
SEARCH_JOBS_BY_ID_FOR_AUTOCOMPLETE
|
SEARCH_JOBS_BY_ID_FOR_AUTOCOMPLETE
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -34,10 +43,10 @@ const JobSearchSelect = (
|
|||||||
search: value,
|
search: value,
|
||||||
...(convertedOnly || notExported
|
...(convertedOnly || notExported
|
||||||
? {
|
? {
|
||||||
...(convertedOnly ? { isConverted: true } : {}),
|
...(convertedOnly ? {isConverted: true} : {}),
|
||||||
...(notExported ? { notExported: true } : {}),
|
...(notExported ? {notExported: true} : {}),
|
||||||
...(notInvoiced ? { notInvoiced: true } : {})
|
...(notInvoiced ? {notInvoiced: true} : {})
|
||||||
}
|
}
|
||||||
: {})
|
: {})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -45,7 +54,7 @@ const JobSearchSelect = (
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (restProps.value) {
|
if (restProps.value) {
|
||||||
callIdSearch({ variables: { id: restProps.value } }); // Sometimes results in a no-op. Not sure how to fix.
|
callIdSearch({variables: {id: restProps.value}}); // Sometimes results in a no-op. Not sure how to fix.
|
||||||
}
|
}
|
||||||
}, [restProps.value, callIdSearch]);
|
}, [restProps.value, callIdSearch]);
|
||||||
|
|
||||||
@@ -75,14 +84,14 @@ const JobSearchSelect = (
|
|||||||
filterOption={false}
|
filterOption={false}
|
||||||
onSearch={handleSearch}
|
onSearch={handleSearch}
|
||||||
//loading={loading || idLoading}
|
//loading={loading || idLoading}
|
||||||
suffixIcon={loading && <Spin />}
|
suffixIcon={(loading || idLoading) && <Spin/>}
|
||||||
notFoundContent={loading ? <LoadingOutlined /> : null}
|
notFoundContent={loading ? <LoadingOutlined/> : null}
|
||||||
{...restProps}
|
{...restProps}
|
||||||
>
|
>
|
||||||
{theOptions
|
{theOptions
|
||||||
? theOptions.map((o) => (
|
? theOptions.map((o) => (
|
||||||
<Option key={o.id} value={o.id} status={o.status}>
|
<Option key={o.id} value={o.id} status={o.status}>
|
||||||
<Space align="center">
|
<Space align="center">
|
||||||
<span>
|
<span>
|
||||||
{`${clm_no && o.clm_no ? `${o.clm_no} | ` : ""}${
|
{`${clm_no && o.clm_no ? `${o.clm_no} | ` : ""}${
|
||||||
o.ro_number || t("general.labels.na")
|
o.ro_number || t("general.labels.na")
|
||||||
@@ -90,17 +99,17 @@ const JobSearchSelect = (
|
|||||||
o.v_model_yr || ""
|
o.v_model_yr || ""
|
||||||
} ${o.v_make_desc || ""} ${o.v_model_desc || ""}`}
|
} ${o.v_make_desc || ""} ${o.v_model_desc || ""}`}
|
||||||
</span>
|
</span>
|
||||||
<Tag>
|
<Tag>
|
||||||
<strong>{o.status}</strong>
|
<strong>{o.status}</strong>
|
||||||
</Tag>
|
</Tag>
|
||||||
</Space>
|
</Space>
|
||||||
</Option>
|
</Option>
|
||||||
))
|
))
|
||||||
: null}
|
: null}
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
{error ? <AlertComponent message={error.message} type="error" /> : null}
|
{error ? <AlertComponent message={error.message} type="error"/> : null}
|
||||||
{idError ? <AlertComponent message={idError.message} type="error" /> : null}
|
{idError ? <AlertComponent message={idError.message} type="error"/> : null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user