Added find owner modal and basic searching logic.
This commit is contained in:
@@ -1,23 +1,53 @@
|
||||
import React from "react";
|
||||
import { Modal } from "antd";
|
||||
import OwnerFindModalComponent from "./owner-find-modal.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import React from "react";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import { json } from "body-parser";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import OwnerFindModalComponent from "./owner-find-modal.component";
|
||||
import { useQuery } from "react-apollo";
|
||||
import { QUERY_SEARCH_OWNER_BY_IDX } from "../../graphql/owners.queries";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
export default function OwnerFindModalContainer({
|
||||
loading,
|
||||
error,
|
||||
owner,
|
||||
selectedOwner,
|
||||
setSelectedOwner,
|
||||
...modalProps
|
||||
}) {
|
||||
//use owner object to run query and find what possible owners there are.
|
||||
const { t } = useTranslation();
|
||||
|
||||
const ownersList = useQuery(QUERY_SEARCH_OWNER_BY_IDX, {
|
||||
variables: {
|
||||
search: owner
|
||||
? `${owner.ownr_fn} ${owner.ownr_ln} ${owner.ownr_addr1} ${owner.ownr_city} ${owner.ownr_zip} ${owner.ownr_ea} ${owner.ownr_ph1} ${owner.ownr_ph2}`
|
||||
: null
|
||||
},
|
||||
skip: !owner,
|
||||
fetchPolicy: "network-only"
|
||||
});
|
||||
|
||||
return (
|
||||
<Modal {...modalProps}>
|
||||
<Modal
|
||||
title={t("owners.labels.existing_owners")}
|
||||
width={"80%"}
|
||||
{...modalProps}
|
||||
>
|
||||
{loading ? <LoadingSpinner /> : null}
|
||||
{error ? <AlertComponent message={error.message} type="error" /> : null}
|
||||
{owner ? <OwnerFindModalComponent /> : null}
|
||||
{owner ? JSON.stringify(owner) : null}
|
||||
{owner ? (
|
||||
<OwnerFindModalComponent
|
||||
selectedOwner={selectedOwner}
|
||||
setSelectedOwner={setSelectedOwner}
|
||||
ownersListLoading={ownersList.loading}
|
||||
ownersList={
|
||||
ownersList.data && ownersList.data.search_owners
|
||||
? ownersList.data.search_owners
|
||||
: null
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user