-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ea16b2
commit 9bf739a
Showing
11 changed files
with
174 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Recidiviz - a data platform for criminal justice reform | ||
// Copyright (C) 2020 Recidiviz, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
// ============================================================================= | ||
|
||
import { RouteComponentProps } from "@reach/router"; | ||
import { observer } from "mobx-react-lite"; | ||
import React from "react"; | ||
import { SystemNarrativeTypeId } from "../contentApi/types"; | ||
import { useDataStore } from "../StoreProvider"; | ||
import withRouteSync from "../withRouteSync"; | ||
|
||
type PageNarrativeProps = RouteComponentProps & { | ||
narrativeTypeId?: SystemNarrativeTypeId; | ||
}; | ||
|
||
const PageNarrative: React.FC<PageNarrativeProps> = ({ narrativeTypeId }) => { | ||
const tenant = useDataStore().tenantStore.currentTenant; | ||
|
||
// if this component is used properly as a route component, | ||
// this should never be true; | ||
// if it is, something has gone very wrong | ||
if (!narrativeTypeId) { | ||
throw new Error("missing narrativeTypeId"); | ||
} | ||
|
||
// tenant may be briefly undefined on initial page load | ||
const narrative = tenant?.systemNarratives[narrativeTypeId]; | ||
|
||
return ( | ||
<article> | ||
<h1>{narrative?.title}</h1> | ||
<p>{narrative?.introduction}</p> | ||
</article> | ||
); | ||
}; | ||
|
||
export default withRouteSync(observer(PageNarrative)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
spotlight-client/src/PageNarrativeList/PageNarrativeList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Recidiviz - a data platform for criminal justice reform | ||
// Copyright (C) 2020 Recidiviz, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
// ============================================================================= | ||
|
||
import { Link, RouteComponentProps } from "@reach/router"; | ||
import { observer } from "mobx-react-lite"; | ||
import React from "react"; | ||
import { SystemNarrativeTypeIdList } from "../contentApi/types"; | ||
import getUrlForResource from "../routerUtils/getUrlForResource"; | ||
import { useDataStore } from "../StoreProvider"; | ||
import withRouteSync from "../withRouteSync"; | ||
|
||
const PageNarrativeList: React.FC<RouteComponentProps> = () => { | ||
const tenant = useDataStore().tenantStore.currentTenant; | ||
|
||
const systemNarratives = tenant?.systemNarratives; | ||
|
||
return ( | ||
<article> | ||
<h1>Collections</h1> | ||
{tenant && systemNarratives && Object.keys(systemNarratives).length > 0 && ( | ||
<section> | ||
<h2>system overview</h2> | ||
<ul> | ||
{SystemNarrativeTypeIdList.map((id) => { | ||
const narrative = systemNarratives[id]; | ||
return ( | ||
narrative && ( | ||
<li key={id}> | ||
<Link | ||
to={getUrlForResource({ | ||
page: "narrative", | ||
params: { tenantId: tenant.id, narrativeTypeId: id }, | ||
})} | ||
> | ||
{narrative.title} | ||
</Link> | ||
</li> | ||
) | ||
); | ||
})} | ||
</ul> | ||
</section> | ||
)} | ||
</article> | ||
); | ||
}; | ||
|
||
export default withRouteSync(observer(PageNarrativeList)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters