-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {facilityType !== 'SupervisedFacility' ?
+
+
- {facilityType !== 'SupervisedFacility' ?
-
-
-
-
+ >
+ }
+
+
+
>
);
};
Index: src/stock-on-hand-mobile/pages/stock-on-hand.jsx
===================================================================
diff -u -N
--- src/stock-on-hand-mobile/pages/stock-on-hand.jsx (revision 0)
+++ src/stock-on-hand-mobile/pages/stock-on-hand.jsx (revision 9bbcb50a0fd738bf96b96418ce9735988b8103b3)
@@ -0,0 +1,54 @@
+/*
+ * This program is part of the OpenLMIS logistics management information system platform software.
+ * Copyright © 2017 VillageReach
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU Affero General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Affero General Public License for more details. You should have received a copy of
+ * the GNU Affero General Public License along with this program. If not, see
+ * http://www.gnu.org/licenses. For additional information contact info@OpenLMIS.org.
+ */
+
+import React, { useEffect } from 'react';
+import { useDispatch, useSelector } from 'react-redux';
+import { useParams } from 'react-router-dom';
+import { setFacilityStockOnHand } from '../reducers/facilities';
+import { setProgramStockOnHand } from '../reducers/programs';
+
+const StockOnHand = ({ facilityService, programService }) => {
+ const { facilityId, programId } = useParams();
+ const dispatch = useDispatch();
+
+ const facility = useSelector(state => state['facilitiesStockOnHand']['facilityStockOnHand']);
+ const program = useSelector(state => state['programsStockOnHand']['programStockOnHand']);
+
+ const downloadFacilityData = () => {
+ return facilityService.get(facilityId).then((facility) => {
+ dispatch(setFacilityStockOnHand(facility));
+ });
+ };
+
+ const downloadProgramData = () => {
+ return programService.get(programId).then((program) => {
+ dispatch(setProgramStockOnHand(program));
+ });
+ };
+
+ useEffect(() => {
+ Promise.all([downloadFacilityData(), downloadProgramData()]);
+ },[facilityId, programId]);
+
+ return (
+
+
+
+ );
+};
+
+export default StockOnHand;
Index: src/stock-on-hand-mobile/reducers/facilities.jsx
===================================================================
diff -u -N -r7f9ffae3458e2f9994249398a1d526a3cbe861d6 -r9bbcb50a0fd738bf96b96418ce9735988b8103b3
--- src/stock-on-hand-mobile/reducers/facilities.jsx (.../facilities.jsx) (revision 7f9ffae3458e2f9994249398a1d526a3cbe861d6)
+++ src/stock-on-hand-mobile/reducers/facilities.jsx (.../facilities.jsx) (revision 9bbcb50a0fd738bf96b96418ce9735988b8103b3)
@@ -19,18 +19,26 @@
name: 'facilitiesStockOnHand',
initialState: {
userHomeFacilityStockOnHand: null,
- supervisedFacilitiesStockOnHand: []
+ supervisedFacilitiesStockOnHand: [],
+ facilityStockOnHand: null
},
reducers: {
setUserHomeFacilityStockOnHand: (state, action) => {
state.userHomeFacilityStockOnHand = action.payload;
},
setSupervisedFacilitiesStockOnHand: (state, action) => {
state.supervisedFacilitiesStockOnHand = action.payload;
+ },
+ setFacilityStockOnHand: (state, action) => {
+ state.facilityStockOnHand = action.payload;
}
}
});
-export const {setUserHomeFacilityStockOnHand, setSupervisedFacilitiesStockOnHand} = facilitiesStockOnHandSlice.actions;
+export const {
+ setUserHomeFacilityStockOnHand,
+ setSupervisedFacilitiesStockOnHand,
+ setFacilityStockOnHand
+} = facilitiesStockOnHandSlice.actions;
export default facilitiesStockOnHandSlice.reducer;
Index: src/stock-on-hand-mobile/reducers/programs.jsx
===================================================================
diff -u -N -r7f9ffae3458e2f9994249398a1d526a3cbe861d6 -r9bbcb50a0fd738bf96b96418ce9735988b8103b3
--- src/stock-on-hand-mobile/reducers/programs.jsx (.../programs.jsx) (revision 7f9ffae3458e2f9994249398a1d526a3cbe861d6)
+++ src/stock-on-hand-mobile/reducers/programs.jsx (.../programs.jsx) (revision 9bbcb50a0fd738bf96b96418ce9735988b8103b3)
@@ -19,18 +19,26 @@
name: 'programsStockOnHand',
initialState: {
programsStockOnHand: [],
- supervisedProgramsStockOnHand: []
+ supervisedProgramsStockOnHand: [],
+ programStockOnHand: {}
},
reducers: {
setProgramsStockOnHand: (state, action) => {
state.programsStockOnHand = action.payload;
},
setSupervisedProgramsStockOnHand: (state, action) => {
state.supervisedProgramsStockOnHand = action.payload;
+ },
+ setProgramStockOnHand: (state, action) => {
+ state.programStockOnHand = action.payload;
}
}
});
-export const {setProgramsStockOnHand, setSupervisedProgramsStockOnHand} = programsStockOnHandSlice.actions;
+export const {
+ setProgramsStockOnHand,
+ setSupervisedProgramsStockOnHand,
+ setProgramStockOnHand
+} = programsStockOnHandSlice.actions;
export default programsStockOnHandSlice.reducer;
Index: src/stock-on-hand-mobile/stock-on-hand-app.jsx
===================================================================
diff -u -N -r7f9ffae3458e2f9994249398a1d526a3cbe861d6 -r9bbcb50a0fd738bf96b96418ce9735988b8103b3
--- src/stock-on-hand-mobile/stock-on-hand-app.jsx (.../stock-on-hand-app.jsx) (revision 7f9ffae3458e2f9994249398a1d526a3cbe861d6)
+++ src/stock-on-hand-mobile/stock-on-hand-app.jsx (.../stock-on-hand-app.jsx) (revision 9bbcb50a0fd738bf96b96418ce9735988b8103b3)
@@ -20,6 +20,7 @@
import { setSupervisedProgramsStockOnHand } from './reducers/programs';
import { setUserHomeFacilityStockOnHand, setSupervisedFacilitiesStockOnHand } from './reducers/facilities';
import ProgramSelect from './pages/program-select';
+import StockOnHand from './pages/stock-on-hand';
const StockOnHandApp = ({
asynchronousService,
@@ -64,13 +65,13 @@
});
return result;
- }
+ };
const getFacilityById = (facilities, id) => {
return facilities.filter(function(facility) {
return facility.id === id;
})[0];
- }
+ };
const getSupervisedFacilities = (programId, permissions, facilities) => {
const facilityIds = [];
@@ -96,13 +97,13 @@
});
return result;
- }
+ };
const dispatchData = (actions) => {
actions.forEach((action) => {
dispatch(action);
- })
- }
+ });
+ };
useEffect(() => {
facilityFactory.getUserHomeFacility().then((facility) => {
@@ -126,8 +127,6 @@
setSupervisedFacilitiesStockOnHand(supervisedFacilities)
]);
- }).catch((error) => {
- console.log(error);
});
});
} ,[facilityFactory]);
@@ -143,6 +142,15 @@
hashType='hashbang'
>
+
+ {
+ userHomeFacilityStore &&
+
+ }
+
{
userHomeFacilityStore &&
Index: src/stock-on-hand-mobile/stock-on-hand.routes.js
===================================================================
diff -u -N -rd337a0ac836544c6a7201f924878e2fd5f88370e -r9bbcb50a0fd738bf96b96418ce9735988b8103b3
--- src/stock-on-hand-mobile/stock-on-hand.routes.js (.../stock-on-hand.routes.js) (revision d337a0ac836544c6a7201f924878e2fd5f88370e)
+++ src/stock-on-hand-mobile/stock-on-hand.routes.js (.../stock-on-hand.routes.js) (revision 9bbcb50a0fd738bf96b96418ce9735988b8103b3)
@@ -45,6 +45,13 @@
}
},
accessRights: [STOCKMANAGEMENT_RIGHTS.STOCK_CARDS_VIEW]
- });
+ })
+ .state('openlmis.stockmanagement.stockOnHandMobile.stockOnHand', {
+ url: '/stockOnHand/:facilityId/:programId',
+ isOffline: true,
+ showInNavigation: false,
+ showInNavigationOnLowResolutions: false,
+ accessRights: [STOCKMANAGEMENT_RIGHTS.STOCK_CARDS_VIEW]
+ });
}
})();
Index: src/stock-on-hand-mobile/stock-on-hand.wrapper.jsx
===================================================================
diff -u -N -r7f9ffae3458e2f9994249398a1d526a3cbe861d6 -r9bbcb50a0fd738bf96b96418ce9735988b8103b3
--- src/stock-on-hand-mobile/stock-on-hand.wrapper.jsx (.../stock-on-hand.wrapper.jsx) (revision 7f9ffae3458e2f9994249398a1d526a3cbe861d6)
+++ src/stock-on-hand-mobile/stock-on-hand.wrapper.jsx (.../stock-on-hand.wrapper.jsx) (revision 9bbcb50a0fd738bf96b96418ce9735988b8103b3)
@@ -36,7 +36,7 @@
return {
template: '',
replace: true,
- link: function ($scope) {
+ link: function () {
const app = document.getElementById('mobileApp');
ReactDOM.render(