Untitled
unknown
plain_text
7 months ago
13 kB
7
Indexable
import React, { useEffect } from 'react';
import {
Section,
Page,
Header,
Date,
Card,
Textarea,
List,
ListItem,
Selectbox,
} from '@d-lift/uxcomponents';
import { Navigate, withPage, useAppState, AppContext } from '@d-lift/core';
import PageData from '@/UXModule/bcDesktopWayfinder/aplDesktopWayfinderData.json';
import CPUtil from '@/Util/CPUtil';
import ButtonNavigation from '@/UXModule/ButtonNavigation/ButtonNavigation';
import ConstantKeys from '@/Constants/ConstantKeys';
import dataAdapter from '@/Adapters/DataAdapter';
const pageConfig = {
PageName: 'APLPR',
Description: 'Program And Reason Page',
ContextRoot: 'Appeals',
ContentManager: true,
PageType: 'workflow',
WorkFlowNavigation: true,
TemplateOptions: { cardWorkflow: true },
pageId: 'APLPR',
ShowTitle: false,
SaveAndExitActionUrl: '/APLPR/APLPRLoad',
PersistActionUrl: '/APLPR/APLPRNext',
};
const APLPR = () => {
useEffect(() => {
CPUtil.setValueInAppcontext('currentStep', 2);
CPUtil.setValueInAppcontext('wayFinderSteps', PageData);
//APLPRLoadData();
}, []);
const APLPRLoadData = () => {
dataAdapter
.invokeSummaryLoad({}, AppContext.pagedetails.getPageConfig().saveAndExitActionUrl)
.then((response) => {
let success = dataAdapter.validateServiceResponse(response);
if (success) {
let appealId = response?.data?.appealId;
console.log('data from APLPRLoad', appealId);
setAppealId(appealId);
}
});
};
const defaultData = {
programCd: '',
programReasonCd: '',
noticeAppealingDate: '',
appealApplyDate: '',
otherReason: '',
};
const [APLPR] = useAppState('APLPR', defaultData);
const [appealId, setAppealId] = useAppState('appealId', '796cfb5b-f7f1-4329-a4c1-9c50b7050a0a');
//const [appealId, setAppealId] = useAppState('appealId', ''); uncomment once APLPRLoad is working
const onNext = () => {
let data = AppContext.model.getValue(AppContext.pagedetails.getPageConfig().pageId);
if (!AppContext.model.getValue('errorMsg')) {
dataAdapter.invokeAppealPresist(
{ ...data, appealId },
AppContext.pagedetails.getPageConfig().persistActionUrl,
appealId,
);
}
CPUtil.setValueInAppcontext('currentStep', 3);
Navigate.to('/Appeals/AppealsContinuationOfBenefits/APLCB');
};
const onBack = () => {
Navigate.to('/Appeals/AppealsMoreAbout/APLMR');
};
return (
<Page ref-table-list="APPG_11006 , APPR_11005,APPR_11005:1, APPR_11005:2">
<Section className="container">
<Header labelKey="Appeals_program_reason_header" />
<Header
header-size="2"
className="mt-4"
labelKey="Appeals_program_selection_sub_header"
/>
<Selectbox
id="program_selection"
labelKey="Appeals_program_selection_dropdown_title"
defaultOption="true"
defaultOptionValue="SEL"
defaultOptionLabelKey="common_selectone"
model="APLPR.programCd"
ref-table="APPG_11006"
optionLabel={ConstantKeys.REF_TABLE_COLS.DESCRIPTION}
optionValue={ConstantKeys.REF_TABLE_COLS.CODE}
required="{true}"
validationRules="required"
errormessages='{{"required": "common_mandatory_error"}}'
/>
<Selectbox
id="appeal_reason"
labelKey="Appeals_program_selection_reason_dropdown_title"
defaultOption="true"
defaultOptionValue="SEL"
defaultOptionLabelKey="common_selectone"
model="APLPR.programReasonCd"
ref-table="APPR_11005:1"
showIf={AppContext.model.getValue('APLPR.programCd') === 'snap'}
optionLabel={ConstantKeys.REF_TABLE_COLS.DESCRIPTION}
optionValue={ConstantKeys.REF_TABLE_COLS.CODE}
required="{true}"
validationRules="required"
errormessages='{{"required": "common_mandatory_error"}}'
/>
<Selectbox
id="appeal_reason"
labelKey="Appeals_program_selection_reason_dropdown_title"
defaultOption="true"
defaultOptionValue="SEL"
defaultOptionLabelKey="common_selectone"
model="APLPR.programReasonCd"
ref-table="APPR_11005:2"
showIf={AppContext.model.getValue('APLPR.programCd') === 'ff'}
optionLabel={ConstantKeys.REF_TABLE_COLS.DESCRIPTION}
optionValue={ConstantKeys.REF_TABLE_COLS.CODE}
required="{true}"
validationRules="required"
errormessages='{{"required": "common_mandatory_error"}}'
/>
<Section showIf={AppContext.model.getValue('APLPR.programReasonCd') === 'AP'}>
<Card className="application-pending-info-card mt-4 mb-4">
<Header size="2" labelKey="Application_pending_info_title" />
<List className="application-pending-info-list mb-0">
<ListItem labelKey="Application_pending_info_text1" />
<ListItem labelKey="Application_pending_info_text2" />
</List>
</Card>
</Section>
<Section showIf={AppContext.model.getValue('APLPR.programReasonCd') === 'CLB'}>
<Card className="application-pending-info-card mt-4 mb-4">
<Header size="2" labelKey="benefits_level_info_title" />
<List className="application-pending-info-list mb-0">
<ListItem labelKey="benefits_level_info_text1" />
</List>
</Card>
</Section>
<Section showIf={AppContext.model.getValue('APLPR.programReasonCd') === 'CL'}>
<Card className="application-pending-info-card mt-4 mb-4">
<Header size="2" labelKey="claims_info_title" />
<List className="application-pending-info-list mb-0">
<ListItem labelKey="claims_info_text1" />
</List>
</Card>
</Section>
<Section showIf={AppContext.model.getValue('APLPR.programReasonCd') === 'DEAP'}>
<Card className="application-pending-info-card mt-4 mb-4">
<Header size="2" labelKey="denied_appl_info_title" />
<List className="application-pending-info-list mb-0">
<ListItem labelKey="denied_appl_info_text1" />
</List>
</Card>
</Section>
<Section showIf={AppContext.model.getValue('APLPR.programReasonCd') === 'TE'}>
<Card className="application-pending-info-card mt-4 mb-4">
<Header size="2" labelKey="termination_info_title" />
<List className="application-pending-info-list mb-0">
<ListItem labelKey="termination_info_text1" />
</List>
</Card>
</Section>
<Section showIf={AppContext.model.getValue('APLPR.programReasonCd') === 'LB'}>
<Card className="application-pending-info-card mt-4 mb-4">
<Header size="2" labelKey="lossOfBenefits_info_title" />
<List className="application-pending-info-list mb-0">
<ListItem labelKey="lossOfBenefits_info_text1" />
</List>
</Card>
</Section>
<Header size="2" labelKey="Appeals_additional_details_header" />
<Section showIf={AppContext.model.getValue('APLPR.programReasonCd')}>
<Date
id="noticeDate"
labelKey="notice_date_text"
model="APLPR.noticeAppealingDate"
monthDropdown
yearDropdown
/>
<Date
id="noticeDate"
labelKey="apply_date_text"
model="APLPR.appealApplyDate"
monthDropdown
yearDropdown
/>
</Section>
<Header size="3" labelKey="Tell_us_why_textbox_title" />
<Textarea
labelKey="Maximum_characters"
rows="9"
maxLength="2000"
showRemaining
charRemainingKey="common_char_remaining_text"
model="APLPR.otherReason"
calculateLength="{CPUtil.getTextLengthInBytes}"
validationRules="max_length_in_bytes_2000"
errormessages='{{ max_length_in_bytes_2000: "common_length_validation"}}'
change="{(e)=>CPUtil.handleSpclCharsInTextArea(e)}"
truncate="true"
/>
</Section>
<ButtonNavigation onNext={onNext} onBack={onBack} />
</Page>
);
};
export default withPage(pageConfig, APLPR);
invokeAppealPresist = async (data, presistActionUrl) => {
try {
CPUtil.showSpinner();
let pageAction = this.getPageAction(presistActionUrl);
let serviceContextUrl = this.getServiceUrlContext(pageAction.pageId);
let dataJson = this.createAppealRequest(
serviceContextUrl.serviceContext,
pageAction,
data.appealId,
);
let serviceResponse = await CPUtil.HTTP.post(
serviceContextUrl.baseUrl + presistActionUrl,
dataJson,
);
CPUtil.hideSpinner();
let success = dataAdapter.validateServiceResponse(serviceResponse);
if (success) {
DriverUtil.navigateToNext(AppContext.pagedetails.getPageConfig().pageId);
}
return serviceResponse;
} catch (exceptionObject) {
throw this.exceptionHandling(exceptionObject);
} finally {
CPUtil.hideSpinner();
}
};
createAppealRequest(serviceContext, pageAction, appealId) {
let request = {};
let pageId = AppContext.pagedetails.getPageConfig().pageId;
let model = AppContext.model.getValue(pageId);
// serviceContext
request.serviceContext = serviceContext;
// userDetails
let userDetails = {
loginUserId:
AppContext.security.getProfile()._id ||
CPUtil.getValueFromAppContext(ApplicationConstants.ANONYMOUS_TOKEN),
appNumber: PSUtil.getAppNum(),
};
request.userDetails = userDetails;
// currentActionDetails
let currentActionDetails = {
pageId: pageAction.pageId,
pageAction: pageAction.pageAction,
indvSeqDetails: {},
};
request.currentActionDetails = currentActionDetails;
// pageCollection
request.pageCollection = {
appealId: appealId || '', // Default to empty string if not found
AppealsProgram_Collection: {
programCd: model.programCd || '',
programReasonCd: model.programReasonCd || '',
},
};
return request;
}
update the above code for the createAppealRequest function , so that it takes the AppealsProgram_Collection whatever is sent from APLPR.jsx, and is not consistent or made fixed as above. this function needs to reusable so that whatever the AppealsProgram_Collection is, it will workEditor is loading...
Leave a Comment