Skip to content

feat(frontend): edit primary doc screen#486

Open
Dario-Au wants to merge 1 commit intomainfrom
edit-primary-doc
Open

feat(frontend): edit primary doc screen#486
Dario-Au wants to merge 1 commit intomainfrom
edit-primary-doc

Conversation

@Dario-Au
Copy link
Contributor

@Dario-Au Dario-Au commented Mar 25, 2025

Summary

AB#19354 Copy screens to the multichannel flow
Added edit primary doc screen
Moved person-case models to sin-application

Types of changes

What types of changes does this PR introduce?
(check all that apply by placing an x in the relevant boxes)

  • 🛠️ refactoring -- non-breaking change that improves code readability or structure
  • 🐛 bugfix -- non-breaking change that fixes an issue
  • new feature -- non-breaking change that adds functionality
  • 💥 breaking change -- change that causes existing functionality to no longer work as expected
  • 📚 documentation -- changes to documentation only
  • ⚙️ build or tooling -- ex: CI/CD, dependency upgrades

Checklist

Before submitting this PR, ensure that you have completed the following. You can fill these out now, or after creating the PR.
(check all that apply by placing an x in the relevant boxes)

  • code has been linted and formatted locally
  • added or updated tests to verify the changes
  • added adequate logging for new or updated functionality
  • ensured metrics and/or tracing are in place for monitoring and debugging
  • documentation has been updated to reflect the changes (if applicable)
  • linked this PR to a related issue (if applicable)
Linting and formatting
npm run lint:check
npm run format:check
Unit and e2e tests
npm run test
npm run test:e2e

Additional Notes

If this PR introduces significant changes, explain your reasoning and provide any necessary context here. Feel free to include diagrams, screenshots, or alternative approaches you considered.

Screenshots (if applicable)

Provide screenshots or screen-recordings to help reviewers understand the visual impact of your changes, if relevant.

@Dario-Au Dario-Au force-pushed the edit-primary-doc branch 2 times, most recently from 9a03f5b to 8c3fc1f Compare March 25, 2025 17:18
@Dario-Au Dario-Au enabled auto-merge (squash) March 25, 2025 17:19
state: string;
};
createdCases: Record<string, PersonSinCase>;
editingCase?: SinCaseDto;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if this should go in the global session definition. This should be scoped to the flow that uses it.

Comment on lines 11 to 13
if (session.editingCase && session.editingCase.caseId === caseId) {
return session.editingCase;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Storing a chunk of data like this in session is not multi-tab safe. If the user opens the same flow in multiple tabs, the data from one will clobber the data from the other.

Does the data need to be stored in session? Is this a part of a multi-page flow? If not, just fetch the data on demand and updated it as required. If this is a part of a multi-page flow and you need to keep the data from one page to the next (and you can't re-fetch it), then you have to use a tab id to isolate the session data.

}

export function getEditingSinCase(request: Request, session: AppSession, caseId: string): SinCaseDto {
if (!session.editingCase) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if (session.editingCase && session.editingCase.caseId === caseId) {
return session.editingCase;
}
const sinCase = await getSinCaseService().getSinCaseById(caseId);
Copy link
Contributor

Choose a reason for hiding this comment

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

This file's responsibility is validation. In my opinion, it shouldn't be fetching data unless it's some lookup code that is required for validation.

status: HttpStatusCodes.NOT_FOUND,
});
}
const personSinCase = await fetchSinCase(context.session, params.caseId);
Copy link
Contributor

Choose a reason for hiding this comment

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

The case data should be fetched first, then passed to the validation module for validation (if required).

The validation module shouldn't be fetching data, nor should it be deciding on navigational flows (ie: throw i18nRedirect()). This stuff should be handled before the validation module is called.

See https://github.com/DTS-STN/future-sir/pull/486/files#r2014085232.

@Dario-Au Dario-Au force-pushed the edit-primary-doc branch 3 times, most recently from de4f6fd to c65a834 Compare March 28, 2025 18:37
@Dario-Au Dario-Au disabled auto-merge March 31, 2025 13:36
@Dario-Au Dario-Au enabled auto-merge (squash) April 1, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants