Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
249 changes: 248 additions & 1 deletion package-lock.json

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"axios": "^0.20.0",
"bootstrap": "^5.1.3",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-hook-form": "^7.20.4",
"react-redux": "^7.2.1",
"react-router-dom": "^6.0.2",
"react-scripts": "3.4.3",
"redux": "^4.0.5"
"react-select": "^5.2.1",
"reactstrap": "^9.0.1",
"redux": "^4.0.5",
"reselect": "^4.1.5"
},
"scripts": {
"start": "react-scripts start",
Expand Down
Binary file added public/images/ecobel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions src/application/actions/collection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export const LOAD_All = '[all] load';
export const LOAD_ALL_SUCCESS = '[all] load success';
export const LOAD_ITEM_SUCCESS = '[one item] load success';
export const LOAD_ALL_FAILURE = '[all] load failure';
export const LOAD_ITEM = '[one item] load';
export const SAVE_ITEM ='[one item] save';

export const TOGGLE_TAB= '[toggle tab of project] toggle ';


export const loadAll = collection => ({
type: LOAD_All,
payload:collection,
});

export const load = (items)=> ({
type: LOAD_ITEM,
payload: {id:items.id, items:items.table},
});

export const loadItemSuccess = item => ({
type: LOAD_ITEM_SUCCESS,
payload: item,
});


export const loadAllSuccess = items => ({
type: LOAD_ALL_SUCCESS,
payload: items,
});

export const loadAllFailure = error => ({
type: LOAD_ALL_FAILURE,
payload: error,
});

export const toggleTab = tabId => ({
type: TOGGLE_TAB,
payload: tabId,
});


export const save = data => ({
type: SAVE_ITEM,
payload: data,
});



46 changes: 46 additions & 0 deletions src/application/actions/permitActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
export const LOAD_PERMIT = '[load permit]';
export const LOAD_PERMIT_SUCCESS = '[permit loaded successfully]';
export const SPLIT_PERMIT_SUCCESS = '[permit splitted successfully]';
export const SPLIT_PERMIT = '[split Permit]';
export const SPLIT_AND_SAVE = '[split and save]';
export const SPLIT_AND_SAVE_SUCCESS = '[splited and saved successfylly]';
export const SAVE_PERMIT = '[save permit]';

export const TOGGLE_TAB = '[change permit tab]';

export const load = id => ({
type: LOAD_PERMIT,
payload: id,
});


export const loadPermitSuccess = permit=> ({
type: LOAD_PERMIT_SUCCESS,
payload: permit,
});

export const split = payload => ({
type: SPLIT_PERMIT,
payload: payload,
});

export const splitPermitSuccess = permitItems=> ({
type: SPLIT_PERMIT_SUCCESS,
payload: permitItems,
});

export const splitAndSave = payload => ({
type: SPLIT_AND_SAVE,
payload: payload,
});

export const splitAndSavePermitSuccess = permitItems=> ({
type: SPLIT_AND_SAVE_SUCCESS,
payload: permitItems,
});

export const toggleTab = tabId => ({
type: TOGGLE_TAB,
payload: tabId,
});

13 changes: 13 additions & 0 deletions src/application/actions/projectActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const CREATE_ENVIRONMENT_MODULE = '[create environment module]';
export const CREATE_SECURITY_MODULE = '[create security module]';


export const createEnvironmentModule = payload => ({
type: CREATE_ENVIRONMENT_MODULE,
payload: payload,
});

export const createSecurityModule = payload => ({
type: CREATE_SECURITY_MODULE,
payload: payload,
});
28 changes: 28 additions & 0 deletions src/application/actions/ricActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const LOAD_RIC = '[load ric]';
export const LOAD_RIC_SUCCESS = '[load ric success]';

export const UPDATE_RIC_STATUS = '[update ric status]';
export const UPDATE_RIC_STATUS_SUCCESS = '[update ric status success]'

export const loadRic = projectid => ({
type: LOAD_RIC,
payload: projectid,
});

export const loadRicSuccess = ric=> ({
type: LOAD_RIC_SUCCESS,
payload: ric,
});

export const updateRicStatus =ric=>({
type: UPDATE_RIC_STATUS,
payload: ric,
});

export const updateRicStatusSuccess =ric=>({
type: UPDATE_RIC_STATUS_SUCCESS,
payload: ric,
});



29 changes: 0 additions & 29 deletions src/application/actions/todos.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/application/actions/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export const pageLoaded = {
export const setLoading = isLoading => ({
type: isLoading ? SET_LOADING_ON : SET_LOADING_OFF,
payload: isLoading,
});
});
64 changes: 64 additions & 0 deletions src/application/middleware/collection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { loadAllFailure, loadAllSuccess,loadItemSuccess, LOAD_All, SAVE_ITEM, LOAD_ITEM, } from "../actions/collection";
import * as uiActions from '../actions/ui';

