From 4471fef74dfe312a8cf6a1440f5a703e897af136 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Wed, 7 Oct 2020 23:25:52 +0300 Subject: feat: wire modal routes --- src/containers/Page/Router.tsx | 48 +++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'src/containers/Page/Router.tsx') diff --git a/src/containers/Page/Router.tsx b/src/containers/Page/Router.tsx index 7067eea..abf8f00 100644 --- a/src/containers/Page/Router.tsx +++ b/src/containers/Page/Router.tsx @@ -1,5 +1,8 @@ import React from 'react'; -import { Switch, Route } from 'react-router-dom'; +import { Switch, Route, useLocation } from 'react-router-dom'; +import { Location } from 'history'; + +import PollCreation from '../PollCreation/PollCreation'; const Profile = React.lazy(() => import('../Profile/Profile')); const Feed = React.lazy(() => import('../Feed/Feed')); @@ -7,20 +10,35 @@ const Login = React.lazy(() => import('../Login/Login')); const Registration = React.lazy(() => import('../Registration/Registration')); const Home = React.lazy(() => import('../Home/Home')); const Notifications = React.lazy(() => import('../Notifications/Notifications')); -const PollCreation = React.lazy(() => import('../PollCreation/PollCreation')); - - -const Router: React.FC = React.memo(() => ( - - - - - - - - - -)); + +export interface LocationState { + background?: Location; +} + +const Router: React.FC = React.memo(() => { + const location = useLocation(); + const background = location.state && location.state.background; + + const ModalSwitch = ( + + + + ); + + return ( + <> + {background && ModalSwitch} + + + + + + + + + + ); +}); export default Router; -- cgit v1.2.3 From 4a86d5c3f0b023c6e4e7862f2a49301ef8b4d3f7 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 8 Oct 2020 13:33:39 +0300 Subject: feat: allow reaching modal routes from outside --- src/containers/Page/Router.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/containers/Page/Router.tsx') diff --git a/src/containers/Page/Router.tsx b/src/containers/Page/Router.tsx index abf8f00..7c3a418 100644 --- a/src/containers/Page/Router.tsx +++ b/src/containers/Page/Router.tsx @@ -27,7 +27,7 @@ const Router: React.FC = React.memo(() => { return ( <> - {background && ModalSwitch} + {ModalSwitch} -- cgit v1.2.3