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(new-primary-school): Contacts page #17466

Merged
merged 4 commits into from
Jan 16, 2025
Merged

feat(new-primary-school): Contacts page #17466

merged 4 commits into from
Jan 16, 2025

Conversation

helgifr
Copy link
Member

@helgifr helgifr commented Jan 9, 2025

...

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

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

Release Notes

  • New Features

    • Replaced "Relatives" section with a new "Contacts" section in the New Primary School application form.
    • Reduced maximum number of contacts from 6 to 4.
    • Introduced a new subsection for managing contacts within the application form.
  • Improvements

    • Renamed and restructured components and messages to reflect "Contacts" terminology.
    • Updated data schema and type definitions for contacts.
    • Simplified contact information collection process.
  • User Experience

    • More precise contact information collection.
    • Clearer instructions for adding contacts during application.

@helgifr helgifr requested a review from a team as a code owner January 9, 2025 19:04
Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

Walkthrough

The pull request introduces a comprehensive rename and restructure of the "Relatives" section to "Contacts" in the New Primary School application template. This change involves modifications across multiple files, including utility functions, type definitions, form configurations, and message translations. The transformation focuses on replacing "relatives" terminology with "contacts," adjusting the maximum number of entries from 6 to 4, and updating related components and schemas to reflect this new approach.

Changes

File Path Change Summary
libs/application/template-api-modules/.../new-primary-school.utils.ts Replaced relatives with contacts in data transformation logic.
libs/application/templates/.../ContactsTableRepeater/index.tsx Renamed component from RelativesTableRepeater to ContactsTableRepeater, reduced max rows from 6 to 4.
libs/application/templates/.../Review/index.tsx Replaced Relatives component with Contacts component.
libs/application/templates/.../Review/review-groups/Contacts.tsx Renamed Relatives to Contacts, updated navigation and labels.
libs/application/templates/.../fields/index.ts Updated exports to use ContactsTableRepeater.
libs/application/templates/.../forms/NewPrimarySchoolForm/childrenNParentsSection/ Added contactsSubSection.ts, removed relativesSubSection.ts.
libs/application/templates/.../lib/dataSchema.ts Renamed relatives field to contacts, updated validation error messages.
libs/application/templates/.../lib/messages.ts Replaced all "relatives" message keys with "contacts" equivalents.
libs/application/templates/.../lib/newPrimarySchoolUtils.ts Updated variable and type names from relatives to contacts.
libs/application/templates/.../types.ts Replaced RelativesRow interface with ContactsRow.

Possibly related PRs

Suggested labels

deploy-feature

Suggested reviewers

  • sigruntg
  • helgifr

📜 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 cd9d610 and 213f8f4.

📒 Files selected for processing (4)
  • libs/application/templates/new-primary-school/src/fields/Review/index.tsx (2 hunks)
  • libs/application/templates/new-primary-school/src/lib/dataSchema.ts (2 hunks)
  • libs/application/templates/new-primary-school/src/lib/messages.ts (2 hunks)
  • libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • libs/application/templates/new-primary-school/src/lib/dataSchema.ts
  • libs/application/templates/new-primary-school/src/fields/Review/index.tsx
  • libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts
  • libs/application/templates/new-primary-school/src/lib/messages.ts
