refactor appeal for new and resume

This commit is contained in:
2026-01-15 13:21:11 +00:00
parent 9241fe0b84
commit 83dc4e12e3
11 changed files with 533 additions and 1 deletions
@@ -0,0 +1,82 @@
// lib/myportal/hydrateMyPortalAppealStore.js
import {
setContainerID,
setLoggedInUserEmail,
setLoggedInUserId,
setAccountDetails,
} from "../../store/accountDetails/action";
import {
setAppealLPA,
setAppealType,
setAppealTypeID,
setCaseReference as setCaseReferenceAction,
setFilesForAppeal,
} from "../../store/appealType/action";
import {
setAwaitingSubmissionDetails,
setAwaitingSubmissionFromBlob,
} from "../../store/awaitingSubmission/action";
import { setCurrentView, setLocale } from "../../store/currentView/action";
import { setForm } from "../../store/formData/action";
/**
* Hydrates Redux store for resume flow in /myportal/[appealtypes]
*/
export function hydrateMyPortalAppealStore(store, ctx, data) {
const { query, locale } = ctx;
const {
session,
loggedInUser,
loggedInUserEmail,
appealTypeData,
mandatoryFieldsData,
pickListData,
blobList,
blobProgress,
accountDetails,
awaitingSubmissionFromBlob,
xmlStr,
} = data;
// Keep existing behaviour: write locale into store
store.dispatch(setLocale(locale));
// Build caseReference in the same shape you already use
const caseReference = {
ticketnumber: query.casereference,
incidentid: query.inid, // as per your file
caseDetails: blobProgress,
};
// Optional awaiting submission state setup
if (awaitingSubmissionFromBlob) {
store.dispatch(
setAwaitingSubmissionFromBlob(awaitingSubmissionFromBlob)
);
store.dispatch(
setAwaitingSubmissionDetails(awaitingSubmissionFromBlob)
);
store.dispatch(
setCurrentView({
viewName: "Awaiting Submission",
viewKey: "awaitingSubmissionDetails",
})
);
}
store.dispatch(setLoggedInUserId(loggedInUser));
store.dispatch(setLoggedInUserEmail(loggedInUserEmail));
store.dispatch(setAppealLPA(query.lpa));
store.dispatch(setAppealTypeID(query.apt));
store.dispatch(setCaseReferenceAction(caseReference));
store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData));
store.dispatch(setAppealType(appealTypeData));
store.dispatch(setContainerID(session.user.id));
store.dispatch(setAccountDetails(accountDetails));
store.dispatch(setFilesForAppeal(blobList));
}
+91
View File
@@ -0,0 +1,91 @@
// lib/myportal/loadMyPortalAppealPage.js
import { getSession } from "next-auth/react";
import {
getAppealsTypesForNewAppeal,
getAwaitingSubmissionFromBlob,
getFilesFromBlob,
getIP,
getMandatoryFields,
getPickLists,
getProgressFromBlob,
getPersonalAccount,
} from "../../actions";
import { readFormXml } from "../forms/readFormXml";
import { requireQueryParams } from "../routing/requireQueryParams";
/**
* Loader for "resume appeal" in /myportal/[appealtypes]
*/
export async function loadMyPortalAppealPage(ctx) {
const { query, req } = ctx;
getIP(req);
// Required params for resume flow (adjust if your routes always provide them)
// casereference is the main identifier here
const required = requireQueryParams(query, [
"appealtypes",
"apt",
"casereference",
]);
if (!required.ok) {
return { redirect: required.redirect };
}
const session = await getSession(ctx);
if (!session) {
return {
redirect: {
destination: "/auth/signin",
permanent: false,
},
};
}
const { cookies } = req;
const loggedInUser = cookies?.pinsUser;
const loggedInUserIdent = session.user.id;
const loggedInUserEmail = session.user.email;
const accountDetails = await getPersonalAccount(loggedInUser);
// Fetch config + blob assets in parallel
const [appealTypeData, mandatoryFieldsData, pickListData, blobList] =
await Promise.all([
getAppealsTypesForNewAppeal(),
getMandatoryFields(query.appealtypes),
getPickLists(query.appealtypes),
getFilesFromBlob(loggedInUserIdent, query.casereference),
]);
const blobProgress = await getProgressFromBlob(
loggedInUserIdent,
query.casereference
);
// Optional: awaiting-submission view setup when query.key exists
let awaitingSubmissionFromBlob = null;
if (Object.prototype.hasOwnProperty.call(query, "key")) {
awaitingSubmissionFromBlob = await getAwaitingSubmissionFromBlob(
session.user.id
);
}
const { xmlStr } = readFormXml(query.appealtypes);
return {
session,
loggedInUser,
loggedInUserIdent,
loggedInUserEmail,
appealTypeData,
mandatoryFieldsData,
pickListData,
blobList,
blobProgress,
accountDetails,
awaitingSubmissionFromBlob,
xmlStr,
};
}