Skip to content

Commit cfbad1f

Browse files
authored
Merge pull request #1 from Lemoncode/feature/Create_basic_pods_and_new_routes
Feature/create basic pods and new routes
2 parents fffbe04 + e663c45 commit cfbad1f

44 files changed

Lines changed: 203 additions & 998 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/core/router/router.component.tsx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import React from 'react';
22
import { HashRouter, Switch, Route } from 'react-router-dom';
33
import { AuthRouterComponent } from 'common-app/auth';
44
import { routes } from './routes';
5-
import { LoginScene, TimeScene } from 'scenes';
5+
import {
6+
LoginScene,
7+
SubmoduleListScene,
8+
ProjectListScene,
9+
EmployeeListScene,
10+
ProjectScene,
11+
EmployeeScene,
12+
} from 'scenes';
613

714
export const RouterComponent: React.FunctionComponent = () => {
815
return (
@@ -15,8 +22,28 @@ export const RouterComponent: React.FunctionComponent = () => {
1522
/>
1623
<AuthRouterComponent
1724
exact={true}
18-
path={routes.time}
19-
component={TimeScene}
25+
path={routes.submoduleList}
26+
component={SubmoduleListScene}
27+
/>
28+
<Route
29+
exact={true}
30+
path={routes.projects}
31+
component={ProjectListScene}
32+
/>
33+
<Route
34+
exact={true}
35+
path={routes.employees}
36+
component={EmployeeListScene}
37+
/>
38+
<Route
39+
exact={true}
40+
path={routes.editProject()}
41+
component={ProjectScene}
42+
/>
43+
<Route
44+
exact={true}
45+
path={routes.editEmployee()}
46+
component={EmployeeScene}
2047
/>
2148
</Switch>
2249
</HashRouter>

src/core/router/routes.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
1+
import { generatePath } from 'react-router-dom';
2+
13
interface BaseRoutes {
24
root: string;
35
login: string;
4-
time: string;
6+
submoduleList: string;
7+
projects: string;
8+
editProject: string;
9+
employees: string;
10+
editEmployee: string;
511
}
612

713
const baseRoutes: BaseRoutes = {
814
root: '/',
915
login: '/login',
10-
time: '/time',
16+
submoduleList: '/submodule-list',
17+
projects: '/projects',
18+
editProject: '/projects/:id',
19+
employees: '/employees',
20+
editEmployee: '/employees/:id',
1121
};
1222

13-
type Routes = Omit<BaseRoutes, ''>;
23+
interface Routes extends Omit<BaseRoutes, 'editProject' | 'editEmployee'> {
24+
editProject: (id?: string) => string;
25+
editEmployee: (id?: string) => string;
26+
}
1427

1528
export const routes: Routes = {
1629
...baseRoutes,
30+
editProject: id =>
31+
id ? generatePath(baseRoutes.editProject, { id }) : baseRoutes.editProject,
32+
editEmployee: id =>
33+
id
34+
? generatePath(baseRoutes.editEmployee, { id })
35+
: baseRoutes.editEmployee,
1736
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { useHistory } from 'react-router-dom';
3+
import { routes } from 'core/router';
4+
5+
export const EmployeeListComponent: React.FunctionComponent = () => {
6+
const history = useHistory();
7+
const goToEmployee = (
8+
event: React.MouseEvent<HTMLParagraphElement, MouseEvent>
9+
) => {
10+
event.preventDefault();
11+
history.push({
12+
pathname: routes.editEmployee('1'),
13+
});
14+
};
15+
return (
16+
<>
17+
<h1>Hello Employee list component</h1>
18+
<p onClick={goToEmployee}>Go to edit employee page</p>
19+
</>
20+
);
21+
};

src/pods/employee-list/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './employee-list.component';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from 'react';
2+
3+
export const EmployeeComponent: React.FunctionComponent = () => {
4+
return <h1>Hello Edit employee component</h1>;
5+
};

src/pods/employee/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './employee.component';

src/pods/login/login.container.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const LoginContainer: React.FunctionComponent = () => {
2121
const userSession = mapLoginResponseToUserSession();
2222
userSession.userName = 'Admin';
2323
setUserSession(userSession);
24-
history.push(routes.time);
24+
history.push(routes.submoduleList);
2525
} else {
2626
showMessage(literals.messages.errors.invalidLogin, 'error');
2727
}

src/pods/project-list/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './project-list.component';
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { useHistory } from 'react-router-dom';
3+
import { routes } from 'core/router';
4+
5+
export const ProjectListComponent: React.FunctionComponent = () => {
6+
const history = useHistory();
7+
const goToProject = (
8+
event: React.MouseEvent<HTMLParagraphElement, MouseEvent>
9+
) => {
10+
event.preventDefault();
11+
history.push({
12+
pathname: routes.editProject('1'),
13+
});
14+
};
15+
return (
16+
<>
17+
<h1>Hello Project list component</h1>
18+
<p onClick={goToProject}>Go to edit project component</p>
19+
</>
20+
);
21+
};

src/pods/project/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './project.component';

0 commit comments

Comments
 (0)