Skip to content

Commit

Permalink
Merge pull request #36 from OpenLMIS/OMLIS-7903
Browse files Browse the repository at this point in the history
OLMIS-7903
  • Loading branch information
dszafranek authored Apr 4, 2024
2 parents 593c71c + 878f401 commit e58de46
Show file tree
Hide file tree
Showing 10 changed files with 751 additions and 123 deletions.
57 changes: 47 additions & 10 deletions src/buq/Routing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import MohApproveFacilityDemandingForecasting from './components/MOHApproval/Moh
import MOHApprovalDistrictBuq from './components/MOHApproval/MOHApprovalDistrictBuq';
import MOHApproveRegionBuq from './components/MOHApproval/MOHApproveRegionBuq';
import MOHApprovalFacilityBuq from './components/MOHApproval/MOHApprovalFacilityBuq';
import MohForFinalApproval from './components/MOHApproval/MohForFinalApproval';
import useLocalStorage from "../react-hooks/useLocalStorage";


const Routing = ({
loadingModalService,
facilityService,
Expand All @@ -38,43 +40,63 @@ const Routing = ({

const breadcrumbsRoutes = [{
path: '/buq',
breadcrumb: 'BUQ'
breadcrumb: 'BUQ',
isDisabled: true
},
{
path: '/buq/prepare',
breadcrumb: 'Prepare BUQ'
breadcrumb: 'Prepare BUQ',
isDisabled: false
},
{
path: '/buq/create',
breadcrumb: 'Create / Authorize Forecasting'
breadcrumb: 'Create / Authorize Forecasting',
isDisabled: false
},
{
path: '/buq/create/:id',
breadcrumb: 'Facility Demanding Forecasting Form'
breadcrumb: 'Facility Demanding Forecasting Form',
isDisabled: false
},
{
path: '/buq/national-approve',
breadcrumb: 'Pending Approvals'
breadcrumb: 'Pending Approvals',
isDisabled: false
},
{
path: '/buq/national-approval',
breadcrumb: 'Pending Approvals',
isDisabled: false
},
{
path: '/buq/national-approval/:id',
breadcrumb: 'Facility Demanding Forecasting Form',
isDisabled: false
},
{
path: '/buq/national-approve/:districtId',
breadcrumb: 'District Summary'
breadcrumb: 'District Summary',
isDisabled: false
},
{
path: '/buq/national-approve/:districtId/:facilityId',
breadcrumb: `Facilities Consolidated Summary for ${mohApprovalParams?.region} region`
breadcrumb: `Facilities Consolidated Summary for ${mohApprovalParams?.region} region`,
isDisabled: false
},
{
path: '/buq/national-approve/:districtId/:facilityId/:id',
breadcrumb: 'Facility Demanding Forecasting Form'
breadcrumb: 'Facility Demanding Forecasting Form',
isDisabled: false
},
{
path: '/buq/approve',
breadcrumb: 'Approve BUQ'
breadcrumb: 'Approve BUQ',
isDisabled: false
},
{
path: '/buq/approve/:id',
breadcrumb: 'Facility Demanding Forecasting Form'
breadcrumb: 'Facility Demanding Forecasting Form',
isDisabled: false
}
];

Expand Down Expand Up @@ -147,6 +169,21 @@ const Routing = ({
orderableService={orderableService}
/>
</Route>
<Route exact path='/buq/national-approval'>
<MohForFinalApproval
loadingModalService={loadingModalService}
periodService={periodService}
orderableService={orderableService}
facilityService={facilityService}
/>
</Route>
<Route exact path='/buq/national-approval/:id'>
<MohApproveFacilityDemandingForecasting
loadingModalService={loadingModalService}
facilityService={facilityService}
orderableService={orderableService}
/>
</Route>
</Switch>
</Router>
</div>
Expand Down
18 changes: 16 additions & 2 deletions src/buq/buq.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
.state('openlmis.buq.MOHPORALGApprovals', {
label: 'buq.MOHPORALGApprovals',
url: '/national-approve',
showInNavigation: true,
showInNavigation: false,
priority: 10,
accessRights: [BUQ_RIGHTS.MOH_APPROVAL, BUQ_RIGHTS.PORALG_APPROVAL],
resolve: createResolve(false)
Expand All @@ -172,7 +172,21 @@
showInNavigation: false,
accessRights: [BUQ_RIGHTS.MOH_APPROVAL, BUQ_RIGHTS.PORALG_APPROVAL],
resolve: createResolve(false)
})
.state('openlmis.buq.MOHPORALGForFinalApproval', {
label: 'buq.MOHPORALGApprovals',
url: '/national-approval',
showInNavigation: true,
priority: 10,
accessRights: [BUQ_RIGHTS.MOH_APPROVAL, BUQ_RIGHTS.PORALG_APPROVAL],
resolve: createResolve(false)
})
.state('openlmis.buq.MOHPORALGBuqApprove', {
label: 'buq.MOHPORALGApproval',
url: '/national-approval/:id',
showInNavigation: false,
accessRights: [BUQ_RIGHTS.MOH_APPROVAL, BUQ_RIGHTS.PORALG_APPROVAL],
resolve: createResolve(false)
});

}
})();
14 changes: 14 additions & 0 deletions src/buq/buq.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@
'?processingPeriodId=:ppId&programId=:pId&geographicZoneId=:gzId'),
method: 'POST',
isArray: true
},
forFinalApproval: {
url: openlmisUrlFactory('/api/bottomUpQuantifications/forFinalApproval' +
'?processingPeriodId=:ppId&programId=:pId&geographicZoneId=:gzId'),
method: 'GET'
}
});

