Skip to content
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

feat(app-sys): changes to app sys that were bundled with financial aid update #17210

Merged
merged 8 commits into from
Dec 13, 2024

Conversation

jonnigs
Copy link
Member

@jonnigs jonnigs commented Dec 11, 2024

What

Add back in changes to the application system that were reverted with the financial aid reveret
buildAccordionField
buildBankInfoField
dynamic logo for applications

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Introduced accordion and bank account form fields with dedicated components.
    • Added localization support for bank account-related messages in Icelandic.
  • Bug Fixes

    • Improved handling of form logo assignment in the FormShell component.
  • Documentation

    • Updated exports to include new form field components.
  • Chores

    • Enhanced utility functions for better component type handling.

Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Walkthrough

The pull request introduces several new functionalities and modifications across multiple files. It adds two new field builder functions, buildAccordionField and buildBankAccountField, to create specific field configurations. Additionally, new message definitions for bank account terms are added to enhance localization. Two new interfaces, AccordionField and BankAccountField, are defined along with their respective components for rendering in the UI. The Form interface is updated, and utility functions for handling form components are introduced, improving the overall structure and functionality of the application.

Changes

File Path Change Summary
libs/application/core/src/lib/fieldBuilders.ts Added functions buildAccordionField and buildBankAccountField for field configuration.
libs/application/core/src/lib/messages.ts Introduced new messages for bank account terms in coreDefaultFieldMessages.
libs/application/types/src/lib/Fields.ts Added types/interfaces AccordionItem, AccordionField, and BankAccountField; updated enums.
libs/application/types/src/lib/Form.ts Updated logo property type in Form interface from React.FC to FormComponent.
libs/application/ui-fields/src/lib/AccordionFormField/AccordionFormField.tsx Added AccordionFormField component for rendering accordion UI elements.
libs/application/ui-fields/src/lib/BankAccountFormField/BankAccountFormField.tsx Added BankAccountFormField component for rendering bank account fields.
libs/application/ui-fields/src/lib/index.ts Exported new components AccordionFormField and BankAccountFormField.
libs/application/ui-shell/src/lib/FormShell.tsx Modified how FormLogo is assigned using getFormComponent.
libs/application/ui-shell/src/utils.ts Added utility functions for type checking and introduced getFormComponent for component retrieval.

Possibly related PRs

Suggested labels

automerge, deploy-feature

Suggested reviewers

  • Toti91
  • HjorturJ

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ab2f13 and f342717.

📒 Files selected for processing (1)
  • libs/application/ui-shell/src/lib/FormShell.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/application/ui-shell/src/lib/FormShell.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jonnigs jonnigs changed the title feat: changes to app sys that were bundled with financial aid update feat(app-sys): changes to app sys that were bundled with financial aid update Dec 11, 2024
@jonnigs jonnigs marked this pull request as ready for review December 11, 2024 15:32
@jonnigs jonnigs requested a review from a team as a code owner December 11, 2024 15:32
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (5)
libs/application/ui-shell/src/utils.ts (1)

165-167: Improve type checking with optional chaining

The component prototype check can be simplified using optional chaining.

-    typeof component === 'function' &&
-    !(component.prototype && component.prototype.isReactComponent) &&
-    component.length === 0
+    typeof component === 'function' &&
+    !component.prototype?.isReactComponent &&
+    component.length === 0
🧰 Tools
🪛 Biome (1.9.4)

[error] 166-166: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

libs/application/ui-fields/src/lib/AccordionFormField/AccordionFormField.tsx (2)

12-14: Add prop validation for required fields

Consider adding runtime validation for required fields using PropTypes or a schema validation library to catch potential issues early in development.


19-25: Optimize performance with useMemo

Consider memoizing the items calculation to prevent unnecessary re-renders when other props change.

-  useEffect(() => {
-    if (typeof accordionItems === 'function') {
-      setItems(accordionItems(application))
-    } else {
-      setItems(accordionItems)
-    }
-  }, [accordionItems])
+  const calculatedItems = useMemo(() => {
+    return typeof accordionItems === 'function'
+      ? accordionItems(application)
+      : accordionItems
+  }, [accordionItems, application])
+
+  useEffect(() => {
+    setItems(calculatedItems)
+  }, [calculatedItems])
libs/application/ui-fields/src/lib/BankAccountFormField/BankAccountFormField.tsx (1)

14-82: Document format patterns

Add JSDoc comments to document the expected format patterns for each input field. This will help other developers understand the validation requirements.

