Skip to content

Commit

Permalink
Merge pull request #100 from myanzik/master
Browse files Browse the repository at this point in the history
resolved merge conflicts from stage
  • Loading branch information
myanzik authored Sep 29, 2021
2 parents 5476463 + e210e49 commit 2b8a456
Show file tree
Hide file tree
Showing 43 changed files with 1,758 additions and 513 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
},
"dependencies": {
"add": "^2.0.6",
"apexcharts": "^3.28.3",
"axios": "^0.21.1",
"bootstrap-switch-button-react": "^1.2.0",
"chart.js": "^2.9.3",
Expand All @@ -52,6 +53,7 @@
"qrcode.react": "^1.0.0",
"query-string": "^6.13.1",
"react": "^16.13.1",
"react-apexcharts": "1.3.7",
"react-chartjs-2": "^2.10.0",
"react-digit-input": "^2.1.0",
"react-dom": "^16.13.1",
Expand All @@ -64,6 +66,7 @@
"react-select": "^2.2.0",
"react-stepzilla": "^6.0.2",
"react-table-v6": "^6.8.6",
"react-to-print": "^2.13.0",
"react-toast-notifications": "^2.4.0",
"reactstrap": "^8.4.1",
"redux-devtools-extension": "^2.13.8",
Expand Down
4 changes: 4 additions & 0 deletions src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ module.exports = {
SUCCESS: {
appearance: 'success',
autoDismiss: true
},
WARNING: {
appearance: 'warning',
autoDismiss: true
}
},
PROJECT_STATUS: {
Expand Down
41 changes: 10 additions & 31 deletions src/contexts/BeneficiaryContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as Service from '../services/beneficiary';
import * as AidService from '../services/aid';
import ACTION from '../actions/beneficiary';
import { AppContext } from './AppSettingsContext';
import { APP_CONSTANTS } from '../constants';

const initialState = {
list: [],
Expand Down Expand Up @@ -38,15 +37,11 @@ export const BeneficiaryContextProvider = ({ children }) => {
return Service.getBeneficiaryBalance(phone, contract_address);
}, []);

const listAid = useCallback(() => {
return AidService.listAid({ limit: APP_CONSTANTS.FETCH_LIMIT });
}, []);

// async function listAid() {
// const d = await AidService.listAid({ start: 0, limit: 50 });
// dispatch({ type: ACTION.LIST_AID, data: { projectList: d.data } });
// return d;
// }
async function listProject() {
const d = await AidService.listAid({ start: 0, limit: 50 });
dispatch({ type: ACTION.LIST_AID, data: { projectList: d.data } });
return d;
}

function setAid(aid) {
dispatch({ type: ACTION.SET_AID, data: aid });
Expand Down Expand Up @@ -79,23 +74,6 @@ export const BeneficiaryContextProvider = ({ children }) => {
return Service.updateBeneficiary(id, payload);
};

// const addBeneficiary = async event => {
// event.preventDefault();
// const formData = new FormData(event.target);

// let payload = {
// name: formData.get('name'),
// phone: formData.get('phone'),
// govt_id: formData.get('govt_id'),
// email: formData.get('email'),
// address: formData.get('address'),
// wallet_address: formData.get('wallet_address'),
// project_id: formData.get('aid')
// };
// let d = await Service.addBeneficiary(payload);
// return d;
// };

async function listBeneficiary(params) {
let res = await Service.listBeneficiary(params);
if (res) {
Expand All @@ -112,8 +90,9 @@ export const BeneficiaryContextProvider = ({ children }) => {
for (let b of beneficiaries) await Service.addBeneficiary(b);
};

const getBeneficiaryDetails = useCallback(id => {
return Service.get(id);
const getBeneficiaryDetails = useCallback(async id => {
const data = await Service.get(id);
return data;
}, []);

return (
Expand All @@ -124,10 +103,10 @@ export const BeneficiaryContextProvider = ({ children }) => {
list: state.list,
pagination: state.pagination,
tokenBalance: state.tokenBalance,
beneficiary_detail: state.beneficiary,
beneficiary: state.beneficiary,
clear,
setAid,
listAid,
listProject,
issueTokens,
addBeneficiary,
updateBeneficiary,
Expand Down
Loading

0 comments on commit 2b8a456

Please sign in to comment.