2018-09-17 13:55:49 -07:00
|
|
|
import React from 'react';
|
|
|
|
import { hot } from 'react-hot-loader';
|
2018-10-03 19:42:20 -07:00
|
|
|
import {
|
|
|
|
Switch,
|
|
|
|
Route,
|
|
|
|
RouteProps,
|
|
|
|
RouteComponentProps,
|
|
|
|
withRouter,
|
|
|
|
matchPath,
|
|
|
|
} from 'react-router';
|
2019-01-23 08:35:03 -08:00
|
|
|
import loadable from '@loadable/component';
|
2018-10-01 14:01:20 -07:00
|
|
|
import AuthRoute from 'components/AuthRoute';
|
2018-10-03 19:42:20 -07:00
|
|
|
import Template, { TemplateProps } from 'components/Template';
|
2019-03-08 13:13:13 -08:00
|
|
|
import ErrorWrap from 'components/ErrorWrap';
|
|
|
|
import Loader from 'components/Loader';
|
|
|
|
import 'styles/style.less';
|
2018-09-17 13:55:49 -07:00
|
|
|
|
|
|
|
// wrap components in loadable...import & they will be split
|
2019-01-31 17:49:13 -08:00
|
|
|
// Make sure you specify chunkname! Must replace slashes with dashes.
|
2019-01-23 08:35:03 -08:00
|
|
|
const opts = { fallback: <Loader size="large" /> };
|
|
|
|
const Home = loadable(() => import('pages/index'), opts);
|
|
|
|
const Create = loadable(() => import('pages/create'), opts);
|
CCRs (#86)
* CCRs API / Models boilerplate
* start on frontend
* backendy things
* Create CCR redux module, integrate API endpoints, create types
* Fix/Cleanup API
* Wire up CreateRequestDraftList
* bounty->target
* Add 'Create Request Flow' MVP
* cleanup
* Tweak filenames
* Simplify migrations
* fix migrations
* CCR Staking MVP
* tslint
* Get Pending Requests into Profile
* Remove staking requirement
* more staking related removals
* MVP Admin integration
* Make RFP when CCR is accepted
* Add pagination to CCRs in Admin
Improve styles for Proposals
* Hookup notifications
Adjust copy
* Simplify ccr->rfp relationship
Add admin approval email
Fixup copy
* Show Message on RFP Detail
Make Header CTAs change based on draft status
Adjust proposal card style
* Bugfix: Show header for non signed in users
* Add 'create a request' to intro
* Profile Created CCRs
RFP CCR attribution
* ignore
* CCR Price in USD (#85)
* init profile tipjar backend
* init profile tipjar frontend
* fix lint
* implement tip jar block
* fix wrapping, hide tip block on self
* init backend proposal tipjar
* init frontend proposal tipjar
* add hide title, fix bug
* uncomment rate limit
* rename vars, use null check
* allow address and view key to be unset
* add api tests
* fix tsc errors
* fix lint
* fix CopyInput styling
* fix migrations
* hide tipping in proposal if address not set
* add tip address to create flow
* redesign campaign block
* fix typo
* init backend changes
* init admin changes
* init frontend changes
* fix backend tests
* update campaign block
* be - init rfp usd changes
* admin - init rfp usd changes
* fe - fully adapt api util functions to usd
* fe - init rfp usd changes
* adapt profile created to usd
* misc usd changes
* add tip jar to dedicated card
* fix tipjar bug
* use zf light logo
* switch to zf grants logo
* hide profile tip jar if address not set
* add comment, run prettier
* conditionally add info icon and tooltip to funding line
* admin - disallow decimals in RFPs
* fe - cover usd string edge case
* add Usd as rfp bounty type
* fix migration order
* fix email bug
* adapt CCRs to USD
* implement CCR preview
* fix tsc
* Copy Updates and UX Tweaks (#87)
* Add default structure to proposal content
* Landing page copy
* Hide contributors tab for v2 proposals
* Minor UX tweaks for Liking/Following/Tipping
* Copy for Tipping Tooltip, proposal explainer for review, and milestone day estimate notice.
* Fix header styles bug and remove commented out styles.
* Revert "like" / "unfollow" hyphenication
* Comment out unused tests related to staking
Increase PROPOSAL_TARGET_MAX in .env.example
* Comment out ccr approval email send until ready
* Adjust styles, copy.
* fix proposal prune test (#88)
* fix USD display in preview, fix non-unique key (#90)
* Pre-stepper explainer for CCRs.
* Tweak styles
* Default content for CCRs
* fix tsc
* CCR approval and rejection emails
* add back admin_approval_ccr email templates
* Link ccr author name to profile in RFPs
* copy tweaks
* copy tweak
* hookup mangle user command
* Fix/add endif in jinja
* fix tests
* review
* fix review
2019-12-05 17:01:02 -08:00
|
|
|
const CreateRequest = loadable(() => import('pages/create-request'), opts);
|
|
|
|
const RequestEdit = loadable(() => import('pages/request-edit'), opts);
|
2019-01-23 08:35:03 -08:00
|
|
|
const ProposalEdit = loadable(() => import('pages/proposal-edit'), opts);
|
|
|
|
const Proposals = loadable(() => import('pages/proposals'), opts);
|
|
|
|
const Proposal = loadable(() => import('pages/proposal'), opts);
|
CCRs (#86)
* CCRs API / Models boilerplate
* start on frontend
* backendy things
* Create CCR redux module, integrate API endpoints, create types
* Fix/Cleanup API
* Wire up CreateRequestDraftList
* bounty->target
* Add 'Create Request Flow' MVP
* cleanup
* Tweak filenames
* Simplify migrations
* fix migrations
* CCR Staking MVP
* tslint
* Get Pending Requests into Profile
* Remove staking requirement
* more staking related removals
* MVP Admin integration
* Make RFP when CCR is accepted
* Add pagination to CCRs in Admin
Improve styles for Proposals
* Hookup notifications
Adjust copy
* Simplify ccr->rfp relationship
Add admin approval email
Fixup copy
* Show Message on RFP Detail
Make Header CTAs change based on draft status
Adjust proposal card style
* Bugfix: Show header for non signed in users
* Add 'create a request' to intro
* Profile Created CCRs
RFP CCR attribution
* ignore
* CCR Price in USD (#85)
* init profile tipjar backend
* init profile tipjar frontend
* fix lint
* implement tip jar block
* fix wrapping, hide tip block on self
* init backend proposal tipjar
* init frontend proposal tipjar
* add hide title, fix bug
* uncomment rate limit
* rename vars, use null check
* allow address and view key to be unset
* add api tests
* fix tsc errors
* fix lint
* fix CopyInput styling
* fix migrations
* hide tipping in proposal if address not set
* add tip address to create flow
* redesign campaign block
* fix typo
* init backend changes
* init admin changes
* init frontend changes
* fix backend tests
* update campaign block
* be - init rfp usd changes
* admin - init rfp usd changes
* fe - fully adapt api util functions to usd
* fe - init rfp usd changes
* adapt profile created to usd
* misc usd changes
* add tip jar to dedicated card
* fix tipjar bug
* use zf light logo
* switch to zf grants logo
* hide profile tip jar if address not set
* add comment, run prettier
* conditionally add info icon and tooltip to funding line
* admin - disallow decimals in RFPs
* fe - cover usd string edge case
* add Usd as rfp bounty type
* fix migration order
* fix email bug
* adapt CCRs to USD
* implement CCR preview
* fix tsc
* Copy Updates and UX Tweaks (#87)
* Add default structure to proposal content
* Landing page copy
* Hide contributors tab for v2 proposals
* Minor UX tweaks for Liking/Following/Tipping
* Copy for Tipping Tooltip, proposal explainer for review, and milestone day estimate notice.
* Fix header styles bug and remove commented out styles.
* Revert "like" / "unfollow" hyphenication
* Comment out unused tests related to staking
Increase PROPOSAL_TARGET_MAX in .env.example
* Comment out ccr approval email send until ready
* Adjust styles, copy.
* fix proposal prune test (#88)
* fix USD display in preview, fix non-unique key (#90)
* Pre-stepper explainer for CCRs.
* Tweak styles
* Default content for CCRs
* fix tsc
* CCR approval and rejection emails
* add back admin_approval_ccr email templates
* Link ccr author name to profile in RFPs
* copy tweaks
* copy tweak
* hookup mangle user command
* Fix/add endif in jinja
* fix tests
* review
* fix review
2019-12-05 17:01:02 -08:00
|
|
|
const Ccr = loadable(() => import('pages/ccr'), opts);
|
2018-10-01 14:01:20 -07:00
|
|
|
const Auth = loadable(() => import('pages/auth'));
|
2019-01-23 08:35:03 -08:00
|
|
|
const SignOut = loadable(() => import('pages/sign-out'), opts);
|
|
|
|
const Profile = loadable(() => import('pages/profile'), opts);
|
|
|
|
const Settings = loadable(() => import('pages/settings'), opts);
|
|
|
|
const Exception = loadable(() => import('pages/exception'), opts);
|
2018-10-18 17:59:49 -07:00
|
|
|
const Tos = loadable(() => import('pages/tos'));
|
2019-01-23 08:35:03 -08:00
|
|
|
const About = loadable(() => import('pages/about'), opts);
|
|
|
|
const Privacy = loadable(() => import('pages/privacy'), opts);
|
|
|
|
const Contact = loadable(() => import('pages/contact'), opts);
|
|
|
|
const CodeOfConduct = loadable(() => import('pages/code-of-conduct'), opts);
|
|
|
|
const VerifyEmail = loadable(() => import('pages/email-verify'), opts);
|
|
|
|
const Callback = loadable(() => import('pages/callback'), opts);
|
|
|
|
const RecoverEmail = loadable(() => import('pages/email-recover'), opts);
|
|
|
|
const UnsubscribeEmail = loadable(() => import('pages/email-unsubscribe'), opts);
|
2019-02-09 19:03:19 -08:00
|
|
|
const ArbiterEmail = loadable(() => import('pages/email-arbiter'), opts);
|
2019-01-30 09:59:15 -08:00
|
|
|
const RFP = loadable(() => import('pages/rfp'), opts);
|
|
|
|
const RFPs = loadable(() => import('pages/rfps'), opts);
|
2018-09-17 13:55:49 -07:00
|
|
|
|
2018-10-03 19:42:20 -07:00
|
|
|
interface RouteConfig extends RouteProps {
|
|
|
|
route: RouteProps;
|
|
|
|
template: TemplateProps;
|
2018-12-14 11:36:22 -08:00
|
|
|
requiresAuth?: boolean;
|
2018-10-03 19:42:20 -07:00
|
|
|
onlyLoggedIn?: boolean;
|
|
|
|
onlyLoggedOut?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
const routeConfigs: RouteConfig[] = [
|
|
|
|
{
|
|
|
|
// Homepage
|
|
|
|
route: {
|
|
|
|
path: '/',
|
|
|
|
component: Home,
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Home',
|
|
|
|
isHeaderTransparent: true,
|
|
|
|
isFullScreen: true,
|
|
|
|
},
|
|
|
|
},
|
CCRs (#86)
* CCRs API / Models boilerplate
* start on frontend
* backendy things
* Create CCR redux module, integrate API endpoints, create types
* Fix/Cleanup API
* Wire up CreateRequestDraftList
* bounty->target
* Add 'Create Request Flow' MVP
* cleanup
* Tweak filenames
* Simplify migrations
* fix migrations
* CCR Staking MVP
* tslint
* Get Pending Requests into Profile
* Remove staking requirement
* more staking related removals
* MVP Admin integration
* Make RFP when CCR is accepted
* Add pagination to CCRs in Admin
Improve styles for Proposals
* Hookup notifications
Adjust copy
* Simplify ccr->rfp relationship
Add admin approval email
Fixup copy
* Show Message on RFP Detail
Make Header CTAs change based on draft status
Adjust proposal card style
* Bugfix: Show header for non signed in users
* Add 'create a request' to intro
* Profile Created CCRs
RFP CCR attribution
* ignore
* CCR Price in USD (#85)
* init profile tipjar backend
* init profile tipjar frontend
* fix lint
* implement tip jar block
* fix wrapping, hide tip block on self
* init backend proposal tipjar
* init frontend proposal tipjar
* add hide title, fix bug
* uncomment rate limit
* rename vars, use null check
* allow address and view key to be unset
* add api tests
* fix tsc errors
* fix lint
* fix CopyInput styling
* fix migrations
* hide tipping in proposal if address not set
* add tip address to create flow
* redesign campaign block
* fix typo
* init backend changes
* init admin changes
* init frontend changes
* fix backend tests
* update campaign block
* be - init rfp usd changes
* admin - init rfp usd changes
* fe - fully adapt api util functions to usd
* fe - init rfp usd changes
* adapt profile created to usd
* misc usd changes
* add tip jar to dedicated card
* fix tipjar bug
* use zf light logo
* switch to zf grants logo
* hide profile tip jar if address not set
* add comment, run prettier
* conditionally add info icon and tooltip to funding line
* admin - disallow decimals in RFPs
* fe - cover usd string edge case
* add Usd as rfp bounty type
* fix migration order
* fix email bug
* adapt CCRs to USD
* implement CCR preview
* fix tsc
* Copy Updates and UX Tweaks (#87)
* Add default structure to proposal content
* Landing page copy
* Hide contributors tab for v2 proposals
* Minor UX tweaks for Liking/Following/Tipping
* Copy for Tipping Tooltip, proposal explainer for review, and milestone day estimate notice.
* Fix header styles bug and remove commented out styles.
* Revert "like" / "unfollow" hyphenication
* Comment out unused tests related to staking
Increase PROPOSAL_TARGET_MAX in .env.example
* Comment out ccr approval email send until ready
* Adjust styles, copy.
* fix proposal prune test (#88)
* fix USD display in preview, fix non-unique key (#90)
* Pre-stepper explainer for CCRs.
* Tweak styles
* Default content for CCRs
* fix tsc
* CCR approval and rejection emails
* add back admin_approval_ccr email templates
* Link ccr author name to profile in RFPs
* copy tweaks
* copy tweak
* hookup mangle user command
* Fix/add endif in jinja
* fix tests
* review
* fix review
2019-12-05 17:01:02 -08:00
|
|
|
{
|
|
|
|
// Create request
|
|
|
|
route: {
|
|
|
|
path: '/create-request',
|
|
|
|
component: CreateRequest,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Create a Request',
|
|
|
|
},
|
|
|
|
onlyLoggedIn: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Request edit page
|
|
|
|
route: {
|
|
|
|
path: '/ccrs/:id/edit',
|
|
|
|
component: RequestEdit,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Edit Request',
|
|
|
|
isFullScreen: true,
|
|
|
|
hideFooter: true,
|
|
|
|
},
|
|
|
|
onlyLoggedIn: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Request view page
|
|
|
|
route: {
|
|
|
|
path: '/ccrs/:id',
|
|
|
|
component: Ccr,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'View Request',
|
|
|
|
isFullScreen: true,
|
|
|
|
hideFooter: true,
|
|
|
|
},
|
|
|
|
onlyLoggedIn: true,
|
|
|
|
},
|
2018-10-03 19:42:20 -07:00
|
|
|
{
|
|
|
|
// Create proposal
|
|
|
|
route: {
|
|
|
|
path: '/create',
|
|
|
|
component: Create,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Create a Proposal',
|
|
|
|
},
|
2018-11-13 08:07:09 -08:00
|
|
|
onlyLoggedIn: true,
|
2018-10-03 19:42:20 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
// Browse proposals
|
|
|
|
route: {
|
|
|
|
path: '/proposals',
|
|
|
|
component: Proposals,
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Browse proposals',
|
|
|
|
},
|
|
|
|
},
|
2018-11-13 08:07:09 -08:00
|
|
|
{
|
|
|
|
// Proposal edit page
|
|
|
|
route: {
|
|
|
|
path: '/proposals/:id/edit',
|
|
|
|
component: ProposalEdit,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Edit proposal',
|
2018-11-13 14:51:02 -08:00
|
|
|
isFullScreen: true,
|
|
|
|
hideFooter: true,
|
2018-11-13 08:07:09 -08:00
|
|
|
},
|
|
|
|
onlyLoggedIn: true,
|
|
|
|
},
|
2018-10-03 19:42:20 -07:00
|
|
|
{
|
|
|
|
// Proposal detail page
|
|
|
|
route: {
|
|
|
|
path: '/proposals/:id',
|
|
|
|
component: Proposal,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Proposal',
|
|
|
|
},
|
|
|
|
},
|
2019-01-30 09:59:15 -08:00
|
|
|
{
|
|
|
|
// RFP list page,
|
|
|
|
route: {
|
|
|
|
path: '/requests',
|
|
|
|
component: RFPs,
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Requests',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// RFP detail page
|
|
|
|
route: {
|
|
|
|
path: '/requests/:id',
|
|
|
|
component: RFP,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Request',
|
|
|
|
},
|
|
|
|
},
|
2018-10-03 19:42:20 -07:00
|
|
|
{
|
|
|
|
// Self profile
|
|
|
|
route: {
|
|
|
|
path: '/profile',
|
|
|
|
component: Profile,
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Profile',
|
|
|
|
},
|
|
|
|
onlyLoggedIn: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Settings page
|
|
|
|
route: {
|
|
|
|
path: '/profile/settings',
|
|
|
|
component: Settings,
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Settings',
|
|
|
|
},
|
|
|
|
onlyLoggedIn: true,
|
|
|
|
},
|
2018-10-18 17:59:49 -07:00
|
|
|
{
|
|
|
|
// Terms of Service page
|
|
|
|
route: {
|
|
|
|
path: '/tos',
|
|
|
|
component: Tos,
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Terms of Service',
|
|
|
|
},
|
|
|
|
onlyLoggedIn: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// About page
|
|
|
|
route: {
|
|
|
|
path: '/about',
|
|
|
|
component: About,
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'About',
|
|
|
|
},
|
|
|
|
onlyLoggedIn: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Privacy page
|
|
|
|
route: {
|
|
|
|
path: '/privacy',
|
|
|
|
component: Privacy,
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Privacy Policy',
|
|
|
|
},
|
|
|
|
onlyLoggedIn: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Contact page
|
|
|
|
route: {
|
|
|
|
path: '/contact',
|
|
|
|
component: Contact,
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Contact',
|
|
|
|
},
|
|
|
|
onlyLoggedIn: false,
|
|
|
|
},
|
2019-01-18 09:21:03 -08:00
|
|
|
{
|
|
|
|
// Code of Conduct page
|
|
|
|
route: {
|
|
|
|
path: '/code-of-conduct',
|
|
|
|
component: CodeOfConduct,
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Code of Conduct',
|
|
|
|
},
|
|
|
|
onlyLoggedIn: false,
|
|
|
|
},
|
2018-10-03 19:42:20 -07:00
|
|
|
{
|
|
|
|
// User profile
|
|
|
|
route: {
|
|
|
|
path: '/profile/:id',
|
|
|
|
component: Profile,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Profile',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2018-12-17 10:33:33 -08:00
|
|
|
// Sign out
|
|
|
|
route: {
|
|
|
|
path: '/auth/sign-out',
|
|
|
|
component: SignOut,
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Signed out',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Sign in / sign up / recover (nested routes)
|
2018-10-03 19:42:20 -07:00
|
|
|
route: {
|
|
|
|
path: '/auth',
|
|
|
|
component: Auth,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Sign in',
|
|
|
|
},
|
|
|
|
onlyLoggedOut: true,
|
|
|
|
},
|
|
|
|
{
|
2018-12-17 10:33:33 -08:00
|
|
|
// Verify email
|
2018-10-03 19:42:20 -07:00
|
|
|
route: {
|
2018-12-17 10:33:33 -08:00
|
|
|
path: '/email/verify',
|
|
|
|
component: VerifyEmail,
|
2018-10-03 19:42:20 -07:00
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
2018-12-17 10:33:33 -08:00
|
|
|
title: 'Verify email',
|
2018-10-03 19:42:20 -07:00
|
|
|
},
|
2018-11-02 09:07:06 -07:00
|
|
|
},
|
|
|
|
{
|
2018-12-17 10:33:33 -08:00
|
|
|
// Recover email
|
2018-11-02 09:07:06 -07:00
|
|
|
route: {
|
2018-12-17 10:33:33 -08:00
|
|
|
path: '/email/recover',
|
|
|
|
component: RecoverEmail,
|
2018-11-02 09:07:06 -07:00
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
2019-01-16 14:26:45 -08:00
|
|
|
title: 'Recover email',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Unsubscribe email
|
|
|
|
route: {
|
|
|
|
path: '/email/unsubscribe',
|
|
|
|
component: UnsubscribeEmail,
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Unsubscribe email',
|
2018-11-02 09:07:06 -07:00
|
|
|
},
|
2019-01-02 10:23:02 -08:00
|
|
|
},
|
2019-02-09 19:03:19 -08:00
|
|
|
{
|
|
|
|
// Arbiter email
|
|
|
|
route: {
|
|
|
|
path: '/email/arbiter',
|
|
|
|
component: ArbiterEmail,
|
|
|
|
exact: true,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Unsubscribe email',
|
|
|
|
},
|
|
|
|
},
|
2019-01-02 10:23:02 -08:00
|
|
|
{
|
|
|
|
// oauth callbacks
|
|
|
|
route: {
|
|
|
|
path: '/callback',
|
|
|
|
component: Callback,
|
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'OAuth Callback',
|
|
|
|
},
|
2018-10-03 19:42:20 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
// 404
|
|
|
|
route: {
|
|
|
|
path: '/*',
|
2018-10-19 15:03:37 -07:00
|
|
|
render: () => <Exception code="404" />,
|
2018-10-03 19:42:20 -07:00
|
|
|
},
|
|
|
|
template: {
|
|
|
|
title: 'Page not found',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
type Props = RouteComponentProps<any>;
|
|
|
|
|
|
|
|
class Routes extends React.PureComponent<Props> {
|
2018-09-17 13:55:49 -07:00
|
|
|
render() {
|
2018-10-03 19:42:20 -07:00
|
|
|
const { pathname } = this.props.location;
|
2018-10-19 15:03:37 -07:00
|
|
|
const currentRoute =
|
|
|
|
routeConfigs.find(config => !!matchPath(pathname, config.route)) ||
|
|
|
|
routeConfigs[routeConfigs.length - 1];
|
2018-10-03 19:42:20 -07:00
|
|
|
const routeComponents = routeConfigs.map(config => {
|
|
|
|
const { route, onlyLoggedIn, onlyLoggedOut } = config;
|
|
|
|
if (onlyLoggedIn || onlyLoggedOut) {
|
2019-01-23 12:48:22 -08:00
|
|
|
return (
|
|
|
|
<AuthRoute
|
|
|
|
key={route.path as string}
|
|
|
|
onlyLoggedOut={onlyLoggedOut}
|
|
|
|
{...route}
|
|
|
|
/>
|
|
|
|
);
|
2018-10-03 19:42:20 -07:00
|
|
|
} else {
|
2019-01-23 12:48:22 -08:00
|
|
|
return <Route key={route.path as string} {...route} />;
|
2018-10-03 19:42:20 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-09-17 13:55:49 -07:00
|
|
|
return (
|
2018-10-03 19:42:20 -07:00
|
|
|
<Template {...currentRoute.template}>
|
2019-03-08 13:13:13 -08:00
|
|
|
<ErrorWrap key={currentRoute.route.path as string}>
|
|
|
|
<Switch>{routeComponents}</Switch>
|
|
|
|
</ErrorWrap>
|
2018-10-03 19:42:20 -07:00
|
|
|
</Template>
|
2018-09-17 13:55:49 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-03 19:42:20 -07:00
|
|
|
const RouterAwareRoutes = withRouter(Routes);
|
|
|
|
export default hot(module)(RouterAwareRoutes);
|