+/**
+ * BankAccountFormField component for collecting bank account information
+ * @param field - The bank account field configuration
+ * @param application - The application context
+ * 
+ * Format patterns:
+ * - Bank number: #### (4 digits)
+ * - Ledger: ## (2 digits)
+ * - Account number: ###### (6 digits)
+ */
 export const BankAccountFormField = ({ field, application }: Props) => {
libs/application/types/src/lib/Fields.ts (1)

682-695: Consider adding validation support to AccordionField.

The AccordionField interface could benefit from validation capabilities to ensure content meets requirements.

Consider adding validation-related properties:

export interface AccordionField extends BaseField {
  readonly type: FieldTypes.ACCORDION
  component: FieldComponents.ACCORDION
  accordionItems:
    | Array<AccordionItem>
    | ((application: Application) => Array<AccordionItem>)
  marginTop?: ResponsiveProp<Space>
  marginBottom?: ResponsiveProp<Space>
  titleVariant?: TitleVariants
+ validate?: (items: Array<AccordionItem>) => boolean
+ validationErrorMessage?: FormText
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5c8c1b9 and 8ab2f13.

📒 Files selected for processing (9)
  • libs/application/core/src/lib/fieldBuilders.ts (2 hunks)
  • libs/application/core/src/lib/messages.ts (1 hunks)
  • libs/application/types/src/lib/Fields.ts (4 hunks)
  • libs/application/types/src/lib/Form.ts (1 hunks)
  • libs/application/ui-fields/src/lib/AccordionFormField/AccordionFormField.tsx (1 hunks)
  • libs/application/ui-fields/src/lib/BankAccountFormField/BankAccountFormField.tsx (1 hunks)
  • libs/application/ui-fields/src/lib/index.ts (1 hunks)
  • libs/application/ui-shell/src/lib/FormShell.tsx (2 hunks)
  • libs/application/ui-shell/src/utils.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
libs/application/types/src/lib/Form.ts (1)

Pattern 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/ui-fields/src/lib/index.ts (1)

Pattern 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/ui-shell/src/lib/FormShell.tsx (1)

Pattern 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/core/src/lib/messages.ts (1)

Pattern 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/ui-shell/src/utils.ts (1)

Pattern 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/ui-fields/src/lib/BankAccountFormField/BankAccountFormField.tsx (1)

Pattern 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/types/src/lib/Fields.ts (1)

Pattern 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/ui-fields/src/lib/AccordionFormField/AccordionFormField.tsx (1)

Pattern 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/core/src/lib/fieldBuilders.ts (1)

Pattern 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."
🪛 Biome (1.9.4)
libs/application/ui-shell/src/utils.ts

[error] 166-166: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (6)
libs/application/types/src/lib/Form.ts (1)

82-82: LGTM: Type change enhances logo flexibility

The change from React.FC to FormComponent type for the logo property improves flexibility by allowing dynamic logo generation based on application state.

libs/application/ui-shell/src/utils.ts (1)

160-189: LGTM: Well-implemented type guards and component handling

The implementation provides robust type checking with proper TypeScript type guards. The getFormComponent function handles all cases gracefully and maintains type safety throughout.

🧰 Tools
🪛 Biome (1.9.4)

[error] 166-166: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

libs/application/ui-shell/src/lib/FormShell.tsx (1)

28-28: LGTM: Clean integration of dynamic logo handling

The integration of getFormComponent is clean and maintains the component's simplicity while adding support for dynamic logos.

Also applies to: 70-70

libs/application/ui-fields/src/lib/index.ts (1)

33-34: LGTM!

The new exports follow the established pattern and maintain alphabetical ordering.

libs/application/core/src/lib/fieldBuilders.ts (1)

1016-1040: Verify accordion component integration.

The function implementation looks correct, but let's verify the AccordionFormField component exists.

✅ Verification successful

The accordion field implementation is correctly integrated with its component

The buildAccordionField function is properly implemented and aligns with the AccordionFormField component found in libs/application/ui-fields/src/lib/AccordionFormField/AccordionFormField.tsx. The component:

  • Accepts all the properties returned by the builder function
  • Properly handles both static and dynamic accordionItems
  • Correctly uses the optional properties like titleVariant, marginTop, and marginBottom
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify AccordionFormField component exists
# Test: Search for AccordionFormField component definition
ast-grep --pattern 'export const AccordionFormField = $$$'

Length of output: 4641

libs/application/core/src/lib/messages.ts (1)

321-335: LGTM! Messages follow the established pattern.

The new bank account related messages are well-structured and properly localized.

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 30.90909% with 38 lines in your changes missing coverage. Please review.

Project coverage is 35.74%. Comparing base (5a13f96) to head (f342717).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../src/lib/AccordionFormField/AccordionFormField.tsx 5.88% 16 Missing ⚠️
.../lib/BankAccountFormField/BankAccountFormField.tsx 10.00% 9 Missing ⚠️
libs/application/ui-shell/src/utils.ts 53.33% 7 Missing ⚠️
libs/application/core/src/lib/fieldBuilders.ts 25.00% 6 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17210      +/-   ##
==========================================
- Coverage   35.75%   35.74%   -0.01%     
==========================================
  Files        6935     6937       +2     
  Lines      148113   148149      +36     
  Branches    42233    42242       +9     
==========================================
+ Hits        52953    52954       +1     
- Misses      95160    95195      +35     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.33% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.39% <ø> (ø)
application-api-files 61.87% <100.00%> (+0.13%) ⬆️
application-core 75.78% <50.00%> (-0.24%) ⬇️
application-system-api 38.75% <50.00%> (+0.01%) ⬆️
application-template-api-modules 27.83% <50.00%> (+0.03%) ⬆️
application-templates-accident-notification 28.82% <25.00%> (-0.02%) ⬇️
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.77% <25.00%> (-0.01%) ⬇️
application-templates-driving-license 18.16% <25.00%> (+0.03%) ⬆️
application-templates-estate 13.80% <25.00%> (+0.01%) ⬆️
application-templates-example-payment 24.72% <25.00%> (+<0.01%) ⬆️
application-templates-financial-aid 14.46% <25.00%> (+0.03%) ⬆️
application-templates-general-petition 23.15% <25.00%> (+0.01%) ⬆️
application-templates-inheritance-report 6.59% <25.00%> (+0.05%) ⬆️
application-templates-marriage-conditions 15.19% <25.00%> (+0.07%) ⬆️
application-templates-mortgage-certificate 43.64% <50.00%> (+0.03%) ⬆️
application-templates-parental-leave 29.94% <25.00%> (-0.01%) ⬇️
application-types 6.51% <0.00%> (-0.06%) ⬇️
application-ui-components 1.24% <ø> (ø)
application-ui-shell 22.51% <25.49%> (+<0.01%) ⬆️
clients-charge-fjs-v2 28.35% <ø> (ø)
cms 0.39% <ø> (ø)
cms-translations 38.72% <ø> (ø)
judicial-system-api 20.16% <ø> (ø)
judicial-system-backend 55.83% <ø> (ø)
services-user-notification 46.52% <ø> (+0.02%) ⬆️
web 2.42% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
libs/application/core/src/lib/messages.ts 100.00% <ø> (ø)
libs/application/types/src/lib/Fields.ts 100.00% <100.00%> (ø)
libs/application/types/src/lib/Form.ts 100.00% <ø> (ø)
libs/application/ui-shell/src/lib/FormShell.tsx 69.44% <100.00%> (ø)
libs/application/core/src/lib/fieldBuilders.ts 40.50% <25.00%> (-0.65%) ⬇️
libs/application/ui-shell/src/utils.ts 55.91% <53.33%> (-0.50%) ⬇️
.../lib/BankAccountFormField/BankAccountFormField.tsx 10.00% <10.00%> (ø)
.../src/lib/AccordionFormField/AccordionFormField.tsx 5.88% <5.88%> (ø)

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a13f96...f342717. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 11, 2024

Datadog Report

All test runs ca286b4 🔗

21 Total Test Services: 0 Failed, 20 Passed
🔻 Test Sessions change in coverage: 3 decreased, 14 increased, 76 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-web 0 0 0 2 0 8.66s 1 no change Link
api 0 0 0 4 0 3.16s 1 no change Link
application-api-files 0 0 0 2 0 4.24s 1 increased (+0.13%) Link
application-core 0 0 0 97 0 14.77s 1 decreased (-0.19%) Link
application-system-api 0 0 0 46 0 2m 24.97s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 4.58s 1 increased (+0.01%) Link
application-templates-accident-notification 0 0 0 148 0 14.75s 1 increased (+0.14%) Link
application-templates-criminal-record 0 0 0 2 0 10.76s 1 no change Link
application-templates-driving-license 0 0 0 13 0 16.74s 1 increased (+0.06%) Link
application-templates-example-payment 0 0 0 2 0 11.74s 1 increased (+0.02%) Link

🔻 Code Coverage Decreases vs Default Branch (3)

  • application-core - jest 82.2% (-0.19%) - Details
  • application-types - jest 5.38% (-0.05%) - Details
  • application-ui-shell - jest 29.39% (-0.02%) - Details

Copy link
Member

@HjorturJ HjorturJ left a comment

Choose a reason for hiding this comment

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

LGTM

@jonnigs jonnigs added the automerge Merge this PR as soon as all checks pass label Dec 11, 2024
@kodiakhq kodiakhq bot removed the automerge Merge this PR as soon as all checks pass label Dec 12, 2024
Copy link
Contributor

kodiakhq bot commented Dec 12, 2024

This PR currently has a merge conflict. Please resolve this and then re-add the automerge label.

@jonnigs jonnigs added the automerge Merge this PR as soon as all checks pass label Dec 13, 2024
@kodiakhq kodiakhq bot merged commit 444cedf into main Dec 13, 2024
113 of 122 checks passed
@kodiakhq kodiakhq bot deleted the feat/add-app-sys-changes-from-fa-back-in branch December 13, 2024 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants