Skip to content

Conversation

@m-salaudeen
Copy link
Contributor

Description

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

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.

@m-salaudeen m-salaudeen self-assigned this Nov 3, 2025
@m-salaudeen m-salaudeen requested a review from a team as a code owner November 3, 2025 14:38
@m-salaudeen m-salaudeen requested a review from a team as a code owner November 13, 2025 07:49
"WAITING_FOR_PROOF",
"PROOF_AVAILABLE"
"PROOF_AVAILABLE",
"TEMPLATE_PROOF_APPROVED"
Copy link
Contributor

@chris-elliott-nhsd chris-elliott-nhsd Nov 13, 2025

Choose a reason for hiding this comment

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

if we want to keep this change to the frontend, we shouldn't be updating lists of backend statuses or any backend code including the event publisher

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because this is used to generate types. I will be changing this approach as suggested by Michael

"WAITING_FOR_PROOF",
"PROOF_AVAILABLE"
"PROOF_AVAILABLE",
"TEMPLATE_PROOF_APPROVED"
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels strange having this on the API spec when this isn't a status on the backend. The API will never return or accept this status. I know its used to generate the types. But I wonder if there's a that the status change can be shifted further left or further right.

Further left would be something like we make the API return this status (we wouldn't have to change in the database). Maybe we update the Zod parser so that it transforms the status from SUBMITTED to TEMPLATE_PROOF_APPROVED.

Or further right would be something like ... I will comment in the appropriate place 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

I added a comment in utils/utils/src/enum.ts with the shift-right option. I think I prefer that approach rather than shift-left.


const templateStatusToDisplayMappingsLetter = (status: TemplateStatus) =>
statusToDisplayMappings[status];
const isProofEmpty = (
Copy link
Contributor

Choose a reason for hiding this comment

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

This returns true if template.files.proofs in non-empty, right?
Should this be called isProofAvailable instead?

? templateStatusToDisplayMappingsLetter(
template.templateStatus,
isRoutingEnabled,
isProofEmpty(template)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shift right option:

You could get rid of templateStatusToDisplayMappingsDigital and templateStatusToDisplayMappingsLetter, you could rework statusToDisplayMapping like this:

It'd mean that you don't need to introduce the TEMPLATE_PROOF_APPROVED status on the open api spec and into the type system.

export const statusToDisplayMapping = (
  template: TemplateDto,
  isRoutingEnabled: boolean = false
): string => {
  const statusToDisplayMappings: Record<TemplateStatus, string> = {
    NOT_YET_SUBMITTED:
      template.templateType === 'LETTER' ? 'Not yet submitted' : 'Draft',
    SUBMITTED:
      template.templateType === 'LETTER' &&
      isRoutingEnabled &&
      isProofAvailable(template)
        ? 'Template proof approved'
        : 'Submitted',
    DELETED: '', // will not be shown in the UI
    PENDING_PROOF_REQUEST: 'Files uploaded',
    PENDING_UPLOAD: 'Checking files',
    PENDING_VALIDATION: 'Checking files',
    VALIDATION_FAILED: 'Checks failed',
    VIRUS_SCAN_FAILED: 'Checks failed',
    WAITING_FOR_PROOF: 'Waiting for proof',
    PROOF_AVAILABLE: 'Proof available',
  } as const;

  return statusToDisplayMappings[template.templateStatus];
};

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.

3 participants