-
Notifications
You must be signed in to change notification settings - Fork 70
fix(secondary school): Add check for applicationDataHasBeenPruned #18968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(secondary school): Add check for applicationDataHasBeenPruned #18968
Conversation
WalkthroughA new utility function, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant OverviewComponent
participant HelperFunctions
participant Messages
User->>OverviewComponent: Render Overview
OverviewComponent->>HelperFunctions: applicationDataHasBeenPruned(answers)
HelperFunctions-->>OverviewComponent: true/false
alt Data has been pruned
OverviewComponent->>Messages: Get pruned state message (by application state)
Messages-->>OverviewComponent: Localized message
OverviewComponent-->>User: Show pruned message
else Data not pruned
OverviewComponent-->>User: Show detailed overview components
end
sequenceDiagram
participant User
participant SubmittedForm
participant HelperFunctions
User->>SubmittedForm: Interact with form
SubmittedForm->>HelperFunctions: applicationDataHasBeenPruned(answers)
HelperFunctions-->>SubmittedForm: true/false
alt Data has been pruned
SubmittedForm-->>User: Hide alerts, disable submit
else Data not pruned
SubmittedForm-->>User: Show alerts (if applicable), enable submit
end
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
libs/application/templates/secondary-school/src/utils/helperFunctions/index.ts
Show resolved
Hide resolved
View your CI Pipeline Execution ↗ for commit a4fdd0f.
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (5)
libs/application/templates/secondary-school/src/utils/helperFunctions/index.ts (1)
13-15
: Add JSDoc comments to explain this new utility function.This function seems to be checking whether an application's data has been pruned by checking if
approveExternalData
is falsy. Adding a JSDoc comment would help other developers understand the reasoning behind this implementation.+/** + * Checks if the application data has been pruned. + * @param answers The application form values + * @returns True if the application data has been pruned (when approveExternalData is false/undefined) + */ export const applicationDataHasBeenPruned = (answers: FormValue) => { return !getValueViaPath<boolean>(answers, 'approveExternalData') }libs/application/templates/secondary-school/src/fields/overview/index.tsx (1)
15-24
: Consider extracting the message rendering logic into a helper component.The conditional rendering block could be extracted into a separate component for better readability and maintainability, especially if this pattern might be reused elsewhere.
+const PrunedDataMessage = ({ state }: { state: string }) => { + const { formatMessage } = useLocale() + + if (state === States.SUBMITTED) { + return <>{formatMessage(overview.applicationDataHasBeenPruned.submitted)}</> + } + + if (state === States.IN_REVIEW) { + return <>{formatMessage(overview.applicationDataHasBeenPruned.inReview)}</> + } + + if (state === States.COMPLETED) { + return <>{formatMessage(overview.applicationDataHasBeenPruned.completed)}</> + } + + return null +} export const Overview: FC<FieldBaseProps> = (props) => { const { formatMessage } = useLocale() return applicationDataHasBeenPruned(props.application.answers) ? ( <Box> - {props.application.state === States.SUBMITTED && - formatMessage(overview.applicationDataHasBeenPruned.submitted)} - {props.application.state === States.IN_REVIEW && - formatMessage(overview.applicationDataHasBeenPruned.inReview)} - {props.application.state === States.COMPLETED && - formatMessage(overview.applicationDataHasBeenPruned.completed)} + <PrunedDataMessage state={props.application.state} /> </Box> ) : (libs/application/templates/secondary-school/src/forms/submittedForm.ts (3)
37-41
: Improve readability with a descriptive variable name.The condition logic is duplicated in multiple places. Consider creating a descriptive helper function or variable to make the intent more clear.
condition: (answers) => { + const isDataAvailableForDisplay = !applicationDataHasBeenPruned(answers); return ( - !applicationDataHasBeenPruned(answers) && + isDataAvailableForDisplay && checkIsFreshman(answers) ) },
49-53
: Improve readability with a descriptive variable name.Similar to the previous comment, use a descriptive variable to improve readability.
condition: (answers) => { + const isDataAvailableForDisplay = !applicationDataHasBeenPruned(answers); return ( - !applicationDataHasBeenPruned(answers) && + isDataAvailableForDisplay && !checkIsFreshman(answers) ) },
70-70
: Consistency with other conditions.For consistency with other conditions in this file, consider using the same descriptive variable approach here as well.
-condition: (answers) => !applicationDataHasBeenPruned(answers), +condition: (answers) => { + const isDataAvailableForDisplay = !applicationDataHasBeenPruned(answers); + return isDataAvailableForDisplay; +},
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
libs/application/templates/secondary-school/src/fields/overview/index.tsx
(1 hunks)libs/application/templates/secondary-school/src/forms/submittedForm.ts
(4 hunks)libs/application/templates/secondary-school/src/lib/messages/overview.ts
(1 hunks)libs/application/templates/secondary-school/src/utils/helperFunctions/index.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`libs/**/*`: "Confirm that the code adheres to the following: - Reusability of components and hooks across different NextJS apps. - TypeScript usage for defining props and exportin...
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/application/templates/secondary-school/src/utils/helperFunctions/index.ts
libs/application/templates/secondary-school/src/forms/submittedForm.ts
libs/application/templates/secondary-school/src/fields/overview/index.tsx
libs/application/templates/secondary-school/src/lib/messages/overview.ts
🧬 Code Graph Analysis (1)
libs/application/templates/secondary-school/src/forms/submittedForm.ts (1)
libs/application/templates/secondary-school/src/utils/helperFunctions/index.ts (1)
applicationDataHasBeenPruned
(13-15)
libs/application/templates/secondary-school/src/lib/messages/overview.ts
Outdated
Show resolved
Hide resolved
Datadog ReportAll test runs ✅ 4 Total Test Services: 0 Failed, 4 Passed Test Services
|
...
Note: We can revert all this stuff when the applications for this term can actually be pruned
What
Display some information if application that has been submitted, but all the data has been accidentally pruned
Why
12 applications were accidentally pruned in end of april 2025
Screenshots / Gifs
If state = submitted :

If state = inReview:

If state = completed:

Checklist:
Summary by CodeRabbit
New Features
Bug Fixes