const loadFlow = ({ api }) => ({ dispatch }) => next => async (action) => {
next(action);

const loadAll = async ()=>{
try {
//log('blabla');
dispatch(uiActions.setLoading(true));
const items = await api[action.payload].getAll();
dispatch(loadAllSuccess(items));
dispatch(uiActions.setLoading(false));
} catch (error) {
dispatch(loadAllFailure(error));
}
}

const load = async ()=>{
try {
dispatch(uiActions.setLoading(true));
const item = await api[action.payload.items].get(action.payload.id);
dispatch(loadItemSuccess(item));
dispatch(uiActions.setLoading(false));
} catch (error) {
dispatch(loadAllFailure(error));
}
}

const save = async ()=>{
try {
await api[action.payload.items].save(action.payload.data);
//dispatch(saveSuccess)
} catch (error) {
dispatch(loadAllFailure(error));
}
}


switch(action.type) {
case LOAD_All:
loadAll();
break;
case LOAD_ITEM:
load();
break;
case SAVE_ITEM:
save();
break;
default:
break;
}
}


/*const putProjectsFlow = () => ({ dispatch, getState }) => next => action => {
next(action);
}*/



export default [
loadFlow,
]
43 changes: 43 additions & 0 deletions src/application/middleware/companies.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// import { loadCompaniesSuccess, LOAD_COMPANIES } from '../actions/collection';
// import companiesMiddleware from './companies';

// describe('companies middleware', () => {
// describe('load companies flow', () => {
// const [ loadCompaniesFlow ] = companiesMiddleware;

// const dummyCompany = {
// id: '1',
// title: 'Dummy company',
// completed: true,
// };
// const api = {
// companies: {
// getAll: jest.fn().mockImplementationOnce(() => new Promise((resolve) => resolve([dummyCompany])))
// }
// }
// const dispatch = jest.fn();
// const next = jest.fn();
// const action = {
// type: LOAD_COMPANIES
// }


// it('passes action to next middleware', async () => {
// await loadCompaniesFlow({ api })({ dispatch })(next)(action);

// expect(next).toHaveBeenCalledWith(action);
// });

// it('calls api.companies.getAll at least once', async () => {
// await loadCompaniesFlow({ api })({ dispatch })(next)(action);

// expect(api.companies.getAll).toHaveBeenCalled();
// });c

// it('calls api.companies.getAll at least once', async () => {
// await loadCompaniesFlow({ api })({ dispatch })(next)(action);

// expect(dispatch).toHaveBeenCalledWith(loadCompaniesSuccess([dummyCompany]));
// });
// });
// });
8 changes: 6 additions & 2 deletions src/application/middleware/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import ui from './ui';
import todos from './todos';
import collection from './collection';
import permit from './permitMiddleware';
import ric from './ricMiddleware'

export default [
...ui,
...todos,
...collection,
...permit,
...ric
]
Loading