Skip to content

Commit 054d5e2

Browse files
author
Antonio Contreras LEMONCODE
committed
Create employee list and project list components
1 parent 0913d87 commit 054d5e2

12 files changed

Lines changed: 94 additions & 11 deletions

File tree

src/core/router/router.component.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ 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, SubmoduleListScene } from 'scenes';
5+
import {
6+
LoginScene,
7+
SubmoduleListScene,
8+
ProjectListScene,
9+
EmployeeListScene,
10+
} from 'scenes';
611

712
export const RouterComponent: React.FunctionComponent = () => {
813
return (
@@ -18,6 +23,16 @@ export const RouterComponent: React.FunctionComponent = () => {
1823
path={routes.submoduleList}
1924
component={SubmoduleListScene}
2025
/>
26+
<Route
27+
exact={true}
28+
path={routes.projects}
29+
component={ProjectListScene}
30+
/>
31+
<Route
32+
exact={true}
33+
path={routes.employees}
34+
component={EmployeeListScene}
35+
/>
2136
</Switch>
2237
</HashRouter>
2338
);

src/core/router/routes.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
interface BaseRoutes {
22
root: string;
33
login: string;
4-
time: string;
54
submoduleList: string;
65
projects: string;
76
editProject: string;
@@ -12,12 +11,11 @@ interface BaseRoutes {
1211
const baseRoutes: BaseRoutes = {
1312
root: '/',
1413
login: '/login',
15-
time: '/time',
1614
submoduleList: '/submodule-list',
17-
projects: './projects',
18-
editProject: './projects/:id',
19-
employees: './employees',
20-
editEmployee: './employees/:id',
15+
projects: '/projects',
16+
editProject: '/projects/:id',
17+
employees: '/employees',
18+
editEmployee: '/employees/:id',
2119
};
2220

2321
type Routes = Omit<BaseRoutes, 'editProject' | 'editEmployee'>;
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 EmployeeListComponent: React.FunctionComponent = () => {
4+
return <h1>Hello Employee list component</h1>;
5+
};

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';

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: 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 ProjectListComponent: React.FunctionComponent = () => {
4+
return <h1>Hello Project List component</h1>;
5+
};
Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
import React from 'react';
2+
import { useHistory } from 'react-router-dom';
3+
import { routes } from 'core/router';
24

3-
export const SumoduleListComponent: React.FC = () => {
4-
return <h1>Hello Submodule List</h1>;
5+
export const SumoduleListComponent: React.FunctionComponent = () => {
6+
const history = useHistory();
7+
const goToProjectList = (
8+
event: React.MouseEvent<HTMLParagraphElement, MouseEvent>
9+
) => {
10+
event.preventDefault();
11+
history.push({
12+
pathname: routes.projects,
13+
});
14+
};
15+
16+
const goToEmployeeList = (
17+
event: React.MouseEvent<HTMLParagraphElement, MouseEvent>
18+
) => {
19+
event.preventDefault();
20+
history.push({
21+
pathname: routes.employees,
22+
});
23+
};
24+
25+
return (
26+
// Pending to use dashboard component
27+
<>
28+
<h1>Hello Submodule List</h1>
29+
<p onClick={goToProjectList}>Go to Project list page</p>
30+
<p onClick={goToEmployeeList}>Go to Employee list page</p>
31+
</>
32+
);
533
};

src/scenes/employee-list.scene.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
import { AppLayout } from 'layouts';
3+
import { EmployeeListComponent } from 'pods/employee-list';
4+
5+
export const EmployeeListScene: React.FunctionComponent = () => {
6+
return (
7+
<AppLayout>
8+
<EmployeeListComponent />
9+
</AppLayout>
10+
);
11+
};

src/scenes/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
export * from './login.scene';
22
export * from './submodule-list.scene';
3+
export * from './project-list.scene';
4+
export * from './employee-list.scene';

0 commit comments

Comments
 (0)