Skip to content

Commit

Permalink
Merge pull request #220 from heritagemap/refactoring/routing
Browse files Browse the repository at this point in the history
Добавила костанту для коротких ссылок
  • Loading branch information
Julia-Lavrova authored Apr 20, 2021
2 parents 32be6e3 + 4cb502d commit 2030bdf
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 72 deletions.
79 changes: 7 additions & 72 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,85 +11,20 @@ import DefaultMap from 'components/DefaultMap';
import Sidebar from 'components/Sidebar';
import MonumentPage from 'components/MonumentPage';
import RedirectWithZoom from 'components/RedirectWithZoom';
import shortLinks from 'constants/shortLinks';
import LinkInterface from 'interfaces/Link';

import './App.scss';

const App = () => (
<Router>
<main>
<Switch>
<Route path="/moscow">
<Redirect to="/lat/55.744654/lon/37.624991/zoom/12" />
</Route>

<Route path="/saint-petersburg">
<Redirect to="/lat/59.935324/lon/30.314125/zoom/11" />
</Route>

<Route path="/ekaterinburg">
<Redirect to="/lat/56.839542/lon/60.633391/zoom/11" />
</Route>

<Route path="/novosibirsk">
<Redirect to="/lat/55.028348/lon/82.931337/zoom/11" />
</Route>

<Route path="/nizhny-novgorod">
<Redirect to="/lat/56.301011/lon/43.995229/zoom/10" />
</Route>

<Route path="/kazan">
<Redirect to="/lat/55.790216/lon/49.125194/zoom/12" />
</Route>

<Route path="/samara">
<Redirect to="/lat/53.188109/lon/50.110306/zoom/13" />
</Route>

<Route path="/orenburg">
<Redirect to="/lat/51.770342/lon/55.098720/zoom/13" />
</Route>

<Route path="/arzamas">
<Redirect to="/lat/55.386373/lon/43.817099/zoom/12" />
</Route>

<Route path="/balakhna">
<Redirect to="/lat/56.492938/lon/43.611212/zoom/12" />
</Route>

<Route path="/bogorodsk">
<Redirect to="/lat/56.101523/lon/43.516550/zoom/12" />
</Route>

<Route path="/bolshoe-murashkino">
<Redirect to="/lat/55.781787/lon/44.774134/zoom/12" />
</Route>

<Route path="/vyksa">
<Redirect to="/lat/55.318686/lon/42.186628/zoom/12" />
</Route>

<Route path="/gorbatov">
<Redirect to="/lat/56.131309/lon/43.058318/zoom/12" />
</Route>

<Route path="/lyskovo">
<Redirect to="/lat/56.037971/lon/45.0478428/zoom/12" />
</Route>

<Route path="/gorodets">
<Redirect to="/lat/56.644823/lon/43.469353/zoom/12" />
</Route>

<Route path="/dzerzhinsk">
<Redirect to="/lat/56.238716/lon/43.461149/zoom/12" />
</Route>

<Route path="/pavlovo">
<Redirect to="/lat/55.963602/lon/43.070018/zoom/12" />
</Route>

{shortLinks.map((link: LinkInterface) => (
<Route path={link.path}>
<Redirect to={link.to} />
</Route>
))}
<Route path="/lat/:lat/lon/:lon/zoom/:zoom/:id?">
<Map />
<Sidebar />
Expand Down
78 changes: 78 additions & 0 deletions src/constants/shortLinks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import LinkInterface from 'interfaces/Link';

const shortLinks: LinkInterface[] = [
{
path: '/moscow',
to: '/lat/55.744654/lon/37.624991/zoom/12',
},
{
path: '/saint-petersburg',
to: '/lat/59.935324/lon/30.314125/zoom/11',
},
{
path: '/ekaterinburg',
to: '/lat/56.839542/lon/60.633391/zoom/11',
},
{
path: '/novosibirsk',
to: '/lat/55.028348/lon/82.931337/zoom/11',
},
{
path: '/nizhny-novgorod',
to: '/lat/56.301011/lon/43.995229/zoom/10',
},
{
path: '/kazan',
to: '/lat/55.790216/lon/49.125194/zoom/12',
},
{
path: '/samara',
to: '/lat/53.188109/lon/50.110306/zoom/13',
},
{
path: '/orenburg',
to: '/lat/51.770342/lon/55.098720/zoom/13',
},
{
path: '/arzamas',
to: '/lat/55.386373/lon/43.817099/zoom/12',
},
{
path: '/balakhna',
to: '/lat/56.492938/lon/43.611212/zoom/12',
},
{
path: '/bogorodsk',
to: '/lat/56.101523/lon/43.516550/zoom/12',
},
{
path: '/bolshoe-murashkino',
to: '/lat/55.781787/lon/44.774134/zoom/12',
},
{
path: '/vyksa',
to: '/lat/55.318686/lon/42.186628/zoom/12',
},
{
path: '/gorbatov',
to: '/lat/56.131309/lon/43.058318/zoom/12',
},
{
path: '/lyskovo',
to: '/lat/56.037971/lon/45.0478428/zoom/12',
},
{
path: '/gorodets',
to: '/lat/56.644823/lon/43.469353/zoom/12',
},
{
path: '/dzerzhinsk',
to: '/lat/56.238716/lon/43.461149/zoom/12',
},
{
path: '/pavlovo',
to: '/lat/55.963602/lon/43.070018/zoom/12',
},
];

export default shortLinks;
4 changes: 4 additions & 0 deletions src/interfaces/Link.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default interface LinkInterface {
path: string,
to: string,
}

0 comments on commit 2030bdf

Please sign in to comment.