Skip to content

CCM-14190: letter variants#854

Open
harrim91 wants to merge 42 commits intomainfrom
feature/CCM-14190_choose-printing-and-postage
Open

CCM-14190: letter variants#854
harrim91 wants to merge 42 commits intomainfrom
feature/CCM-14190_choose-printing-and-postage

Conversation

@harrim91
Copy link
Contributor

@harrim91 harrim91 commented Feb 24, 2026

Description

  • Adds page for selecting letter variants on an authoring template
  • Adds letter variants database
  • Adds API endpoints for querying letter variants:
    • One endpoint gets all letter variants that are eligible for use by a template (returns global variants, plus those relevant to the client / campaign on the template - if no campaign on the template, only client scoped are returned)
    • Other endpoint gets a letter variant by id
  • Displays letter variant name instead of id on the preview page
  • Puts in some lock number checks that I'd missed on the edit campaign / edit name pages
  • Resets the letter variant when changing campaign id, if a campaign scoped letter variant was chosen

The other big change is replacing createAuthHelper in the playwright tests with a broader getTestContext function. Previously the client config set up was nested into the AuthHelper. Instead of also nesting the new letter variants helper (which also needs to be globally available state, linked to clients), I've un-nested things, and added the AuthContext class which is like a facade, responsible for exposing the three things, and orchestrating the setup / teardown. This change is where the bulk of the changed files comes from.

@ClareJonesBJSS edit - also tidied up the barrels in nhs-notify-backend-client which has ballooned the files touched again, but just with import updates

Context

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming
  • If I have used the 'skip-trivy-package' label I have done so responsibly and in the knowledge that this is being fixed as part of a separate ticket/PR.

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

@harrim91 harrim91 requested review from a team as code owners February 24, 2026 16:38
@harrim91 harrim91 marked this pull request as draft February 24, 2026 16:38
@harrim91 harrim91 added the skip-trivy-package Skip the Trivy Package Scan label Feb 27, 2026
@harrim91 harrim91 marked this pull request as ready for review February 27, 2026 11:59
@ClareJonesBJSS ClareJonesBJSS removed the skip-trivy-package Skip the Trivy Package Scan label Mar 3, 2026
@ClareJonesBJSS ClareJonesBJSS force-pushed the feature/CCM-14190_choose-printing-and-postage branch from 45c6848 to b43835b Compare March 6, 2026 12:01
alexnuttall
alexnuttall previously approved these changes Mar 9, 2026
alexnuttall
alexnuttall previously approved these changes Mar 10, 2026
alexnuttall
alexnuttall previously approved these changes Mar 10, 2026
@harrim91 harrim91 dismissed stale reviews from alexnuttall and aidenvaines-cgi via 741c034 March 10, 2026 15:59
const [state] = useNHSNotifyForm();

return (
<input
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a 1 sentence explanation for why we cant make our notify form component work with the inputs from the react lib?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In a sentence. The React components are too opinionated for our designs. Our designs tend to go off-piste a little bit, and this approach gives you smaller components which have the NHS styling, but which are more composable.

It depends on the input type and the context we're using it in. I

n this case, the react lib Radios component always looks something like this.

Image

But in this new page, we needed them to be nested inside a table. This was the simplest way to achieve that.

Our file upload just looks completely different to the NHSUK one (not sure why we didn't go with the standard one)

The library components support props for showing errors, hints etc. But we have instances where it's laid out differently. e.g. in some places we have a <details> section between the hint and the input, which isn't supported by the lib.

}

const searchParams = await props.searchParams;
const lockNumberResult = $LockNumber.safeParse(searchParams?.lockNumber);
Copy link
Contributor

@nicki-nhs nicki-nhs Mar 11, 2026

Choose a reason for hiding this comment

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

on the other pages, have you not redirected early on the invalid lock number? pre fetching client?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe the same Q also fcor the template status?
I guess its keeping all those conditions for the redirect together vs redirecting early as soon as we know?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the same as this in some places, and there's an early redirect in other places. I think in this case it was to group all of the conditions for the redirect to the preview page together, and because there are two possible preview pages based on the template status.

I can put the early redirect in if you think it's better. I'd have to get the template status though to know which preview url to redirect to. Unless the preview -> preview-submitted status check / redirect goes into the preview page?

value={variant.id}
aria-labelledby={`label-${variant.id}`}
/>
<span className='nhsuk-radios__label'> </span>
Copy link
Contributor

Choose a reason for hiding this comment

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

is this just to make the nhs frontend styling work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think the radio button doesn't show without this, I took this from somewhere else I think.

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.

6 participants