Skip to content

Commit

Permalink
Merge pull request #20 from akaevjumgal/optimized_routing
Browse files Browse the repository at this point in the history
Optimized routing in project
  • Loading branch information
IsaakNazar authored Jul 2, 2018
2 parents ebf0c10 + 8ff33d5 commit c9cb7a6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class App extends Component {
return (
<div>
<Router>
<User userRole="hr" />{/*Put the department in which you develop: head, hr, pm, interviewer*/}
<User userRole="head" />{/*Put the department in which you develop: head, hr, pm, interviewer*/}
</Router>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
html, body {
margin: 0;
height: 100%;
font-family: 'Roboto', sans-serif, Tahoma;
}
.container {
display: flex;
Expand Down
18 changes: 10 additions & 8 deletions src/scenes/head/HeadScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Navigation from '../../scenes/general/Navigation';
import CreatePosition from '../../scenes/head/CreatePosition';
import Archive from '../../scenes/head/Archive';
import Statistics from '../../scenes/general/Statistics';
import SpecifyTheRoute from '../../utils/Route';
import '../../index.css';

export default class HeadScene extends Component {
Expand All @@ -19,10 +20,7 @@ export default class HeadScene extends Component {
<div className="content">
<Switch>
<Route path="/" component={OpenedPositions} exact/>
<Route path="/create_position" component={CreatePosition}/>
<Route path="/opened_positions" component={OpenedPositions}/>
<Route path="/archive" component={Archive}/>
<Route path="/statistics" component={Statistics}/>
<SpecifyTheRoute route={HeadNav} />
<Route component={Error}/>
</Switch>
</div>
Expand All @@ -35,18 +33,22 @@ export default class HeadScene extends Component {
const HeadNav = [
{
name: 'Создать позицию',
path: '/create_position'
path: '/create_position',
component: CreatePosition
},
{
name: 'Открытые Позиции',
path: '/opened_positions'
path: '/opened_positions',
component: OpenedPositions
},
{
name: 'Архив Позиций',
path: '/archive'
path: '/archive',
component: Archive
},
{
name: 'Статистика',
path: '/statistics'
path: '/statistics',
component: Statistics
}
]
38 changes: 20 additions & 18 deletions src/scenes/hr/HRScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,53 @@ import Reserve from './Reserve';
import Statistics from '../general/Statistics';
import Error from '../general/Error';
import InterviewList from './InterviewList';
import SpecifyTheRoute from '../../utils/Route';

const HRNav = [
{
name: "Запросы",
path: "/list_of_positions",
component: PositionList
},
{
name: "Создать вакансию",
path: "/create_vacancy"
path: "/create_vacancy",
component: CreateVacancy
},
{
name: "Вакансии",
path: "/opened_vacancies"
path: "/opened_vacancies",
component: OpenedVacancies
},
{
name: "Кандидаты",
path: "/list_of_candidates"
path: "/list_of_candidates",
component: CandidateList
},
{
name: "Резерв",
path: "/reserve"
path: "/reserve",
component: Reserve
},
{
name: "Стажеры",
path: "/list_of_interns"
path: "/list_of_interns",
component: InternList
},
{
name: "Статистика",
path: "/statistics"
path: "/statistics",
component: Statistics
},
{
name: "Интервью",
path: "/list_of_interviews"
path: "/list_of_interviews",
component: InterviewList
},
{
name: "Уведомления",
path: "/notifications"
path: "/notifications",
component: Notifications
}
];

Expand All @@ -61,16 +71,8 @@ export default class HRScene extends Component {

<div className="content">
<Switch>
<Route path="/" component={PositionList} exact/>
<Route path="/list_of_positions" component={PositionList}/>
<Route path="/create_vacancy" component={CreateVacancy}/>
<Route path="/opened_vacancies" component={OpenedVacancies}/>
<Route path="/list_of_candidates" component={CandidateList}/>
<Route path="/reserve" component={Reserve}/>
<Route path="/list_of_interns" component={InternList}/>
<Route path="/statistics" component={Statistics}/>
<Route path="/list_of_interviews" component={InterviewList}/>
<Route path="/notifications" component={Notifications}/>
<Route path="/" component={OpenedVacancies} exact />
<SpecifyTheRoute route={HRNav} />
<Route component={Error}/>
</Switch>
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/utils/Route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import { Route } from 'react-router-dom';

const SpecifyTheRoute = (props) => {
return props.route.map((item, index) => (
<Route key={index} path={item.path} component={item.component} />
))
}

export default SpecifyTheRoute;

0 comments on commit c9cb7a6

Please sign in to comment.