-
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.
homepage that redirects on tenant lock
- Loading branch information
1 parent
9196c3b
commit 980159b
Showing
11 changed files
with
172 additions
and
15 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
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,71 @@ | ||
// Recidiviz - a data platform for criminal justice reform | ||
// Copyright (C) 2021 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, Redirect } from "@reach/router"; | ||
import { observer } from "mobx-react-lite"; | ||
import { rem } from "polished"; | ||
import React from "react"; | ||
import styled from "styled-components/macro"; | ||
import getTenantList from "../contentApi/getTenantList"; | ||
import getUrlForResource from "../routerUtils/getUrlForResource"; | ||
import { useDataStore } from "../StoreProvider"; | ||
import { CopyBlock, PageSection, PageTitle } from "../UiLibrary"; | ||
import withRouteSync from "../withRouteSync"; | ||
|
||
const PageContainer = styled(PageSection)` | ||
padding-bottom: ${rem(48)}; | ||
padding-top: ${rem(48)}; | ||
`; | ||
|
||
const PageHome = (): React.ReactElement => { | ||
const { | ||
tenantStore: { locked, currentTenantId }, | ||
} = useDataStore(); | ||
|
||
if (locked && currentTenantId) { | ||
return ( | ||
<Redirect | ||
to={getUrlForResource({ | ||
page: "tenant", | ||
params: { tenantId: currentTenantId }, | ||
})} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<PageContainer> | ||
<PageTitle>Spotlight</PageTitle> | ||
<CopyBlock> | ||
{getTenantList().map(({ id, name }) => ( | ||
<p> | ||
<Link | ||
to={getUrlForResource({ | ||
page: "tenant", | ||
params: { tenantId: id }, | ||
})} | ||
> | ||
{name} | ||
</Link> | ||
</p> | ||
))} | ||
</CopyBlock> | ||
</PageContainer> | ||
); | ||
}; | ||
|
||
export default withRouteSync(observer(PageHome)); |
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,18 @@ | ||
// Recidiviz - a data platform for criminal justice reform | ||
// Copyright (C) 2021 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/>. | ||
// ============================================================================= | ||
|
||
export { default } from "./PageHome"; |
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,33 @@ | ||
// Recidiviz - a data platform for criminal justice reform | ||
// Copyright (C) 2021 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 getTenantList from "./getTenantList"; | ||
|
||
test("getTenantList", () => { | ||
expect(getTenantList()).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"id": "US_ND", | ||
"name": "North Dakota", | ||
}, | ||
Object { | ||
"id": "US_PA", | ||
"name": "Pennsylvania", | ||
}, | ||
] | ||
`); | ||
}); |
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,26 @@ | ||
// Recidiviz - a data platform for criminal justice reform | ||
// Copyright (C) 2021 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 retrieveContent from "./retrieveContent"; | ||
import { TenantId, TenantIdList } from "./types"; | ||
|
||
export default function getTenantList(): { id: TenantId; name: string }[] { | ||
return TenantIdList.map((id) => ({ | ||
id, | ||
name: retrieveContent({ tenantId: id }).name, | ||
})); | ||
} |
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