-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: data portal landing page (#729)
# Pull Request type Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no API changes) - [ ] Build-related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? Issue Number: IN-915 ## What is the new behavior? - - - ## Does this introduce a breaking change? - [ ] Yes - [ ] No ## Other information PR-URL: #729 Co-authored-by: Joe Karow <[email protected]>
- Loading branch information
Showing
26 changed files
with
478 additions
and
364 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,30 +30,19 @@ jobs: | |
git_config_global: true | ||
git_commit_gpgsign: true | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3 | ||
with: | ||
node-version: 18 | ||
|
||
- uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # v2.4.0 | ||
name: Install pnpm | ||
id: pnpm-install | ||
with: | ||
run_install: false | ||
# standalone: true | ||
|
||
- name: Get pnpm store directory | ||
id: pnpm-cache | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | ||
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 | ||
name: Setup pnpm cache | ||
- name: Install Node.js | ||
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3 | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
node-version-file: .nvmrc | ||
cache: pnpm | ||
cache-dependency-path: pnpm-lock.yaml | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
@@ -89,7 +78,7 @@ jobs: | |
with: | ||
message: 'chore: lint & format' | ||
commit: --signoff --no-verify | ||
committer_name: InReach Bot | ||
committer_name: InReach [bot] | ||
committer_email: [email protected] | ||
author_name: InReach Bot | ||
author_name: InReach [bot] | ||
author_email: [email protected] |
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,52 @@ | ||
import { Container, rem, Stack, Title } from '@mantine/core' | ||
import { type GetStaticProps } from 'next' | ||
import { useRouter } from 'next/router' | ||
import { useTranslation } from 'next-i18next' | ||
import { type Route } from 'nextjs-routes' | ||
import { z } from 'zod' | ||
|
||
import { getServerSideTranslations } from '~app/utils/i18n' | ||
import { LoginBody } from '~ui/modals/Login' | ||
|
||
const RouteSchema = z.object({ | ||
pathname: z.string(), | ||
query: z.record(z.string()).optional(), | ||
locale: z.string().optional(), | ||
}) | ||
|
||
const Unauthorized = () => { | ||
const { t } = useTranslation('common') | ||
const router = useRouter() | ||
const callback = | ||
typeof router.query.callbackUrl === 'string' | ||
? RouteSchema.safeParse(JSON.parse(Buffer.from(router.query.callbackUrl, 'base64').toString('utf-8'))) | ||
: undefined | ||
|
||
return ( | ||
<Container> | ||
<Stack | ||
m={{ base: `${rem(48)} ${rem(0)}`, xs: `${rem(80)} ${rem(0)}`, sm: `${rem(100)} ${rem(0)}` }} | ||
align='center' | ||
spacing={32} | ||
> | ||
<Stack spacing={0} align='center'> | ||
{/* eslint-disable-next-line i18next/no-literal-string */} | ||
<Title order={1}>🔐</Title> | ||
<Title order={1}>{t('errors.401-title')}</Title> | ||
</Stack> | ||
<LoginBody hideTitle callbackUrl={callback?.success ? (callback.data as Route) : undefined} /> | ||
</Stack> | ||
</Container> | ||
) | ||
} | ||
|
||
export const getStaticProps: GetStaticProps = async ({ locale }) => { | ||
return { | ||
props: { | ||
...(await getServerSideTranslations(locale, ['common'])), | ||
}, | ||
revalidate: 60 * 60 * 24 * 7, | ||
} | ||
} | ||
|
||
export default Unauthorized |
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,37 @@ | ||
import { Container, rem, Stack, Text, Title } from '@mantine/core' | ||
import { type GetStaticProps } from 'next' | ||
import { useTranslation } from 'next-i18next' | ||
|
||
import { getServerSideTranslations } from '~app/utils/i18n' | ||
|
||
const Forbidden = () => { | ||
const { t } = useTranslation('common') | ||
|
||
return ( | ||
<Container> | ||
<Stack | ||
m={{ base: `${rem(48)} ${rem(0)}`, xs: `${rem(80)} ${rem(0)}`, sm: `${rem(100)} ${rem(0)}` }} | ||
align='center' | ||
spacing={32} | ||
> | ||
<Stack spacing={0} align='center'> | ||
{/* eslint-disable-next-line i18next/no-literal-string */} | ||
<Title order={1}>⛔️</Title> | ||
<Title order={1}>{t('errors.403-title')}</Title> | ||
</Stack> | ||
<Text ta='center'>{t('errors.403-body')}</Text> | ||
</Stack> | ||
</Container> | ||
) | ||
} | ||
|
||
export const getStaticProps: GetStaticProps = async ({ locale }) => { | ||
return { | ||
props: { | ||
...(await getServerSideTranslations(locale, ['common'])), | ||
}, | ||
revalidate: 60 * 60 * 24 * 7, | ||
} | ||
} | ||
|
||
export default Forbidden |
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 @@ | ||
import { Container, Stack, Title } from '@mantine/core' | ||
import { type GetServerSideProps, type NextPage } from 'next' | ||
import Head from 'next/head' | ||
import { useSession } from 'next-auth/react' | ||
import { useTranslation } from 'next-i18next' | ||
import { type Route, route } from 'nextjs-routes' | ||
|
||
import { checkPermissions, getServerSession } from '@weareinreach/auth' | ||
import { OrganizationTable } from '@weareinreach/ui/components/data-portal/OrganizationTable' | ||
import { getServerSideTranslations } from '~app/utils/i18n' | ||
|
||
const AdminIndex: NextPage = () => { | ||
const { t } = useTranslation(['common']) | ||
const { data: session, status } = useSession() | ||
return ( | ||
<> | ||
<Head> | ||
<title>{t('page-title.base', { title: 'Data Admin' })}</title> | ||
</Head> | ||
{/* <Container fluid> */} | ||
<Stack spacing={40} miw='80vw'> | ||
<Title order={2}>{t('welcome-name', { name: session?.user?.name })}</Title> | ||
<OrganizationTable /> | ||
</Stack> | ||
{/* </Container> */} | ||
</> | ||
) | ||
} | ||
export default AdminIndex | ||
|
||
export const getServerSideProps: GetServerSideProps = async (ctx) => { | ||
const session = await getServerSession(ctx) | ||
if (!session) { | ||
const callbackRoute: Route = { | ||
pathname: '/admin', | ||
} | ||
const callbackUrl = Buffer.from(JSON.stringify(callbackRoute)).toString('base64url') | ||
return { | ||
redirect: { | ||
destination: route({ pathname: '/401', query: { callbackUrl } }), | ||
permanent: false, | ||
}, | ||
} | ||
} | ||
const hasPermissions = checkPermissions({ session, permissions: 'root', has: 'some' }) | ||
|
||
if (!hasPermissions) { | ||
return { | ||
redirect: { | ||
destination: '/403', | ||
permanent: false, | ||
}, | ||
} | ||
} | ||
|
||
return { | ||
props: { | ||
session, | ||
...(await getServerSideTranslations(ctx.locale, ['common'])), | ||
}, | ||
} | ||
} |
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 |
---|---|---|
|
@@ -72,6 +72,7 @@ | |
"chokidar": ">=3.0.0", | ||
"csstype": "^3.1.2", | ||
"eslint-plugin-import": "npm:eslint-plugin-i@latest", | ||
"eslint-plugin-node": "npm:eslint-plugin-n@latest", | ||
"glob-parent@<5.1.2": "^5.1.2", | ||
"http-cache-semantics@<=4.1.0": "^4.1.1", | ||
"listr2@<5": "^5.0.5", | ||
|
@@ -91,7 +92,6 @@ | |
}, | ||
"patchedDependencies": { | ||
"@crowdin/[email protected]": "patches/@[email protected]", | ||
"[email protected]": "patches/[email protected]", | ||
"[email protected]": "patches/[email protected]", | ||
"[email protected]": "patches/[email protected]" | ||
}, | ||
|
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
Oops, something went wrong.