⏰ Context from checks skipped due to timeout of 90000ms (50)
  • GitHub Check: build (application-system-form)
  • GitHub Check: build (application-system-api)
  • GitHub Check: build (api)
  • GitHub Check: tests (application-system-form,application-template-api-modules,application-template-loader,appli...
  • GitHub Check: tests (application-system-api)
  • GitHub Check: build (application-system-form)
  • GitHub Check: build (application-system-api)
  • GitHub Check: build (api)
  • GitHub Check: tests (application-system-form,application-template-api-modules,application-template-loader,appli...
  • GitHub Check: tests (application-system-api)
  • GitHub Check: build (application-system-form)
  • GitHub Check: build (application-system-api)
  • GitHub Check: build (api)
  • GitHub Check: tests (application-system-form,application-template-api-modules,application-template-loader,appli...
  • GitHub Check: tests (application-system-api)
  • GitHub Check: build (application-system-form)
  • GitHub Check: build (application-system-api)
  • GitHub Check: build (api)
  • GitHub Check: tests (application-system-form,application-template-api-modules,application-template-loader,appli...
  • GitHub Check: tests (application-system-api)
  • GitHub Check: build (application-system-form)
  • GitHub Check: build (application-system-api)
  • GitHub Check: build (api)
  • GitHub Check: tests (application-system-form,application-template-api-modules,application-template-loader,appli...
  • GitHub Check: tests (application-system-api)
  • GitHub Check: build (application-system-form)
  • GitHub Check: build (application-system-api)
  • GitHub Check: build (api)
  • GitHub Check: tests (application-system-form,application-template-api-modules,application-template-loader,appli...
  • GitHub Check: tests (application-system-api)
  • GitHub Check: build (application-system-form)
  • GitHub Check: build (application-system-api)
  • GitHub Check: build (api)
  • GitHub Check: tests (application-system-form,application-template-api-modules,application-template-loader,appli...
  • GitHub Check: tests (application-system-api)
  • GitHub Check: build (application-system-form)
  • GitHub Check: build (application-system-api)
  • GitHub Check: build (api)
  • GitHub Check: tests (application-system-form,application-template-api-modules,application-template-loader,appli...
  • GitHub Check: tests (application-system-api)
  • GitHub Check: build (application-system-form)
  • GitHub Check: build (application-system-api)
  • GitHub Check: build (api)
  • GitHub Check: tests (application-system-form,application-template-api-modules,application-template-loader,appli...
  • GitHub Check: tests (application-system-api)
  • GitHub Check: build (application-system-form)
  • GitHub Check: build (application-system-api)
  • GitHub Check: build (api)
  • GitHub Check: tests (application-system-form,application-template-api-modules,application-template-loader,appli...
  • GitHub Check: tests (application-system-api)

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. (Beta)
  • @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.

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: 0

🔭 Outside diff range comments (1)
libs/application/templates/new-primary-school/src/fields/ContactsTableRepeater/index.tsx (1)

Line range hint 52-84: Update data test IDs to match new terminology.

The data test IDs still use the "relative" prefix (e.g., 'relative-full-name', 'relative-phone-number', etc.) while the component has been renamed to use "contacts". This inconsistency should be fixed.

Apply this diff to update the data test IDs:

-      dataTestId: 'relative-full-name',
+      dataTestId: 'contact-full-name',
-      dataTestId: 'relative-phone-number',
+      dataTestId: 'contact-phone-number',
-      dataTestId: 'relative-national-id',
+      dataTestId: 'contact-national-id',
-      dataTestId: 'relative-relation',
+      dataTestId: 'contact-relation',
🧹 Nitpick comments (2)
libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/contactsSubSection.ts (1)

18-22: Consider using type-safe component reference

Instead of using a string literal for the component name, consider using a type-safe reference to ensure the component exists at compile time.

Example approach:

import { ContactsTableRepeater } from '../../../fields'

// Then in buildCustomField
component: ContactsTableRepeater,
libs/application/templates/new-primary-school/src/types.ts (1)

Line range hint 7-12: Consider using a union type for the relation field

The relation field could benefit from a more specific type definition to constrain possible values and provide better type safety.

Example improvement:

export type ContactRelationType = 'parent' | 'guardian' | 'emergency' | 'other';

export interface ContactsRow {
  fullName: string;
  phoneNumber: string;
  nationalId: string;
  relation: ContactRelationType;
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1a3606f and 17bb917.

📒 Files selected for processing (12)
  • libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.utils.ts (2 hunks)
  • libs/application/templates/new-primary-school/src/fields/ContactsTableRepeater/index.tsx (3 hunks)
  • libs/application/templates/new-primary-school/src/fields/Review/index.tsx (2 hunks)
  • libs/application/templates/new-primary-school/src/fields/Review/review-groups/Contacts.tsx (2 hunks)
  • libs/application/templates/new-primary-school/src/fields/index.ts (1 hunks)
  • libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/contactsSubSection.ts (1 hunks)
  • libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/index.ts (1 hunks)
  • libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/relativesSubSection.ts (0 hunks)
  • libs/application/templates/new-primary-school/src/lib/dataSchema.ts (2 hunks)
  • libs/application/templates/new-primary-school/src/lib/messages.ts (2 hunks)
  • libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts (3 hunks)
  • libs/application/templates/new-primary-school/src/types.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/relativesSubSection.ts
🧰 Additional context used
📓 Path-based instructions (11)
libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/contactsSubSection.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/templates/new-primary-school/src/types.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/templates/new-primary-school/src/fields/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/templates/new-primary-school/src/lib/dataSchema.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/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.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/templates/new-primary-school/src/fields/Review/review-groups/Contacts.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/templates/new-primary-school/src/fields/Review/index.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/templates/new-primary-school/src/fields/ContactsTableRepeater/index.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/templates/new-primary-school/src/lib/newPrimarySchoolUtils.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/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/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/templates/new-primary-school/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."
🔇 Additional comments (14)
libs/application/templates/new-primary-school/src/fields/index.ts (1)

2-2: LGTM! Export change aligns with the renaming initiative

The barrel export pattern is maintained, supporting effective tree-shaking.

libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/index.ts (1)

5-5: LGTM! Section configuration updated consistently

The changes maintain the modular structure while implementing the rename from relatives to contacts.

Also applies to: 10-10

libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/contactsSubSection.ts (1)

1-7: LGTM! Clean implementation using core builders

The implementation follows the established patterns and properly separates concerns.

libs/application/templates/new-primary-school/src/fields/Review/review-groups/Contacts.tsx (2)

21-27: LGTM! Component and data structure renamed consistently.

The renaming from Relatives to Contacts is implemented consistently across the component name and data destructuring.


43-60: LGTM! UI navigation and text changes are consistent.

The screen navigation, section title, and table ID have been updated to use "contacts" terminology consistently.

libs/application/templates/new-primary-school/src/fields/ContactsTableRepeater/index.tsx (1)

46-46: Verify the impact of reducing maximum contacts.

The maximum number of rows has been reduced from 6 to 4. Please ensure this change aligns with business requirements and won't impact existing applications.

Run this script to check for any applications that might be affected:

✅ Verification successful

UI-only change with no impact on existing applications

The reduction from 6 to 4 maximum contacts is a UI-only change that affects only new applications. No validation rules or business logic in the codebase depend on the previous limit of 6 contacts. Existing applications with more than 4 contacts will continue to work as expected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any code that might depend on the previous maximum of 6 contacts
rg -A 2 "maxRows.*6" 
# Search for any tests that might need updating
rg -A 2 "contacts.*length.*6"

Length of output: 54


Script:

#!/bin/bash
# Search for contact-related files
echo "=== Contact-related files ==="
fd -t f -i contact

# Search for validation schemas or rules related to contacts
echo -e "\n=== Validation rules ==="
rg -i "contacts.*validate|contacts.*schema" -A 3

# Search for test files with contact assertions
echo -e "\n=== Test assertions ==="
rg -t test -t spec "contacts.*expect|contacts.*assert|contacts.*should" -A 2

# Search for any number greater than 4 in contact-related files
echo -e "\n=== Contact limits ==="
fd -t f -i contact --exec rg -l "[5-9]|[1-9][0-9]"

Length of output: 7256


Script:

#!/bin/bash
# Check content of primary school contact-related files
echo "=== ContactsTableRepeater implementation ==="
cat "libs/application/templates/new-primary-school/src/fields/ContactsTableRepeater/index.tsx"

echo -e "\n=== Contacts subsection validation ==="
cat "libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/contactsSubSection.ts"

echo -e "\n=== Review component ==="
cat "libs/application/templates/new-primary-school/src/fields/Review/review-groups/Contacts.tsx"

Length of output: 7222

libs/application/templates/new-primary-school/src/lib/dataSchema.ts (1)

Line range hint 63-75: LGTM! Schema changes maintain data validation integrity.

The renaming from relatives to contacts in the schema is consistent, and the validation rules remain intact.

libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.utils.ts (1)

21-21: LGTM! DTO transformation maintains data integrity.

The renaming from relatives to contacts in the DTO transformation is consistent, and the mapping to agents array preserves the same structure.

Also applies to: 66-70

libs/application/templates/new-primary-school/src/fields/Review/index.tsx (2)

23-23: LGTM! Import statement updated correctly.

The import statement has been updated to reflect the new component name, maintaining consistency with the broader refactor from relatives to contacts.


158-158: LGTM! Component usage updated correctly.

The Contacts component is correctly integrated into the review screen, maintaining the same props structure as the previous Relatives component.

libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts (2)

16-16: LGTM! Type import updated correctly.

The import statement has been updated to use the new ContactsRow type, maintaining consistency with the broader refactor.


38-38: LGTM! Variable rename implemented correctly.

The variable has been renamed from relatives to contacts consistently in both the declaration and return statement, maintaining the same functionality.

Also applies to: 120-120

libs/application/templates/new-primary-school/src/lib/messages.ts (2)

249-285: LGTM! Message keys for contacts section added correctly.

The new message keys maintain consistent naming patterns and provide clear, well-structured translations for the contacts section. The description text clearly communicates the requirement of at least one contact and the maximum limit of four contacts.


667-670: LGTM! Error message updated correctly.

The error message for contacts validation maintains consistency with other validation messages in the file while clearly communicating the minimum requirement.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 9, 2025
@datadog-island-is
Copy link

datadog-island-is bot commented Jan 9, 2025

Datadog Report

Branch report: feat/mms-contacts-page
Commit report: c81328c
Test service: api

✅ 0 Failed, 4 Passed, 0 Skipped, 2.94s Total Time
➡️ Test Sessions change in coverage: 1 no change

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 11.11111% with 8 lines in your changes missing coverage. Please review.

Project coverage is 35.61%. Comparing base (caa3127) to head (213f8f4).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...chool/src/fields/Review/review-groups/Contacts.tsx 0.00% 5 Missing ⚠️
...tes/new-primary-school/new-primary-school.utils.ts 0.00% 1 Missing ⚠️
...-school/src/fields/ContactsTableRepeater/index.tsx 0.00% 1 Missing ⚠️
...Form/childrenNParentsSection/contactsSubSection.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main   #17466    +/-   ##
========================================
  Coverage   35.60%   35.61%            
========================================
  Files        7018     7015     -3     
  Lines      150376   150265   -111     
  Branches    42965    42925    -40     
========================================
- Hits        53545    53520    -25     
+ Misses      96831    96745    -86     
Flag Coverage Δ
api 3.33% <ø> (ø)
application-system-api 38.68% <0.00%> (-0.02%) ⬇️
application-template-api-modules 27.57% <0.00%> (ø)
application-templates-new-primary-school 21.21% <12.50%> (ø)
application-ui-shell 22.04% <ø> (ø)

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

Files with missing lines Coverage Δ
...tes/new-primary-school/src/fields/Review/index.tsx 0.00% <ø> (ø)
...PrimarySchoolForm/childrenNParentsSection/index.ts 0.00% <ø> (ø)
...templates/new-primary-school/src/lib/dataSchema.ts 16.66% <ø> (ø)
...n/templates/new-primary-school/src/lib/messages.ts 100.00% <ø> (ø)
...ew-primary-school/src/lib/newPrimarySchoolUtils.ts 72.72% <100.00%> (ø)
...tes/new-primary-school/new-primary-school.utils.ts 12.50% <0.00%> (ø)
...-school/src/fields/ContactsTableRepeater/index.tsx 0.00% <0.00%> (ø)
...Form/childrenNParentsSection/contactsSubSection.ts 0.00% <0.00%> (ø)
...chool/src/fields/Review/review-groups/Contacts.tsx 0.00% <0.00%> (ø)

... and 33 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 caa3127...213f8f4. Read the comment docs.

@helgifr helgifr added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Jan 15, 2025
@kodiakhq kodiakhq bot removed the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Jan 15, 2025
Copy link
Contributor

kodiakhq bot commented Jan 15, 2025

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

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: 0

🧹 Nitpick comments (3)
libs/application/templates/new-primary-school/src/lib/messages.ts (1)

Line range hint 1-767: Well-structured message module following best practices.

The file follows TypeScript best practices with proper type definitions and exports. The modular structure enables effective tree-shaking and reusability across different NextJS applications.

libs/application/templates/new-primary-school/src/fields/Review/review-groups/Contacts.tsx (2)

Line range hint 42-48: Add null checks and type guards for data transformation.

The row mapping could be more robust with:

  1. Null/undefined checks for the contacts array
  2. Type guards for the contact object properties
  3. Error handling for invalid phone numbers or national IDs

Consider this improvement:

-  const rows = contacts.map((r) => {
+  const rows = (contacts ?? []).map((r) => {
+    const phoneNumber = r.phoneNumber ? removeCountryCode(r.phoneNumber) : ''
     return [
-      r.fullName,
-      formatPhoneNumber(removeCountryCode(r.phoneNumber ?? '')),
-      formatKennitala(r.nationalId),
+      r.fullName ?? '',
+      phoneNumber ? formatPhoneNumber(phoneNumber) : '',
+      r.nationalId ? formatKennitala(r.nationalId) : '',
       getSelectedOptionLabel(relationFriggOptions, r.relation) ?? '',
     ]
   })

Line range hint 67-94: Enhance accessibility and user experience.

Consider these improvements:

  1. Add ARIA labels to the table for better screen reader support
  2. Include a message when there are no contacts (currently shows nothing)
  3. Add tooltips for formatted values (phone numbers, national IDs)

Add an empty state message:

   {contacts?.length > 0 && (
     <Box paddingTop={3}>
       <StaticTableFormField
         application={application}
         field={{
           type: FieldTypes.STATIC_TABLE,
           component: FieldComponents.STATIC_TABLE,
           children: undefined,
           id: 'contactsTable',
+          aria-label: formatMessage(newPrimarySchoolMessages.childrenNParents.contactsSubSectionTitle),
           title: '',
           header: [/*...*/],
           rows,
         }}
       />
     </Box>
+  )}
+  {(!contacts || contacts.length === 0) && (
+    <Box paddingTop={3}>
+      <Text variant="small">
+        {formatMessage(newPrimarySchoolMessages.shared.noContactsAdded)}
+      </Text>
     </Box>
   )}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 17bb917 and cd9d610.

📒 Files selected for processing (8)
  • libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.utils.ts (2 hunks)
  • libs/application/templates/new-primary-school/src/fields/ContactsTableRepeater/index.tsx (3 hunks)
  • libs/application/templates/new-primary-school/src/fields/Review/index.tsx (2 hunks)
  • libs/application/templates/new-primary-school/src/fields/Review/review-groups/Contacts.tsx (3 hunks)
  • libs/application/templates/new-primary-school/src/lib/dataSchema.ts (2 hunks)
  • libs/application/templates/new-primary-school/src/lib/messages.ts (2 hunks)
  • libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts (3 hunks)
  • libs/application/templates/new-primary-school/src/types.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • libs/application/templates/new-primary-school/src/lib/dataSchema.ts
  • libs/application/templates/new-primary-school/src/types.ts
  • libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts
  • libs/application/templates/new-primary-school/src/fields/Review/index.tsx
  • libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.utils.ts
  • libs/application/templates/new-primary-school/src/fields/ContactsTableRepeater/index.tsx
🧰 Additional context used
📓 Path-based instructions (2)
libs/application/templates/new-primary-school/src/fields/Review/review-groups/Contacts.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/templates/new-primary-school/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."
🔇 Additional comments (3)
libs/application/templates/new-primary-school/src/lib/messages.ts (2)

262-298: LGTM! Well-structured message definitions.

The contacts section messages are well-organized, properly typed, and follow consistent naming patterns. The translations and descriptions are clear and informative.


716-719: LGTM! Clear error message definition.

The error message for contacts validation is well-defined and follows the established pattern for error messages in the file.

libs/application/templates/new-primary-school/src/fields/Review/review-groups/Contacts.tsx (1)

28-34: Verify component reusability across NextJS apps.

Since this component is in the libs directory, ensure that:

  1. The component and its types are properly exported for use in other NextJS apps
  2. The dependencies are tree-shakeable
  3. The component is not tightly coupled to the new-primary-school template

Run this script to check for proper exports and potential coupling:

Copy link
Member

@veronikasif veronikasif left a comment

Choose a reason for hiding this comment

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

lgtm 👍

@helgifr helgifr added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Jan 16, 2025
@helgifr helgifr added deprecated:automerge (Disabled) Merge this PR as soon as all checks pass and removed deprecated:automerge (Disabled) Merge this PR as soon as all checks pass labels Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants