diff --git a/backend/src/components/application.js b/backend/src/components/application.js index 891bcea4..2757fc7b 100644 --- a/backend/src/components/application.js +++ b/backend/src/components/application.js @@ -1,13 +1,12 @@ /* eslint-disable quotes */ 'use strict'; -const { getOperation, postOperation, patchOperationWithObjectId, deleteOperationWithObjectId} = require('./utils'); +const { getOperation, postOperation, patchOperationWithObjectId, deleteOperationWithObjectId, minify} = require('./utils'); const { CCOF_APPLICATION_TYPES, ORGANIZATION_PROVIDER_TYPES } = require('../util/constants'); const HttpStatus = require('http-status-codes'); const log = require('./logger'); const { MappableObjectForFront, MappableObjectForBack } = require('../util/mapping/MappableObject'); -const { ECEWEApplicationMappings, ECEWEFacilityMappings } = require('../util/mapping/Mappings'); +const { ECEWEApplicationMappings, ECEWEFacilityMappings, RFIApplicationMappings } = require('../util/mapping/Mappings'); const { getCCFRIClosureDates } = require('./facility'); -const { loadFiles } = require('../config/index'); async function renewCCOFApplication(req, res) { log.info('renew CCOF application called'); @@ -29,6 +28,47 @@ async function renewCCOFApplication(req, res) { } } +async function getRFIApplication(req, res) { + let query = `ccof_rfipfis?$filter=(statuscode eq 1) and (_ccof_applicationccfri_value eq ${req.params.ccfriId})`; + try { + const response = await getOperation(query); + console.log('response: ', minify(response.value)); + console.log('response length: ', response.value.length); + if (response.value.length == 1) { + return res.status(HttpStatus.OK).json(new MappableObjectForFront(response.value[0], RFIApplicationMappings)); + } else { + return res.status(HttpStatus.NOT_FOUND).json({message: 'No data'}); + } + } catch (e) { + log.error(e); + return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data? e.data : e?.status ); + } +} + +async function updateRFIApplication(req, res) { + try { + const friApplication = new MappableObjectForBack(req.body, RFIApplicationMappings).toJSON(); + let friApplicationResponse = await patchOperationWithObjectId('ccof_rfipfis', req.params.rfipfiid, friApplication); + friApplicationResponse = new MappableObjectForFront(friApplicationResponse, RFIApplicationMappings); + return res.status(HttpStatus.OK).json(friApplicationResponse); + } catch (e) { + log.error('updateRFIApplication error:', e); + return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status); + } +} + +async function createRFIApplication(req, res) { + try { + const friApplication = new MappableObjectForBack(req.body, RFIApplicationMappings).toJSON(); + friApplication['ccof_applicationccfri@odata.bind'] = `/contacts(ccof_applicationccfris='${req.params.ccfriId}')`; + log.verbose('createRFIApplication payload:', friApplication); + const friApplicationGuid = await postOperation('ccof_rfipfis', friApplication); + return res.status(HttpStatus.CREATED).json({ friApplicationGuid: friApplicationGuid }); + } catch (e) { + log.error('createRFIApplication error:', e); + return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data? e.data : e?.status ); + } +} //creates or updates CCFRI application. @@ -242,6 +282,7 @@ async function getECEWEApplication(req, res) { } } + async function updateECEWEApplication(req, res) { let application = req.body; application = new MappableObjectForBack(application, ECEWEApplicationMappings); @@ -298,6 +339,8 @@ module.exports = { getECEWEApplication, updateECEWEApplication, updateECEWEFacilityApplication, - renewCCOFApplication - //getCCFRIApplication + renewCCOFApplication, + getRFIApplication, + createRFIApplication, + updateRFIApplication, }; diff --git a/backend/src/components/public.js b/backend/src/components/public.js index 748113d1..d9b9184b 100644 --- a/backend/src/components/public.js +++ b/backend/src/components/public.js @@ -42,7 +42,7 @@ async function getFacility(req, res) { let results = {}; let approvedFeesByChildAgeCategory = []; - let operation = 'accounts('+req.params.facilityId+')?$select=accountid,address1_city,accountnumber,name&$expand=ccof_account_ccof_parent_fees_Facility($select=ccof_parent_feesid,ccof_apr,ccof_aug,_ccof_childcarecategory_value,ccof_dec,_ccof_facility_value,ccof_feb,ccof_jan,ccof_jul,ccof_jun,ccof_mar,ccof_may,ccof_nov,ccof_oct,_ccof_programyear_value,ccof_sep,ccof_frequency),ccof_facility_licenses_Facility_account($select=ccof_facility_licensesid,_ccof_facility_value,_ccof_licensecategory_value)'; + let operation = `accounts(${req.params.facilityId})?$select=accountid,address1_city,accountnumber,name&$expand=ccof_account_ccof_parent_fees_Facility($select=ccof_availability,ccof_parent_feesid,ccof_apr,ccof_aug,_ccof_childcarecategory_value,ccof_dec,_ccof_facility_value,ccof_feb,ccof_jan,ccof_jul,ccof_jun,ccof_mar,ccof_may,ccof_nov,ccof_oct,_ccof_programyear_value,ccof_sep,ccof_frequency;$filter=(Microsoft.Dynamics.CRM.In(PropertyName='ccof_availability',PropertyValues=['100000001','100000002']))),ccof_facility_licenses_Facility_account($select=ccof_facility_licensesid,_ccof_facility_value,_ccof_licensecategory_value)` let payLoad = await getOperation(operation); results.facilityId = payLoad.accountnumber; diff --git a/backend/src/components/user.js b/backend/src/components/user.js index a4654764..c5d0337f 100644 --- a/backend/src/components/user.js +++ b/backend/src/components/user.js @@ -20,8 +20,9 @@ async function getUserInfo(req, res) { message: 'No session data' }); } - let isIdir = isIdirUser(req); - let userName = req.params?.userName; + const isIdir = isIdirUser(req); + const queryUserName = req.params?.queryUserName; + const userName = getUserName(req); // if is idir user (ministry user), make sure they are a user in dynamics if (isIdir) { @@ -37,33 +38,23 @@ async function getUserInfo(req, res) { } let resData = { - displayName: (userName)? req.session.passport.user._json.display_name + '-' + userName : req.session.passport.user._json.display_name, - userName: getUserName(req), + displayName: (queryUserName)? req.session.passport.user._json.display_name + '-' + queryUserName : req.session.passport.user._json.display_name, + userName: userName, email: req.session.passport.user._json.email, isMinistryUser: isIdir, serverTime: new Date(), //TODO: unreadMessages is hardcoded. Remove this with API values when built out! unreadMessages: false, }; - let userGuid = undefined; + // let userGuid = undefined; + let userResponse = undefined; if (isIdir) { - if (userName) { + if (queryUserName) { try { - let profileData = await getOperation(`contacts?$select=ccof_userid,firstname,lastname&$filter=ccof_username eq '${userName}'`); - if (profileData.value?.length > 0) { - //found something. - userGuid = profileData.value[0].ccof_userid; - if (!userGuid) { - //found the account but no user guid associated - return res.status(HttpStatus.CONFLICT).json({ - message: 'User found but no User Guid associated' - }); - } - } else { - //didn't find that user - return res.status(HttpStatus.NOT_FOUND).json({ - message: 'No user found with that BCeID UserName' - }); + log.info(`Ministry user [${userName}] is impersonating with username: [${queryUserName}].`); + userResponse = await getUserProfile('\'\'', queryUserName); + if (userResponse === null) { + return res.status(HttpStatus.NOT_FOUND).json({message: 'No user found with that BCeID UserName'}); } } catch (e) { log.error('getUserProfile Error', e.response ? e.response.status : e.message); @@ -75,10 +66,11 @@ async function getUserInfo(req, res) { } } else { //Not an idir user, so just get the guid from the header - userGuid = getUserGuid(req); + const userGuid = getUserGuid(req); + log.verbose('User Guid is: ', userGuid); + userResponse = await getUserProfile(userGuid, userName ); } - log.verbose('User Guid is: ', userGuid); - const userResponse = await getUserProfile(userGuid); + if (log.isVerboseEnabled) { log.verbose('getUserProfile response:',minify(userResponse)); @@ -108,8 +100,9 @@ async function getUserInfo(req, res) { return res.status(HttpStatus.OK).json(results); } -async function getUserProfile(businessGuid) { +async function getUserProfile(businessGuid, userName) { try { + const url = config.get('dynamicsApi:apiEndpoint') + `/api/UserProfile?userId=${businessGuid}&userName=${userName}`; const url = config.get('dynamicsApi:apiEndpoint') + `/api/UserProfile?userId=${businessGuid}&userName=''`; log.verbose('UserProfile Url is', url); const response = await axios.get(url, getHttpHeader()); diff --git a/backend/src/routes/application.js b/backend/src/routes/application.js index 282d357c..e67cf5e2 100644 --- a/backend/src/routes/application.js +++ b/backend/src/routes/application.js @@ -3,8 +3,8 @@ const passport = require('passport'); const router = express.Router(); const auth = require('../components/auth'); const isValidBackendToken= auth.isValidBackendToken(); -const { upsertParentFees, upsertCCFRIApplication, updateCCFRIApplication, renewCCOFApplication} = require('../components/application'); -const { getECEWEApplication, updateECEWEApplication, updateECEWEFacilityApplication , getCCFRIApplication} = require('../components/application'); +const { upsertParentFees, getRFIApplication, updateCCFRIApplication, renewCCOFApplication} = require('../components/application'); +const { getECEWEApplication, updateECEWEApplication, updateECEWEFacilityApplication , getCCFRIApplication, createRFIApplication, updateRFIApplication} = require('../components/application'); const { param, validationResult, checkSchema} = require('express-validator'); const { log } = require('../components/logger'); @@ -53,6 +53,25 @@ router.get('/ccfri/:ccfriId', passport.authenticate('jwt', {session: false}),isV return getCCFRIApplication(req, res); }); +router.get('/ccfri/:ccfriId/rfi', passport.authenticate('jwt', {session: false}),isValidBackendToken, + [param('ccfriId', 'URL param: [ccfriId] is required').not().isEmpty()], (req, res) => { + validationResult(req).throw(); + return getRFIApplication(req, res); + }); + +router.post('/ccfriId/:ccfriId/rfi', passport.authenticate('jwt', {session: false}),isValidBackendToken, + [param('ccfriId', 'URL param: [ccfriId] is required').not().isEmpty()], (req, res) => { + validationResult(req).throw(); + return createRFIApplication(req, res); + }); + +router.put('/rfi/:', passport.authenticate('jwt', {session: false}),isValidBackendToken, + [param('rfipfiid', 'URL param: [rfipfiid] is required').not().isEmpty()], (req, res) => { + validationResult(req).throw(); + return updateRFIApplication(req, res); + }); + + router.patch('/ccfri', passport.authenticate('jwt', {session: false}),isValidBackendToken, [], (req, res) => { //validationResult(req).throw(); //console.log(req.bpdy); diff --git a/backend/src/routes/user.js b/backend/src/routes/user.js index 86704b49..c7a7ea22 100644 --- a/backend/src/routes/user.js +++ b/backend/src/routes/user.js @@ -10,6 +10,6 @@ const { getUserInfo} = require('../components/user'); router.get('/', passport.authenticate('jwt', {session: false}), isValidBackendToken, getUserInfo); -router.get('/:userName', passport.authenticate('jwt', {session: false}), isValidBackendToken, getUserInfo); +router.get('/:queryUserName', passport.authenticate('jwt', {session: false}), isValidBackendToken, getUserInfo); module.exports = router; diff --git a/backend/src/util/mapping/Mappings.js b/backend/src/util/mapping/Mappings.js index efcab0dc..48da5da9 100644 --- a/backend/src/util/mapping/Mappings.js +++ b/backend/src/util/mapping/Mappings.js @@ -48,6 +48,29 @@ const CCFRIFacilityMappings = [ // XXXXXXXXXXXXX: 'hasReceivedFunding', ]; +const RFIApplicationMappings = [ + { back: 'ccof_isthereanythingelseaboutyourchangeinhours', front: 'changeInHours'}, // "is there anything else about your change in hours", + { back: 'ccof_rfipfiid', front: 'rfiId'}, // "df27e229-0b88-ed11-81ac-000d3af48db8", + { back: 'ccof_feeincreasedduetoaincreasedconnection', front: 'feeIncrease' }, // 1 or 0 + { back: 'ccof_appliedforanyothersources', front: 'otherSources' }, // 1 or 0 + { back: 'ccof_howwillyourfeeincreasecontributetotheover', front: 'contributionOverall'}, // "how will your fee increase contribute to the overall?", + { back: 'ccof_feeincreasedduetoaincreaseinhoursdays', front: 'increaseDueToHours' }, // 1 or 0 + { back: 'ccof_describewhetherparentsoutofpocketmonthlyc', front: 'outOfPocket'}, // "describe whether parents out of pocket monthly", + { back: 'ccof_isthereanythingelseaboutyourexpensesyouw', front: 'anythingElse'}, // "is there anything else about your expenses", + { back: 'ccof_meetalloftheabovecriteria', front: 'meetCriteria' }, // 1 or 0 + { back: 'statuscode', front: 'status' }, // 1 or 0 + { back: 'ccof_feeincreasedduetoanexceptionalcircumstance', front: 'exceptionalCircumstances'}, // 0, + { back: 'ccof_pleaseexplainwhyyouhaveincurredorwillincu', front: 'xxx1'}, // "Please explain why you have incurred or will incur", + { back: 'ccof_feeincreasedduetoawageincrease', front: 'feeIncreaseDueToWage' }, // 1 or 0 + { back: 'ccof_name', front: 'xxx3'}, // "RFI-22000025", + { back: 'ccof_pleasedescribehowthemajorityofchildrenyou', front: 'xxx4'}, // "please describe how the majority of children you provide", + { back: '_ccof_applicationccfri_value@OData.Community.Display.V1.FormattedValue', front: 'xxx5'}, // "ID-22000522", + { back: '_ccof_applicationccfri_value', front: 'ccfriApplicationId'}, // "1d261039-0e7c-ed11-81ad-000d3af4f277", + { back: 'ccof_increasedparentfeesbefore', front: 'xxx6' }, // 1 or 0 + { back: 'ccof_exceptionalcircumstanceoccurwithin6m', front: 'circumstanceOccurWithin6Month'}, // null, +]; + + const CCFRIClosureDateMappings = [ { back: 'ccof_startdate', front: 'startDate' }, { back: 'ccof_enddate', front: 'endDate' }, @@ -237,4 +260,5 @@ module.exports = { CCFRIFacilityMappings, CCFRIClosureDateMappings, OrganizationFacilityMappings, + RFIApplicationMappings, }; diff --git a/frontend/src/components/RFI/NMF.vue b/frontend/src/components/RFI/NMF.vue index b7b17e54..c32031d5 100644 --- a/frontend/src/components/RFI/NMF.vue +++ b/frontend/src/components/RFI/NMF.vue @@ -127,7 +127,7 @@ - + diff --git a/frontend/src/components/RFI/RFILanding.vue b/frontend/src/components/RFI/RFILanding.vue index 0429b408..bfb72697 100644 --- a/frontend/src/components/RFI/RFILanding.vue +++ b/frontend/src/components/RFI/RFILanding.vue @@ -30,47 +30,43 @@
-

