Added in-session recent items with cross tab support. BOD-178
This commit is contained in:
@@ -1,17 +1,27 @@
|
||||
import React, { useEffect } from "react";
|
||||
import OwnersDetailComponent from "./owners-detail.page.component";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useQuery } from "@apollo/react-hooks";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
import AlertComponent from "../../components/alert/alert.component";
|
||||
import { QUERY_OWNER_BY_ID } from "../../graphql/owners.queries";
|
||||
import React, { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { setBreadcrumbs } from "../../redux/application/application.actions";
|
||||
import AlertComponent from "../../components/alert/alert.component";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
import { QUERY_OWNER_BY_ID } from "../../graphql/owners.queries";
|
||||
import {
|
||||
addRecentItem,
|
||||
setBreadcrumbs,
|
||||
} from "../../redux/application/application.actions";
|
||||
import { CreateRecentItem } from "../../utils/create-recent-item";
|
||||
import OwnersDetailComponent from "./owners-detail.page.component";
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
||||
addRecentItem: (item) => dispatch(addRecentItem(item)),
|
||||
});
|
||||
|
||||
export function OwnersDetailContainer({ match, setBreadcrumbs }) {
|
||||
export function OwnersDetailContainer({
|
||||
match,
|
||||
setBreadcrumbs,
|
||||
addRecentItem,
|
||||
}) {
|
||||
const { ownerId } = match.params;
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -42,7 +52,19 @@ export function OwnersDetailContainer({ match, setBreadcrumbs }) {
|
||||
}),
|
||||
},
|
||||
]);
|
||||
}, [setBreadcrumbs, t, data, ownerId]);
|
||||
|
||||
if (data)
|
||||
addRecentItem(
|
||||
CreateRecentItem(
|
||||
ownerId,
|
||||
"owner",
|
||||
`${data.owners_by_pk.ownr_fn || ""} ${
|
||||
data.owners_by_pk.ownr_ln || ""
|
||||
} ${data.owners_by_pk.ownr_co_nm || ""}`,
|
||||
`/manage/owners/${ownerId}`
|
||||
)
|
||||
);
|
||||
}, [setBreadcrumbs, t, data, ownerId, addRecentItem]);
|
||||
|
||||
if (loading) return <LoadingSpinner />;
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
|
||||
Reference in New Issue
Block a user