WIP for not found error pages BOD-119
This commit is contained in:
@@ -14,6 +14,8 @@ import {
|
||||
} from "../../redux/application/application.actions";
|
||||
import { CreateRecentItem } from "../../utils/create-recent-item";
|
||||
import CourtesyCarDetailPageComponent from "./courtesy-car-detail.page.component";
|
||||
import NotFound from "../../components/not-found/not-found.component";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
||||
@@ -38,21 +40,29 @@ export function CourtesyCarDetailPageContainer({
|
||||
: error
|
||||
? t("titles.app")
|
||||
: t("titles.courtesycars-detail", {
|
||||
id: (data && data.courtesycars_by_pk.fleet_number) || "",
|
||||
id:
|
||||
(data &&
|
||||
data.courtesycars_by_pk &&
|
||||
data.courtesycars_by_pk.fleet_number) ||
|
||||
"",
|
||||
});
|
||||
setBreadcrumbs([
|
||||
{ link: "/manage/courtesycars", label: t("titles.bc.courtesycars") },
|
||||
{
|
||||
link: `/manage/courtesycars/${
|
||||
(data && data.courtesycars_by_pk.id) || ""
|
||||
(data && data.courtesycars_by_pk && data.courtesycars_by_pk.id) || ""
|
||||
}`,
|
||||
label: t("titles.bc.courtesycars-detail", {
|
||||
number: (data && data.courtesycars_by_pk.fleetnumber) || "",
|
||||
number:
|
||||
(data &&
|
||||
data.courtesycars_by_pk &&
|
||||
data.courtesycars_by_pk.fleetnumber) ||
|
||||
"",
|
||||
}),
|
||||
},
|
||||
]);
|
||||
|
||||
if (data)
|
||||
if (data && data.courtesycars_by_pk)
|
||||
addRecentItem(
|
||||
CreateRecentItem(
|
||||
ccId,
|
||||
@@ -84,10 +94,14 @@ export function CourtesyCarDetailPageContainer({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (data) form.resetFields();
|
||||
if (data && data.courtesycars_by_pk) form.resetFields();
|
||||
}, [data, form]);
|
||||
|
||||
if (loading) return <LoadingSpinner />;
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
|
||||
if (!!!data.courtesycars_by_pk) return <NotFound />;
|
||||
|
||||
return (
|
||||
<RbacWrapper action="courtesycar:detail">
|
||||
<Form
|
||||
|
||||
Reference in New Issue
Block a user