Skip to content

Conversation

@kegrimes
Copy link
Contributor

@kegrimes kegrimes commented Dec 12, 2025

Description

Combine new, edit, and view pages into a single page that routes to /housingAllowance/[requestId]. This page displays different UI based on the mode query parameter.

Implementation: I have used query params (?mode=new, ?mode=edit, ?mode=view) to determine which UI to display. I was thinking about using status (MhaStatusEnum), but there wouldn't be a solid way to determine which display is needed. When a user clicks the navigation buttons, they will be directed to the appropriate mode.

NOTE: In order to test this properly, you need to change MinisterHousingAllowance.tsx line 96 to this:

  const currentRequest = requests[1] || {};

It has been kept as requests[0] since changing it will affect the tests.

Testing

  • Go to /reports/housingAllowance
  • Click on "Edit Request"
  • Check that it displays correct UI with the appropriate mode AND user is on Step 2
  • Click back arrow icon
  • Click on "View Request"
  • Check that it displays correct UI with the appropriate mode

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels (Add the label "Preview" to automatically create a preview environment)
  • I have run the Claude Code /pr-review command locally and fixed any relevant suggestions
  • I have requested a review from another person on the project
  • I have tested my changes in preview or in staging
  • I have cleaned up my commit history

@github-actions
Copy link
Contributor

github-actions bot commented Dec 12, 2025

Bundle sizes [mpdx-react]

Compared against 4f67f48

Route Size (gzipped) Diff
/accountLists/[accountListId]/reports/housingAllowance/[requestId] 163.28 KB added
/accountLists/[accountListId]/reports/housingAllowance/[...requestId] no change removed

@kegrimes kegrimes added the Preview Environment Add this label to create an Amplify Preview label Dec 12, 2025
@github-actions
Copy link
Contributor

@kegrimes kegrimes closed this Dec 13, 2025
@kegrimes kegrimes reopened this Dec 13, 2025
@kegrimes kegrimes requested a review from dr-bizz December 13, 2025 02:44
@wjames111 wjames111 self-requested a review December 18, 2025 14:46
Copy link
Contributor

@wjames111 wjames111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this! Works really well, I had a few small comments and some suggestions but other then that it looks really good.

Comment on lines +53 to +56
const modeLabel =
type === PageEnum.New ? 'New' : type === PageEnum.Edit ? 'Edit' : 'View';
const title = t("{{mode}} Minister's Housing Allowance Request", {
mode:
type === PageEnum.New ? 'New' : type === PageEnum.Edit ? 'Edit' : 'View',
mode: modeLabel,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would update the enum to 'New', 'Edit' and 'View' then just use type here.

Suggested change
const modeLabel =
type === PageEnum.New ? 'New' : type === PageEnum.Edit ? 'Edit' : 'View';
const title = t("{{mode}} Minister's Housing Allowance Request", {
mode:
type === PageEnum.New ? 'New' : type === PageEnum.Edit ? 'Edit' : 'View',
mode: modeLabel,
const title = t("{{mode}} Minister's Housing Allowance Request", {
mode: type,

: mode[1] === PageEnum.Edit
? PageEnum.Edit
: PageEnum.View;
const type = getPageType(mode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional:
I might make this variable name a little more descriptive

Suggested change
const type = getPageType(mode);
const pageType = getPageType(mode);


const { data, error: requestsError } =
useMinistryHousingAllowanceRequestsQuery();
const requestsData = data?.ministryHousingAllowanceRequests.nodes || [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could update this and remove line 56 const requests = requestsData ?? [];

Suggested change
const requestsData = data?.ministryHousingAllowanceRequests.nodes || [];
const requests = data?.ministryHousingAllowanceRequests.nodes ?? [];

Comment on lines +10 to +12
return mode
? `/accountLists/${accountListId}/reports/housingAllowance/${requestId}?mode=${mode}`
: `/accountLists/${accountListId}/reports/housingAllowance/${requestId}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably dry this up a bit

Suggested change
return mode
? `/accountLists/${accountListId}/reports/housingAllowance/${requestId}?mode=${mode}`
: `/accountLists/${accountListId}/reports/housingAllowance/${requestId}`;
const baseUrl = `/accountLists/${accountListId}/reports/housingAllowance/${requestId}`;
return mode ? `${baseUrl}?mode=${mode}` : baseUrl;

);
const mhaRequestId = newRequest?.ministryHousingAllowanceRequest.id;
const requestLink = `/accountLists/${accountListId}/reports/housingAllowance/${mhaRequestId}/new`;
const requestLink = getRequestUrl(accountListId, mhaRequestId, 'new');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably use the PageEnum here

Suggested change
const requestLink = getRequestUrl(accountListId, mhaRequestId, 'new');
const requestLink = getRequestUrl(accountListId, mhaRequestId, PageEnum.New);

<Receipt
formTitle={t('MHA Request')}
buttonText={t('View Your MHA')}
editLink={`${getRequestUrl(accountListId, requestId, 'edit')}`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd pass the enums here for editLink and viewLink.

Comment on lines +171 to +175
useEffect(() => {
if (type === PageEnum.Edit) {
setCurrentStep(StepsEnum.RentOrOwn);
}
}, [type]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we want to start edit mode on the second step?

iconColor="success.main"
linkOneText={t('View Current MHA')}
linkOne={`/accountLists/${accountListId}/reports/housingAllowance/${requestId}/view`}
linkOne={getRequestUrl(accountListId, requestId, 'view')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe enum instead of 'view' here.

iconColor="warning.main"
linkOneText={t('View Request')}
linkOne={`/accountLists/${accountListId}/reports/housingAllowance/${requestId}/view`}
linkOne={getRequestUrl(accountListId, requestId, 'view')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here on and on linkTwo.

complete: false,
},
]
? isEdit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there's a way we could DRY this up a bit. Seems like a lot of repeated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Preview Environment Add this label to create an Amplify Preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants