-
Notifications
You must be signed in to change notification settings - Fork 3
Feature/implement employee list #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
antonio06
wants to merge
19
commits into
master
Choose a base branch
from
feature/implement-employee-list
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c1a335e
config graphql client
nasdan cee690c
implement delete method
nasdan f281c07
implement get employee by id
nasdan c3b7c80
implement employee insert
nasdan 27d1b34
Fix employee api
0b2c6ec
Refactor employee components and remove mock data
a5ad030
Implement saveProjectSummaryList and mappers
6aab104
Fix employee container logic
7eb5db2
Fix view model and api model
796779d
Work in progress
2a6caee
Fix query
32ed3de
Fix view model and mappers
eedf56a
Add function to employee view model and fix mappers
cd89bb5
fix unit test
3e7044c
Add others unit test
123e5b5
Fix column name
22f6251
Delete lastDateIncurred property from employee api
a59b4de
Remove Project view model interface
5cf64f9
Fix project component
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| NODE_ENV=development | ||
| GRAPHQL_URL=http://localhost:8081/graphql/employee | ||
| GRAPHQL_URL=/graphql/admin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| NODE_ENV=production | ||
| GRAPHQL_URL=/graphql/employee | ||
| GRAPHQL_URL=/graphql/admin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { GraphQLClient } from 'graphql-request'; | ||
|
|
||
| const url = process.env.GRAPHQL_URL; | ||
| export const graphQLClient = new GraphQLClient(url); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './graphql.client'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export * from './router.component'; | ||
| export * from './routes'; | ||
| export * from './route-params.vm'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export interface EditParams { | ||
| id: string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,40 @@ | ||
| import { graphQLClient } from 'core/api'; | ||
| import { Employee } from './employee-list.api-model'; | ||
| import { mockEmployeeList } from './employee-list.mock-data'; | ||
|
|
||
| let employeeList = [...mockEmployeeList]; | ||
| interface GetEmployeeListResponse { | ||
| employees: Employee[]; | ||
| } | ||
|
|
||
| export const getEmployeeList = async (): Promise<Employee[]> => { | ||
| return employeeList; | ||
| const query = ` | ||
| query { | ||
| employees { | ||
| id | ||
| name | ||
| isActive | ||
| lastDateIncurred | ||
| } | ||
| } | ||
| `; | ||
| const { employees } = await graphQLClient.request<GetEmployeeListResponse>( | ||
| query | ||
| ); | ||
| return employees; | ||
| }; | ||
|
|
||
| interface DeleteEmployeeResponse { | ||
| deleteEmployee: boolean; | ||
| } | ||
|
|
||
| export const deleteEmployee = async (id: string): Promise<boolean> => { | ||
| employeeList = employeeList.filter(e => e.id !== id); | ||
| return true; | ||
| const query = ` | ||
| mutation { | ||
| deleteEmployee(id: "${id}") | ||
| } | ||
| `; | ||
| const { deleteEmployee } = await graphQLClient.request< | ||
| DeleteEmployeeResponse | ||
| >(query); | ||
| return deleteEmployee; | ||
| }; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,86 @@ | ||
| import { Employee } from './employee.api-model'; | ||
| import { mockEmployee } from './employee.mock-data'; | ||
| import { Employee, EmployeeProject, Project } from './employee.api-model'; | ||
| import { graphQLClient } from 'core/api'; | ||
|
|
||
| interface GetEmployeeResponse { | ||
| employee: Employee; | ||
| } | ||
|
|
||
| export const getEmployeeById = async (id: string): Promise<Employee> => { | ||
| return mockEmployee; | ||
| const query = ` | ||
| query { | ||
| employee(id: "${id}") { | ||
| id | ||
| name | ||
| isActive | ||
| lastDateIncurred | ||
| projects { | ||
| id | ||
| isAssigned | ||
| } | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| const { employee } = await graphQLClient.request<GetEmployeeResponse>(query); | ||
|
|
||
| return employee; | ||
| }; | ||
|
|
||
| interface GetProjectListResponse { | ||
| projects: Project[]; | ||
| } | ||
|
|
||
| export const getProjects = async (): Promise<Project[]> => { | ||
| const query = ` | ||
| query { | ||
| projects { | ||
| id | ||
| name | ||
| } | ||
| } | ||
| `; | ||
| const { projects } = await graphQLClient.request<GetProjectListResponse>( | ||
| query | ||
| ); | ||
| return projects; | ||
| }; | ||
|
|
||
| interface SaveEmployeeResponse { | ||
| saveEmployee: Employee; | ||
| } | ||
|
|
||
| export const saveEmployee = async (employee: Employee): Promise<string> => { | ||
| const query = ` | ||
| mutation($employee: EmployeeInput!) { | ||
| saveEmployee(employee: $employee) { | ||
| id | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| const { saveEmployee } = await graphQLClient.request<SaveEmployeeResponse>( | ||
| query, | ||
| { | ||
| employee, | ||
| } | ||
| ); | ||
|
|
||
| return saveEmployee.id; | ||
| }; | ||
|
|
||
| export const saveEmployeeProjectList = async ( | ||
| id: string, | ||
| employeeProjectList: EmployeeProject[] | ||
| ): Promise<void> => { | ||
| const query = `mutation($employeeProjectList: [EmployeeProjectInput!]!) { | ||
| saveEmployeeProjectList( | ||
| id: "${id}", | ||
| employeeProjectList: $employeeProjectList, | ||
| ) { | ||
| id | ||
| } | ||
| }`; | ||
|
|
||
| await graphQLClient.request(query, { employeeProjectList }); | ||
| }; | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,50 @@ | ||
| import React from 'react'; | ||
| import { TableContainer, RowRendererProps } from 'common/components'; | ||
| import { ProjectSummary } from '../employee.vm'; | ||
| import { EmployeeProject } from '../employee.vm'; | ||
| import { EmployeeRowComponent } from './project-row.component'; | ||
| import { CommandFooterComponent } from 'common-app/command-footer'; | ||
|
|
||
| interface Props { | ||
| projectSummaryList: ProjectSummary[]; | ||
| className?: string; | ||
| employeeProjectList: EmployeeProject[]; | ||
| onSave: (project: EmployeeProject[]) => void; | ||
| onCancel: () => void; | ||
| className?: string; | ||
| } | ||
|
|
||
| export const ProjectComponent: React.FunctionComponent<Props> = ({ | ||
| projectSummaryList, | ||
| className, | ||
| employeeProjectList, | ||
| onSave, | ||
| onCancel, | ||
| className, | ||
| }) => { | ||
| const [projectList, setProjectList] = React.useState<EmployeeProject[]>( | ||
| employeeProjectList | ||
| ); | ||
|
|
||
| React.useEffect(() => { | ||
| setProjectList(employeeProjectList); | ||
| }, [employeeProjectList]); | ||
|
|
||
| const handleChangeProject = (id: string) => (project: EmployeeProject) => { | ||
| const updateProjectList = projectList.map(p => (p.id === id ? project : p)); | ||
| setProjectList(updateProjectList); | ||
| }; | ||
|
|
||
| const handleSave = () => onSave(projectList); | ||
| return ( | ||
| <> | ||
| <TableContainer | ||
| columns={['Asignado', 'Nombre y Apellido']} | ||
| rows={projectSummaryList} | ||
| rows={projectList} | ||
| className={className} | ||
| rowRenderer={(rowProps: RowRendererProps<ProjectSummary>) => ( | ||
| <EmployeeRowComponent {...rowProps} /> | ||
| rowRenderer={(rowProps: RowRendererProps<EmployeeProject>) => ( | ||
| <EmployeeRowComponent | ||
| {...rowProps} | ||
| onChangeProject={handleChangeProject(rowProps.row.id)} | ||
| /> | ||
| )} | ||
| /> | ||
| <CommandFooterComponent onCancel={onCancel} /> | ||
| <CommandFooterComponent onSave={handleSave} onCancel={onCancel} /> | ||
| </> | ||
| ); | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.