Skip to content
This repository was archived by the owner on Mar 3, 2019. It is now read-only.

Commit 90db544

Browse files
committed
Merge branch 'feature/new_stakeholder' into develop
2 parents 3218efa + 990dc33 commit 90db544

File tree

54 files changed

+1132
-440
lines changed

Some content is hidden

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

54 files changed

+1132
-440
lines changed

config-overrides.js

+27-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
1-
const { injectBabelPlugin } = require('react-app-rewired'); // eslint-disable line import/no-extraneous-dependencies
1+
const path = require('path');
2+
const { injectBabelPlugin, compose } = require('react-app-rewired'); // eslint-disable line import/no-extraneous-dependencies
23

34
/**
45
* Override webpack configurations for the application
56
*
67
* @param {Object} config
78
* @param {Object} env
89
*/
9-
module.exports = function override(config, env) {
10-
const newConfig = injectBabelPlugin(['import',
11-
{ libraryName: 'antd', libraryDirectory: 'es', style: 'css' },
12-
], config);
10+
module.exports = {
11+
webpack: function (config, env) {
12+
const newConfig = injectBabelPlugin(['import',
13+
{ libraryName: 'antd', libraryDirectory: 'es', style: 'css' },
14+
], config);
1315

14-
return newConfig;
16+
const rewires = compose(
17+
// Add CSS modules
18+
require('react-app-rewire-css-modules-extensionless')({
19+
include: /.*\.module\.css$/ // add css modules only to css files with keword module
20+
})
21+
);
22+
23+
// Add src shared components to the webpack modules to make
24+
// import from these folder possible without writing relative path
25+
const modules = [
26+
__dirname,
27+
path.resolve(__dirname, 'src', 'common'),
28+
path.resolve(__dirname, 'src', 'common', 'components'),
29+
...newConfig.resolve.modules
30+
];
31+
newConfig.resolve.modules = modules;
32+
33+
34+
return rewires(newConfig, env);
35+
}
1536
};

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"eslint-plugin-import": "^2.13.0",
2929
"eslint-plugin-jsx-a11y": "^6.1.1",
3030
"eslint-plugin-react": "^7.10.0",
31+
"react-app-rewire-css-modules-extensionless": "^1.2.0",
3132
"react-app-rewired": "^1.5.2",
3233
"redux-devtools-extension": "^2.13.5"
3334
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
{
3+
"data": [
4+
{ "name": "Dar es Salaam Region Authority", "phone": "+233 54534545", "email": "[email protected]" },
5+
{ "name": "Tanzania Fire and Rescue Force", "phone": "+233 54534545", "email": "[email protected]" }
6+
7+
]
8+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
{
3+
"data": [
4+
{ "name": "Tanzania Red Cross Society", "phone": "+233 54534545", "email": "[email protected]" },
5+
{ "name": "Dar es Salaam Region Authority", "phone": "+233 54534545", "email": "[email protected]" },
6+
{ "name": "Tanzania Police Force", "phone": "+233 54534545", "email": "[email protected]" },
7+
{ "name": "Ambulance Services", "phone": "+233 54534545", "email": "[email protected]" },
8+
{ "name": "Supportive Personnel", "phone": "+233 54534545", "email": "[email protected]" },
9+
{ "name": "Prime Minister’s Office –Disaster Management Department", "phone": "+233 54534545", "email": "[email protected]" },
10+
{ "name": "Hospitals", "phone": "+233 54534545", "email": "[email protected]" },
11+
{ "name": "Tanzania Fire and Rescue Force", "phone": "+233 54534545", "email": "[email protected]" }
12+
13+
]
14+
}

src/App.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { Provider } from 'react-redux';
33
import { BrowserRouter } from 'react-router-dom';
4-
import configureStore from './configureStore';
4+
import configureStore from 'redux/configureStore';
55
import Dashboard from './dashboard';
66
/* import global styles */
77
import './utils.css';
File renamed without changes.

src/common/API/index.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const API_END_POINT = 'https://emis-asat.herokuapp.com/v1';
2+
const API = {
3+
findStakeholders: () => {
4+
return fetch(`${API_END_POINT}/parties`).then(res => res.json());
5+
},
6+
searchStakeholder: searchText => {
7+
return fetch(`${API_END_POINT}/parties?q=${searchText}`)
8+
.then(res => res.json())
9+
},
10+
createStakeholder: data => {
11+
const url = `${API_END_POINT}/parties`;
12+
const config = {
13+
method: 'POST',
14+
body: JSON.stringify(data),
15+
headers: {
16+
'content-type': 'application/json'
17+
}
18+
};
19+
return fetch(url, config).then(res => res.json());
20+
},
21+
updateStakeholder: (stakeholderId, updates) => {
22+
const url = `${API_END_POINT}/parties/${stakeholderId}`;
23+
const config = {
24+
method: 'PATCH',
25+
body: JSON.stringify(updates),
26+
headers: {
27+
'content-type': 'application/json'
28+
}
29+
};
30+
return fetch(url, config).then(res => res.json());
31+
}
32+
};
33+
34+
export default API;

src/dashboard/contacts/components/Header/index.js renamed to src/common/components/ColHeader/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import classnames from 'classnames';
1+
import classNames from 'classnames/bind';
22
import PropTypes from 'prop-types';
33
import React from 'react';
44
/* import styles */
5-
import styles from './index.css';
5+
import styles from './index.module.css';
66

77

88
/* local constants */
9-
const cx = classnames.bind(styles);
9+
const cx = classNames.bind(styles);
1010

1111

1212
/**
@@ -22,7 +22,7 @@ const cx = classnames.bind(styles);
2222
*/
2323
export default function Header({ children }) {
2424
return (
25-
<div className={cx('header b-b')}>
25+
<div className={cx('container')}>
2626
{React.isValidElement(children)
2727
? (
2828
<div className={cx('component')}>

src/dashboard/contacts/components/Header/index.css renamed to src/common/components/ColHeader/index.module.css

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
/* contacts header styles */
22

3+
.container {
4+
flex: 0 0 50px;
5+
border-bottom: 1px solid #E0E0E0;
6+
padding-left: 15px;
7+
}
8+
39
.title {
410
font-size: 14px;
511
padding-top: 15px;
@@ -10,4 +16,4 @@
1016
width: 95%;
1117
margin: 0 auto;
1218
padding-top: 10px;
13-
}
19+
}

src/common/components/Header/index.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
import classNames from 'classnames/bind';
3+
import styles from './index.module.css';
4+
5+
6+
/* local constants */
7+
const cx = classNames.bind(styles);
8+
9+
export default ({ title }) => (
10+
<div className={cx('container')}>
11+
<span className={cx('title')}>{title}</span>
12+
</div>
13+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.container {
2+
background: #fafafa;
3+
height: 60px;
4+
display: flex;
5+
align-items: flex-end;
6+
padding-left: 30px;
7+
}
8+
9+
.title {
10+
display: block;
11+
font-size: 20px;
12+
margin-bottom: 5px;
13+
}

src/common/redux/configureStore.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { applyMiddleware, createStore } from 'redux';
2+
import { composeWithDevTools } from 'redux-devtools-extension'; // eslint-disable-line import/no-extraneous-dependencies
3+
import { createEpicMiddleware } from 'redux-observable';
4+
/* local dependencies */
5+
import rootReducer from './rootReducer';
6+
import rootEpic from './rootEpic';
7+
8+
9+
/* local constants */
10+
const epicMiddleware = createEpicMiddleware();
11+
12+
// fake data store
13+
const fakeStore = {
14+
filters: [
15+
{ group: 'phases', data: [{ name: 'Mitigation', count: 100, isActive: true }, { name: 'Preparedness', count: 20 }] },
16+
{ group: 'types', data: [] },
17+
{ group: 'roles', data: [] },
18+
{ group: 'functions', data: [] },
19+
],
20+
criteria: {
21+
filter: {
22+
$and: [{ phases: { $in: ['Mitigation'] } }, { types: { $in: ['Agency'] } }],
23+
},
24+
},
25+
};
26+
27+
28+
/**
29+
* Configure Redux store
30+
* Enable redux dev tools
31+
* Setup redux observables as async library
32+
*
33+
* @function
34+
* @name configureStore
35+
*
36+
* @version 0.1.0
37+
* @since 0.1.0
38+
*/
39+
const configureStore = () => {
40+
const store = createStore(rootReducer, fakeStore, composeWithDevTools(
41+
applyMiddleware(epicMiddleware),
42+
));
43+
44+
// epicMiddleware.run(); add root epics here
45+
epicMiddleware.run(rootEpic);
46+
47+
return store;
48+
};
49+
50+
51+
export default configureStore;

src/common/redux/rootEpic.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Root epics for react observables
3+
*/
4+
import { combineEpics } from 'redux-observable';
5+
import {
6+
fetchStakeholdersEpic,
7+
searchStakeholdersEpic
8+
} from '../../dashboard/Stakeholders/epics';
9+
10+
export default combineEpics(
11+
fetchStakeholdersEpic,
12+
searchStakeholdersEpic
13+
);

src/common/redux/rootReducer.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Root Reducer for the application
3+
*/
4+
import { combineReducers } from 'redux';
5+
import { stakeholders } from '../../dashboard/Stakeholders/reducer';
6+
7+
export default combineReducers({ stakeholders });

src/configureStore.js

-66
This file was deleted.

src/dashboard/Stakeholders/actions.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Action creators for contacts
3+
*/
4+
export const FETCH_STAKEHOLDERS = 'FETCH_STAKEHOLDERS';
5+
export const FETCH_STAKEHOLDERS_SUCCESS = 'FETCH_STAKEHOLDERS_SUCCESS';
6+
export const FETCH_STAKEHOLDERS_FAILURE = 'FETCH_STAKEHOLDERS_FAILURE';
7+
export const SEARCH_STAKEHOLDERS = 'SEARCH_STAKEHOLDERS';
8+
export const SELECT_STAKEHOLDER = 'SELECT_STAKEHOLDER';
9+
export const ADD_NEW_STAKEHOLDER_SUCCESS = 'ADD_NEW_STAKEHOLDER_SUCCESS';
10+
export const UPDATE_STAKEHOLDER_SUCCESS = 'UPDATE_STAKEHOLDER_SUCCESS';
11+
12+
13+
export const fetchStakeholders = () => ({ type: FETCH_STAKEHOLDERS });
14+
15+
export const fetchStakeholdersSuccess = (stakeholders) => ({
16+
type: FETCH_STAKEHOLDERS_SUCCESS,
17+
payload: stakeholders
18+
});
19+
20+
export const fetchStakeholdersFailure = (message) => ({
21+
type: FETCH_STAKEHOLDERS_FAILURE,
22+
payload: message
23+
});
24+
25+
// action fired when stakeholder is selected
26+
export const selectStakeholder = stakeholder => ({ type: SELECT_STAKEHOLDER, stakeholder });
27+
28+
// action fired when search for stakeholder using search box
29+
export const searchStakeholders = searchText => ({ type: SEARCH_STAKEHOLDERS, searchText });
30+
31+
// action fired on add new stakeholder success
32+
export const addNewStakeholderSuccess =
33+
stakeholder => ({ type: ADD_NEW_STAKEHOLDER_SUCCESS, stakeholder });
34+
35+
// action fired on update stakeholder successfully
36+
export const updateStakeholderSuccess =
37+
stakeholder => ({ type: UPDATE_STAKEHOLDER_SUCCESS, stakeholder });

0 commit comments

Comments
 (0)