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): Update new school page to use updateOnSelect #17612

Merged
merged 11 commits into from
Jan 24, 2025

Conversation

veronikasif
Copy link
Member

@veronikasif veronikasif commented Jan 22, 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

  • Refactor

    • Simplified school-related data structure in the new primary school application.
    • Updated data retrieval paths for school municipality and selected school.
    • Removed unnecessary hidden input variables.
  • Bug Fixes

    • Corrected TypeScript type definitions for data URI resolvers in the driving license domain.
  • Style

    • Standardized type naming from String to string in resolver methods.

These changes enhance the application's data handling and improve type consistency across various components.

@veronikasif veronikasif requested a review from a team as a code owner January 22, 2025 14:44
Copy link
Contributor

coderabbitai bot commented Jan 22, 2025

Walkthrough

This pull request involves modifications to several files in the new primary school application template and the driving license domain. The changes primarily focus on restructuring the data schema for school-related information, simplifying the form's input handling, and updating TypeScript type definitions. The modifications streamline the data retrieval process, remove unnecessary hidden inputs, and make the code more consistent by using lowercase type definitions.

Changes

File Change Summary
libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts - Removed buildHiddenInputWithWatchedValue function
- Updated IDs for buildMultiField and buildAsyncSelectField
- Modified loadOptions function to improve dynamic selection
libs/application/templates/new-primary-school/src/lib/dataSchema.ts - Removed schools property
- Added newSchool property with municipality and school fields
libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts - Updated paths for schoolMunicipality and selectedSchool
- Removed newSchoolHiddenInput
libs/api/domains/driving-license/src/lib/graphql/qualityPhoto.resolver.ts - Changed return type from `Promise<String
libs/api/domains/driving-license/src/lib/graphql/qualitySignature.resolver.ts - Changed return type from `Promise<String

Possibly related PRs

Suggested labels

automerge, deploy-feature

Suggested reviewers

  • helgifr
  • sigruntg

📜 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 48199b8 and 8cf6281.

📒 Files selected for processing (2)
  • libs/application/templates/new-primary-school/src/lib/dataSchema.ts (1 hunks)
  • libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • libs/application/templates/new-primary-school/src/lib/dataSchema.ts
  • libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: prepare

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

🧹 Nitpick comments (2)
libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts (1)

71-75: Consider handling edge cases in municipality selection.

The selectedValue fallback to schoolMunicipality is good, but we should handle the case where both are undefined.

-                    (selectedValue ? selectedValue : schoolMunicipality),
+                    selectedValue ?? schoolMunicipality ?? '',
libs/application/templates/new-primary-school/src/lib/dataSchema.ts (1)

118-121: Consider adding more validation rules.

While the basic schema is correct, consider enhancing it with additional validation rules:

  1. Minimum length validation for both fields
  2. Custom validation for municipality names
 newSchool: z.object({
-    municipality: z.string(),
-    school: z.string(),
+    municipality: z.string().min(1, 'Municipality is required'),
+    school: z.string().min(1, 'School is required'),
 }),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 91ed8b9 and 941f132.

📒 Files selected for processing (3)
  • libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts (4 hunks)
  • libs/application/templates/new-primary-school/src/lib/dataSchema.ts (1 hunks)
  • libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
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/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/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.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."
📓 Learnings (2)
libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts (2)
Learnt from: veronikasif
PR: island-is/island.is#17477
File: libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts:82-115
Timestamp: 2025-01-13T14:20:07.540Z
Learning: In the new-primary-school application template, the user prefers to keep the type casting approach for extracting allergies data from application answers, rather than introducing additional type safety measures.
Learnt from: veronikasif
PR: island-is/island.is#16096
File: libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts:12-18
Timestamp: 2024-11-12T15:15:20.157Z
Learning: Be cautious when suggesting removal of imports; ensure all imports are thoroughly checked to confirm whether they are unused.
libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts (1)
Learnt from: veronikasif
PR: island-is/island.is#16096
File: libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts:81-90
Timestamp: 2024-11-12T15:15:20.157Z
Learning: When checking conditions involving variables like `schoolMunicipality` and `newSchoolHiddenInput`, ensure to verify that `schoolMunicipality` has a value before comparing it to `newSchoolHiddenInput`.
🔇 Additional comments (5)
libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts (3)

26-26: LGTM! Consistent path updates.

The ID and path updates align well with the new schema structure, making the code more maintainable.

Also applies to: 30-30, 50-50


55-56: Good UX improvement!

The addition of updateOnSelect ensures that the school options are refreshed when the municipality changes, providing a better user experience.


86-89: LGTM! Simplified condition.

The condition has been simplified while maintaining the same functionality. This aligns with the KISS principle.

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

12-12: LGTM! Required import.

The ContactsRow import is used in the type annotation for the contacts variable.


148-148: LGTM! Consistent path updates.

The path updates align with the new schema structure and maintain consistency across the codebase.

Also applies to: 151-151

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.

Project coverage is 35.55%. Comparing base (fa5f883) to head (8cf6281).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...olForm/primarySchoolSection/newSchoolSubSection.ts 0.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17612      +/-   ##
==========================================
- Coverage   35.56%   35.55%   -0.01%     
==========================================
  Files        7033     7033              
  Lines      150624   150617       -7     
  Branches    43023    43019       -4     
==========================================
- Hits        53562    53558       -4     
+ Misses      97062    97059       -3     
Flag Coverage Δ
api 3.33% <ø> (ø)
api-domains-driving-license 44.74% <ø> (ø)
application-system-api 38.63% <66.66%> (+<0.01%) ⬆️
application-template-api-modules 27.57% <ø> (+0.01%) ⬆️
application-templates-new-primary-school 20.58% <20.00%> (-0.03%) ⬇️
application-ui-shell 21.99% <ø> (ø)

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

Files with missing lines Coverage Δ
...g-license/src/lib/graphql/qualityPhoto.resolver.ts 65.00% <100.00%> (ø)
...cense/src/lib/graphql/qualitySignature.resolver.ts 65.00% <100.00%> (ø)
...templates/new-primary-school/src/lib/dataSchema.ts 11.39% <ø> (ø)
...ew-primary-school/src/lib/newPrimarySchoolUtils.ts 64.28% <100.00%> (-0.29%) ⬇️
...olForm/primarySchoolSection/newSchoolSubSection.ts 0.00% <0.00%> (ø)

... and 4 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 fa5f883...8cf6281. Read the comment docs.

…i-domains-air-discount-scheme,api-domains-application,api-domains-auth,api-domains-auth-admin,api-domains-document-provider,api-domains-endorsement-system update dirty files
@andes-it andes-it requested a review from a team as a code owner January 22, 2025 15:26
@datadog-island-is
Copy link

datadog-island-is bot commented Jan 22, 2025

Datadog Report

All test runs 0fe9bff 🔗

10 Total Test Services: 0 Failed, 10 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.07%), 1 increased (+0.8%), 198 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-backend 0 0 0 63 0 17.39s N/A Link
air-discount-scheme-web 0 0 0 2 0 6.55s 1 no change Link
api 0 0 0 4 0 2.3s N/A Link
api-catalogue-services 0 0 0 23 0 8.15s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 16.61s N/A Link
api-domains-assets 0 0 0 3 0 9.98s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 10.51s 1 no change Link
api-domains-communications 0 0 0 5 0 31.23s N/A Link
api-domains-criminal-record 0 0 0 5 0 7.82s 1 no change Link
api-domains-driving-license 0 0 0 23 0 30.45s N/A Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • application-templates-new-primary-school - jest 26.6% (-0.07%) - Details

…mains-documents,api-domains-driving-license,api-domains-driving-license-book,api-domains-education,api-domains-email-signup,api-domains-endorsement-system,api-domains-energy-funds update dirty files
@andes-it andes-it requested a review from a team as a code owner January 22, 2025 16:00
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 (1)
libs/api/domains/driving-license/src/lib/graphql/qualityPhoto.resolver.ts (1)

Line range hint 1-40: Consider removing the wildcard export for better tree-shaking.

The wildcard export export * from '@island.is/nest/audit' may affect tree-shaking capabilities. Consider explicitly exporting only the needed entities.

-export * from '@island.is/nest/audit'
+import { AuditService } from '@island.is/nest/audit'
+export { AuditService }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8e40ece and 7ce4115.

📒 Files selected for processing (2)
  • libs/api/domains/driving-license/src/lib/graphql/qualityPhoto.resolver.ts (1 hunks)
  • libs/api/domains/driving-license/src/lib/graphql/qualitySignature.resolver.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • libs/api/domains/driving-license/src/lib/graphql/qualitySignature.resolver.ts
🧰 Additional context used
📓 Path-based instructions (1)
libs/api/domains/driving-license/src/lib/graphql/qualityPhoto.resolver.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 (1)
libs/api/domains/driving-license/src/lib/graphql/qualityPhoto.resolver.ts (1)

25-25: LGTM! Consider standardizing primitive types across related files.

The change from String to string aligns with TypeScript best practices by using primitive types instead of wrapper objects.

Run this script to check if similar changes are needed in related files:

✅ Verification successful

The change to Promise<string> is consistent with codebase conventions

The verification confirms that all similar return types in the codebase use the primitive string type rather than the String object type. No additional changes are needed in other files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Promise<String> type usage in related resolver files
ast-grep --pattern 'Promise<String>' 

Length of output: 38


Script:

#!/bin/bash
# Search for Promise type annotations using ripgrep
echo "=== Searching for Promise<String> ===="
rg "Promise<String>" -t ts

echo -e "\n=== Searching for Promise<string> ===="
rg "Promise<string>" -t ts

Length of output: 14880

@datadog-island-is
Copy link

datadog-island-is bot commented Jan 23, 2025

Datadog Report

All test runs 665ee5f 🔗

5 Total Test Services: 0 Failed, 5 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.07%), 1 increased (+0.01%), 8 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 3.03s 1 no change Link
api-domains-driving-license 0 0 0 23 0 34.97s 1 no change Link
application-system-api 0 0 0 46 0 2m 45.13s 1 no change Link
application-template-api-modules 0 0 0 118 0 12m 33.57s 1 increased (+0.01%) Link
application-ui-shell 0 0 0 74 0 38.87s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • application-templates-new-primary-school - jest 26.89% (-0.07%) - Details

@veronikasif veronikasif enabled auto-merge January 23, 2025 18:12
@veronikasif veronikasif requested a review from helgifr January 23, 2025 18:13
Copy link
Member

@helgifr helgifr left a comment

Choose a reason for hiding this comment

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

lgtm 👍

@veronikasif veronikasif added this pull request to the merge queue Jan 24, 2025
Merged via the queue into main with commit ff2ddba Jan 24, 2025
38 checks passed
@veronikasif veronikasif deleted the feat/nps-update-new-school branch January 24, 2025 17:17
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.

5 participants