Expand All @@ -141,6 +146,7 @@
this.getMostRecentRejection = getMostRecentRejection;
this.userHasBUQProgram = userHasBUQProgram;
this.doesSupportBUQProgram = doesSupportBUQProgram;
this.forFinalApproval = forFinalApproval;

function getBuqs(facilityId) {
var queryParams = {};
Expand Down Expand Up @@ -258,6 +264,14 @@
}, payload).$promise;
}

function forFinalApproval(programId, processingPeriodId, geoZoneId) {
return resource.forFinalApproval({
pId: programId,
ppId: processingPeriodId,
gzId: geoZoneId
}).$promise;
}

function getMostRecentRejection(buqId) {
return resource.getMostRecentRejection({
id: buqId
Expand Down
41 changes: 41 additions & 0 deletions src/buq/components/MOHApproval/MOHActionBarFinalApprove.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import Modal from '../../../admin-buq/components/Modal/Modal';
import ActionBar from '../../../react-components/ActionBar';
import ConfirmModalBody from '../../../react-components/ConfirmModalBody';
import ModalErrorMessage from '../../../react-components/ModalErrorMessage';

const MOHActionBarFinalApprove = ({
handleFinalApproveAction,
displayFinalApproveModal,
handleSetDisplayFinalApproveModal,
displayFinalApproveErrorModal,
handleSetDisplayFinalApproveErrorModal
}) => (
<>
<Modal
isOpen={displayFinalApproveModal}
sourceOfFundStyle={true}
>
<ConfirmModalBody
onConfirm={handleFinalApproveAction}
confirmMessage={'Are you sure you want to approve this forecasting?'}
onCancel={() => handleSetDisplayFinalApproveModal(false)}
confirmButtonText={'Approve'}
/>
</Modal>
<ModalErrorMessage
isOpen={displayFinalApproveErrorModal}
customMessage="At least one pending approval needs to be selected"
onClose={() => handleSetDisplayFinalApproveErrorModal(false)}
/>
<ActionBar
onFinalApproveAction={() => handleSetDisplayFinalApproveModal(true)}
finalApproveButton={true}
cancelButton={false}
totalCostInformation={false}
sourceOfFundButton={false}
/>
</>
)

export default MOHActionBarFinalApprove
Loading

0 comments on commit e58de46

Please sign in to comment.