Is your fee increase due to an exceptional circumstance?


-
-

Does the exceptional circumstance occur within 6 months of the fee increase?

+
- -
- +
import { PATHS } from '@/utils/constants'; - +import { mapActions, mapState } from 'vuex'; let q1 = ''; let q2 = ''; let q3 = ''; @@ -372,6 +368,7 @@ export default { data() { return { model, + test: 1, input : '', expenseList, fundingList, @@ -395,11 +392,31 @@ export default { next(); }, computed: { - + ...mapState('rfiApp', ['rfiModel']), }, + watch: { + '$route.params.urlGuid': { + handler() { + let ccfriId = this.$route.params.urlGuid; + this.loadRfi(ccfriId); + }, + immediate: true, + deep: true + }, + rfiModel: { + handler() { + this.model = { ...this.rfiModel }; + this.$refs.form?.resetValidation(); + }, + immediate: true, + deep: true + } + }, methods : { + ...mapActions('rfiApp', ['loadRfi', 'saveRfi']), + next(){ - this.$router.push(PATHS.WageIncrease); + this.$router.push(PATHS.WageIncrease + '/' + '2dd4af36-9688-ed11-81ac-000d3a09ce90'); // if (this.model.q1 === 'Yes'){ // this.$router.push(PATHS.addNewFees); diff --git a/frontend/src/components/RFI/WageIncrease.vue b/frontend/src/components/RFI/WageIncrease.vue index 01b594d0..ed48f456 100644 --- a/frontend/src/components/RFI/WageIncrease.vue +++ b/frontend/src/components/RFI/WageIncrease.vue @@ -39,24 +39,23 @@

-

Is your fee increase due to a wage increase for Direct Care Staff?

-
+

Was the wage increase committed to (in writing) before the January 2022 release of the Funding Guidelines?

import { PATHS } from '@/utils/constants'; - +import { mapActions, mapState } from 'vuex'; let wageList = [ { @@ -408,9 +407,30 @@ export default { next(); }, computed: { - + ...mapState('rfiApp', ['rfiModel']), }, + watch: { + '$route.params.urlGuid': { + handler() { + let ccfriId = this.$route.params.urlGuid; + console.log('watched'); + this.loadRfi(ccfriId); + }, + immediate: true, + deep: true + }, + rfiModel: { + handler() { + this.model = { ...this.rfiModel }; + this.$refs.form?.resetValidation(); + }, + immediate: true, + deep: true + } + }, + methods : { + ...mapActions('rfiApp', ['loadRfi', 'saveRfi']), addRow () { this.wageList.push( { staffRole: '', diff --git a/frontend/src/components/ccfriApplication/group/AddNewFees.vue b/frontend/src/components/ccfriApplication/group/AddNewFees.vue index 21c268f1..125b1c22 100644 --- a/frontend/src/components/ccfriApplication/group/AddNewFees.vue +++ b/frontend/src/components/ccfriApplication/group/AddNewFees.vue @@ -391,7 +391,7 @@ export default { computed: { ...mapGetters('app', ['lookupInfo']), ...mapGetters('auth', ['userInfo']), - ...mapState('app', ['navBarList', 'isRenewal']), + ...mapState('app', ['navBarList', 'isRenewal', 'rfiList']), ...mapState('ccfriApp', ['CCFRIFacilityModel', 'ccfriChildCareTypes']), ...mapState('organization', ['applicationId']), @@ -433,8 +433,8 @@ export default { }, methods: { ...mapActions('ccfriApp', ['loadCCFRIFacility', 'loadFacilityCareTypes', 'decorateWithCareTypes']), - ...mapMutations('ccfriApp', ['setFeeModel', 'addModelToStore']), - + ...mapMutations('ccfriApp', ['setFeeModel', 'addModelToStore']), + ...mapMutations('app', ['setRfiList']), addRow () { this.CCFRIFacilityModel.dates.push( { datePicker1: undefined, @@ -465,7 +465,15 @@ export default { } else { console.log('going to ece-we!'); - this.$router.push({path : `${PATHS.eceweEligibility}`}); + this.setRfiList([{name: 'facilityName', guid: 'ccfriguid'}]); + if (this.rfiList?.length > 0) { + this.$router.push(PATHS.ccfriRequestMoreInfo + '/' + '2dd4af36-9688-ed11-81ac-000d3a09ce90'); + } else { + this.$router.push({path : `${PATHS.eceweEligibility}`}); + } + // + + } this.save(); //-- right now because of the refresh this is out- depending how we go forward maybe put back in diff --git a/frontend/src/components/util/NavBar.vue b/frontend/src/components/util/NavBar.vue index 9f7af8bf..8cd229a8 100644 --- a/frontend/src/components/util/NavBar.vue +++ b/frontend/src/components/util/NavBar.vue @@ -101,7 +101,7 @@ export default { }; }, computed: { - ...mapState('app', ['pageTitle', 'navBarGroup', 'navBarList', 'ccofApplicationComplete', 'isRenewal', 'ccfriOptInComplete', 'navBarRefresh', 'isOrganizationComplete','ccofLicenseUploadComplete']), + ...mapState('app', ['pageTitle', 'navBarGroup', 'navBarList', 'ccofApplicationComplete', 'isRenewal', 'ccfriOptInComplete', 'navBarRefresh', 'isOrganizationComplete','ccofLicenseUploadComplete', 'rfiList']), ...mapGetters('facility', ['isFacilityComplete', 'isNewFacilityStarted']), ...mapGetters('groupFunding', ['isNewFundingStarted']), ...mapGetters('auth', ['userInfo']), @@ -186,8 +186,11 @@ export default { } else { this.items.push(this.getCCOFNavigation()); } - this.items.push(this.getCCFRINavigation()); + if (this.rfiList?.length > 0) { + console.log('hi'); + this.items.push(this.getRFINavigation()); + } this.items.push(this.getECEWENavigation()); this.items.push({ title: 'Supporting Document', @@ -259,9 +262,47 @@ export default { items: items }; return retval; + }, + getRFINavigation(){ + let items = []; + items.push( + { + title: 'Opt in / Opt out', + link: { name: 'ccfri-home'}, + isAccessible: true, + icon: this.getCheckbox(this.ccfriOptInComplete), + isActive: 'ccfri-home' === this.$route.name + }, - + ); + if (this.navBarList?.length > 0) { + this.navBarList?.forEach((item, index) => { + if (item.ccfriOptInStatus == 1){ + items.push( + { + title: 'Parent Fees '+ (index + 1), + subTitle: item.facilityName, + id: item.facilityId, + link: { name: 'ccfri-add-fees-guid', params: {urlGuid: item.ccfriApplicationId}}, + isAccessible: true, + icon: 'mdi-checkbox-blank-circle-outline', //replace + isActive: this.$route.params.urlGuid === item.ccfriApplicationId + // function: this.loadFacility(x.id) + }, + ); + } + }); + } + let retval = { + title: NAV_BAR_GROUPS.RFI, + isAccessible: true, + icon: 'mdi-checkbox-blank-circle-outline', //replace + expanded: this.isExpanded(NAV_BAR_GROUPS.RFI), + items: items + }; + return retval; }, + getCCOFNavigation() { let items = []; items.push( diff --git a/frontend/src/router.js b/frontend/src/router.js index 99edebc1..6af4751d 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -340,24 +340,24 @@ const router = new VueRouter({ }, { - path: PATHS.ccfriRequestMoreInfo, + path: PATHS.ccfriRequestMoreInfo + '/:urlGuid', name: 'ccfri-request-info', component: CCFRIRequestMoreInfo, meta: { pageTitle: 'CCFRI Request More Info', showNavBar: true, - navBarGroup: NAV_BAR_GROUPS.CCFRI, + navBarGroup: NAV_BAR_GROUPS.RFI, requiresAuth: true, } }, { - path: PATHS.WageIncrease, + path: PATHS.WageIncrease + '/:urlGuid', name: 'ccfri-wage-increase', component: WageIncrease, meta: { pageTitle: 'CCFRI Wage Increase', showNavBar: true, - navBarGroup: NAV_BAR_GROUPS.CCFRI, + navBarGroup: NAV_BAR_GROUPS.RFI, requiresAuth: true, } }, diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index fd00bf24..8a462e11 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -13,6 +13,7 @@ import familyFunding from '@/store/modules/ccof/family/familyFundingStore'; import familyEligibility from '@/store/modules/ccof/family/familyEligibilityStore'; import familyOrganization from '@/store/modules/ccof/family/familyOrganizationStore'; import ccfriApp from '@/store/modules/ccfriApp.js'; +import rfiApp from '@/store/modules/rfiApp.js'; import eceweApp from '@/store/modules/eceweApp.js'; import message from '@/store/modules/message.js'; @@ -33,6 +34,7 @@ export default new Vuex.Store({ groupFunding, ccfriApp, eceweApp, + rfiApp, message, supportingDocumentUpload } diff --git a/frontend/src/store/modules/app.js b/frontend/src/store/modules/app.js index dbd4c59e..dee150bb 100644 --- a/frontend/src/store/modules/app.js +++ b/frontend/src/store/modules/app.js @@ -13,6 +13,7 @@ export default { ccofLicenseUploadComplete:false, ccofApplicationComplete: false, ccofConfirmationEnabled: false, + rfiList: [], //Notification Details ccfriOptInComplete: false, //jb alertNotificationText: '', @@ -95,6 +96,10 @@ export default { addToNavBarList: (state, payload) => { state.navBarList.push (payload); }, + setRfiList: (state, rfiList) => { + state.rfiList = rfiList; + }, + setCcofApplicationComplete: (state, ccofApplicationComplete) => { state.ccofApplicationComplete = ccofApplicationComplete; }, diff --git a/frontend/src/store/modules/rfiApp.js b/frontend/src/store/modules/rfiApp.js new file mode 100644 index 00000000..4cdeb0e0 --- /dev/null +++ b/frontend/src/store/modules/rfiApp.js @@ -0,0 +1,121 @@ +import ApiService from '@/common/apiService'; +import { ApiRoutes } from '@/utils/constants'; +import { checkSession } from '@/utils/session'; +import { getChanges } from '@/utils/validation'; + +export default { + namespaced: true, + state: { + rfiModel: {}, + loadedModel: {}, + rfiStore: {}, + }, + mutations: { + setRfiModel: (state, value) => { state.rfiModel = value; }, + setLoadedModel: (state, value) => { state.loadedModel = value; }, + addRfiToStore: (state, {ccfriId, model} ) => { + if (ccfriId) { + state.rfiStore[ccfriId] = model; + } + }, + }, + getters: { + getByCcfriId: (state) => (ccfriId) => { + return state.rfiStore[ccfriId]; + }, + }, + + actions: { + async loadRfi({getters, commit}, ccfriId) { + let rfiModel = getters.getByCcfriId(ccfriId); + if (rfiModel) { + console.log('found rfimodel for ccfriId: ', ccfriId); + commit('setRfiModel', rfiModel); + commit('setLoadedModel', rfiModel); + } else { + checkSession(); + try { + let response = await ApiService.apiAxios.get(ApiRoutes.APPLICATION_RFI + '/' + ccfriId + '/rfi'); + commit('addRfiToStore', {ccfriId: ccfriId, model: response.data}); + commit('setRfiModel', response.data); + commit('setLoadedModel', response.data); + } catch(e) { + console.log(`Failed to get existing RFI with error - ${e}`); + throw e; + } + } + }, + async saveOrganization({ state, commit, rootState }) { + + checkSession(); + const payload = getChanges(state.organizationModel, state.loadedModel); + console.log('saveOrganization, payload', payload); + if (!payload) { + return; //No changes. so return from function + } + commit('setLoadedModel', state.organizationModel); + + if (state.organizationId) { + // has an orgaization ID, so update the data + try { + let response = await ApiService.apiAxios.put(ApiRoutes.ORGANIZATION + '/' + state.organizationId, payload); + commit('setIsOrganizationComplete', response.data?.isOrganizationComplete); + return response; + } catch (error) { + console.log(`Failed to update existing Organization - ${error}`); + throw error; + } + } else { + // else create a new application and set the program year + payload.programYearId = rootState.app.programYearList.current.programYearId; + try { + let response = await ApiService.apiAxios.post(ApiRoutes.ORGANIZATION, payload); + commit('setOrganizationId', response.data?.organizationId); + commit('setApplicationId', response.data?.applicationId); + commit('setApplicationStatus', response.data?.applicationStatus); + commit('setApplicationType', response.data?.applicationType); + commit('setOrganizationProviderType', response.data?.organizationProviderType); + commit('setIsOrganizationComplete', response.data?.isOrganizationComplete); + return response; + } catch (error) { + console.log(`Failed to save new Organization - ${error}`); + throw error; + } + } + }, + async renewApplication({ commit, state, rootState }) { + checkSession(); + + let payload = { + providerType: state.organizationProviderType, + programYearId: rootState.app.programYearList.future.programYearId, + organizationId: state.organizationId, + }; + console.log('renewApplication, payload', payload); + try { + const response = await ApiService.apiAxios.post(ApiRoutes.APPLICATION_RENEW, payload); + commit('setApplicationId', response.data?.applicationId); + return response; + } catch (error) { + console.log(`Failed to renew Application - ${error}`); + throw error; + } + }, + + async loadOrganization({ commit }, organizationId) { + checkSession(); + + try { + let response = await ApiService.apiAxios.get(ApiRoutes.ORGANIZATION + '/' + organizationId); + commit('setOrganizationModel', response.data); + commit('setLoadedModel', response.data); + commit('setIsOrganizationComplete', response.data?.isOrganizationComplete); + console.log('response.data?.isOrganizationComplete', response.data?.isOrganizationComplete); + } catch (error) { + console.log(`Failed to get Organization - ${error}`); + throw error; + } + + } + }, +}; diff --git a/frontend/src/utils/constants.js b/frontend/src/utils/constants.js index 8e41a172..676d91bd 100644 --- a/frontend/src/utils/constants.js +++ b/frontend/src/utils/constants.js @@ -33,6 +33,7 @@ export const ApiRoutes = Object.freeze({ APPLICATION_ECEWE: baseRoot + '/application/ecewe', APPLICATION_ECEWE_FACILITY: baseRoot + '/application/ecewe/facilities', APPLICATION_RENEW: baseRoot + '/application/renew-ccof', + APPLICATION_RFI: baseRoot + '/application/ccfri', SUPPORTING_DOCUMENT_UPLOAD:baseRoot+'/supportingDocument' }); @@ -54,7 +55,7 @@ export const PATHS = { ccfriHome: '/ccfriApplication/group/CcfriEceLanding', addNewFees: '/ccfriApplication/group/add-new-fees', currentFees: '/ccfriApplication/group/current-fees', - ccfriRequestMoreInfo: '/ccfri-application/request-info', + ccfriRequestMoreInfo: '/ccfri-application/request-info/landing', WageIncrease: '/ccfri-application/request-info/wage-increase', ServiceExpansion: '/ccfri-application/request-info/service-expansion', IndigenousServiceExpansion: '/ccfri-application/request-info/indigenous-service-expansion', @@ -87,6 +88,7 @@ export const PATHS = { export const NAV_BAR_GROUPS = { CCOF: 'CCOF', CCFRI: 'CCFRI', + RFI: 'RFI', ECEWE: 'ECE-WE' };