Added error pages for detail type pages BOD-119
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
} from "../../redux/application/application.actions";
|
||||
import { CreateRecentItem } from "../../utils/create-recent-item";
|
||||
import OwnersDetailComponent from "./owners-detail.page.component";
|
||||
import NotFound from "../../components/not-found/not-found.component";
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
||||
@@ -34,9 +35,9 @@ export function OwnersDetailContainer({
|
||||
useEffect(() => {
|
||||
document.title = t("titles.owners-detail", {
|
||||
name: data
|
||||
? `${data.owners_by_pk.ownr_fn || ""} ${
|
||||
data.owners_by_pk.ownr_ln || ""
|
||||
} ${data.owners_by_pk.ownr_co_nm || ""}`
|
||||
? `${(data.owners_by_pk && data.owners_by_pk.ownr_fn) || ""} ${
|
||||
(data.owners_by_pk && data.owners_by_pk.ownr_ln) || ""
|
||||
} ${(data.owners_by_pk && data.owners_by_pk.ownr_co_nm) || ""}`
|
||||
: "",
|
||||
});
|
||||
|
||||
@@ -46,15 +47,15 @@ export function OwnersDetailContainer({
|
||||
link: `/manage/owners/${ownerId}`,
|
||||
label: t("titles.bc.owner-detail", {
|
||||
name: data
|
||||
? `${data.owners_by_pk.ownr_fn || ""} ${
|
||||
data.owners_by_pk.ownr_ln || ""
|
||||
} ${data.owners_by_pk.ownr_co_nm || ""}`
|
||||
? `${(data.owners_by_pk && data.owners_by_pk.ownr_fn) || ""} ${
|
||||
(data.owners_by_pk && data.owners_by_pk.ownr_ln) || ""
|
||||
} ${(data.owners_by_pk && data.owners_by_pk.ownr_co_nm) || ""}`
|
||||
: "",
|
||||
}),
|
||||
},
|
||||
]);
|
||||
|
||||
if (data)
|
||||
if (data && data.owners_by_pk)
|
||||
addRecentItem(
|
||||
CreateRecentItem(
|
||||
ownerId,
|
||||
@@ -69,16 +70,12 @@ export function OwnersDetailContainer({
|
||||
|
||||
if (loading) return <LoadingSpinner />;
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
if (!!!data.owners_by_pk) return <NotFound />;
|
||||
|
||||
if (data.owners_by_pk)
|
||||
return (
|
||||
<RbacWrapper action="owners:detail">
|
||||
<OwnersDetailComponent owner={data.owners_by_pk} refetch={refetch} />
|
||||
</RbacWrapper>
|
||||
);
|
||||
else
|
||||
return (
|
||||
<AlertComponent message={t("owners.errors.noaccess")} type="error" />
|
||||
);
|
||||
return (
|
||||
<RbacWrapper action="owners:detail">
|
||||
<OwnersDetailComponent owner={data.owners_by_pk} refetch={refetch} />
|
||||
</RbacWrapper>
|
||||
);
|
||||
}
|
||||
export default connect(null, mapDispatchToProps)(OwnersDetailContainer);
|
||||
|
||||
Reference in New Issue
Block a user