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

fix(application-system): AOSH work accident minor fixes #17437

Merged
merged 4 commits into from
Jan 8, 2025

Conversation

Ballioli
Copy link
Member

@Ballioli Ballioli commented Jan 8, 2025

...

Attach a link to issue if relevant

What

  • Adding country selector to phone number.
  • Fixing occupation
  • Adding tabTitles

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

  • New Features

    • Added a country selector to phone number input field
    • Introduced tab titles for prerequisites and conclusion sections
  • Bug Fixes

    • Reset occupation value when changing major group to prevent data inconsistency
  • Refactor

    • Updated localization messages for prerequisites tab
    • Removed prerequisites section from existing message definitions

@Ballioli Ballioli requested a review from a team as a code owner January 8, 2025 10:15
Copy link
Contributor

coderabbitai bot commented Jan 8, 2025

Walkthrough

This pull request introduces several modifications to the Work Accident Notification template, focusing on form configuration and state management. The changes include adding tab titles to different sections, enabling a country selector for phone number input, and adjusting the occupation selection logic. The modifications primarily enhance the user interface and form interaction by providing more precise configuration and clearing specific form values when certain selections are made.

Changes

File Change Summary
libs/application/templates/aosh/work-accident-notification/src/fields/Occupation/index.tsx Modified onChangeMajorGroup to clear victimsOccupation when major group changes
libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/ConclusionSection/index.ts Added tabTitle property to conclusionSection
libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/InformationSection/companySection.ts Enabled country selector for phone number input
libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/prerequisitesSection.ts Added tabTitle property and imported shared module
libs/application/templates/aosh/work-accident-notification/src/lib/messages/sections.ts Removed prerequisites section from sections object
libs/application/templates/aosh/work-accident-notification/src/lib/messages/shared.ts Added prereqTabTitle message to shared.application

Sequence Diagram

sequenceDiagram
    participant User
    participant OccupationComponent
    participant Form

    User->>OccupationComponent: Select Major Group
    OccupationComponent->>Form: Clear Victims Occupation
    OccupationComponent->>Form: Update Major Group Selection
Loading

Possibly related PRs

Suggested labels

automerge, deploy-feature

Suggested reviewers

  • kksteini
  • HjorturJ

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

codecov bot commented Jan 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.67%. Comparing base (7e3a370) to head (597757b).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17437   +/-   ##
=======================================
  Coverage   35.66%   35.67%           
=======================================
  Files        6941     6941           
  Lines      149131   149131           
  Branches    42640    42640           
=======================================
+ Hits        53193    53196    +3     
+ Misses      95938    95935    -3     
Flag Coverage Δ
air-discount-scheme-backend 48.24% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.35% <ø> (ø)
api-catalogue-services 75.81% <ø> (ø)
api-domains-air-discount-scheme 37.99% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.47% <ø> (ø)
api-domains-criminal-record 48.03% <ø> (ø)
api-domains-driving-license 44.86% <ø> (ø)
api-domains-education 31.27% <ø> (ø)
api-domains-health-insurance 35.47% <ø> (ø)
api-domains-mortgage-certificate 35.24% <ø> (ø)
api-domains-payment-schedule 42.12% <ø> (ø)
application-api-files 61.97% <ø> (ø)
application-core 75.60% <ø> (ø)
application-system-api 38.75% <ø> (+<0.01%) ⬆️
application-template-api-modules 27.72% <ø> (-0.01%) ⬇️
application-templates-accident-notification 27.60% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.82% <ø> (ø)
application-templates-driving-license 18.17% <ø> (ø)
application-templates-estate 13.67% <ø> (ø)
application-templates-example-payment 24.69% <ø> (ø)
application-templates-financial-aid 14.47% <ø> (ø)
application-templates-general-petition 23.13% <ø> (ø)
application-templates-inheritance-report 6.59% <ø> (ø)
application-templates-marriage-conditions 15.21% <ø> (ø)
application-templates-mortgage-certificate 43.73% <ø> (ø)
application-templates-parental-leave 29.92% <ø> (ø)
application-types 6.48% <ø> (ø)
application-ui-components 1.22% <ø> (ø)
application-ui-shell 22.25% <ø> (ø)
auth-admin-web 2.43% <ø> (ø)
auth-nest-tools 31.69% <ø> (ø)
auth-shared 75.00% <ø> (ø)
clients-charge-fjs-v2 28.88% <ø> (ø)
clients-driving-license 40.91% <ø> (ø)
clients-driving-license-book 43.92% <ø> (ø)
clients-financial-statements-inao 49.70% <ø> (ø)
clients-license-client 1.26% <ø> (ø)
clients-middlewares 73.28% <ø> (+0.08%) ⬆️
clients-regulations 43.00% <ø> (ø)
clients-rsk-company-registry 31.18% <ø> (ø)
clients-rsk-personal-tax-return 38.32% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.47% <ø> (ø)
clients-zendesk 50.58% <ø> (ø)
cms 0.39% <ø> (ø)
cms-translations 38.80% <ø> (ø)
content-search-index-manager 95.65% <ø> (ø)
content-search-toolkit 8.16% <ø> (ø)
contentful-apps 4.69% <ø> (ø)
dokobit-signing 62.18% <ø> (ø)
email-service 60.15% <ø> (ø)
feature-flags 90.83% <ø> (ø)
file-storage 45.97% <ø> (ø)
financial-aid-backend 51.42% <ø> (ø)
financial-aid-shared 17.88% <ø> (ø)
icelandic-names-registry-backend 54.33% <ø> (ø)
infra-nest-server 48.06% <ø> (ø)
infra-tracing 69.94% <ø> (ø)
island-ui-core 30.34% <ø> (ø)
judicial-system-api 20.23% <ø> (ø)
judicial-system-audit-trail 69.02% <ø> (ø)
judicial-system-backend 55.88% <ø> (ø)
judicial-system-formatters 78.52% <ø> (ø)
judicial-system-message-handler 48.41% <ø> (ø)
judicial-system-scheduler 71.20% <ø> (ø)
judicial-system-types 41.54% <ø> (ø)
judicial-system-web 27.76% <ø> (ø)
license-api 43.00% <ø> (+0.05%) ⬆️
localization 10.15% <ø> (ø)
logging 58.02% <ø> (ø)
message-queue 67.76% <ø> (+0.70%) ⬆️
nest-audit 65.78% <ø> (ø)
nest-aws 51.93% <ø> (ø)
nest-config 76.45% <ø> (ø)
nest-core 53.16% <ø> (ø)
nest-feature-flags 51.06% <ø> (ø)
nest-problem 45.64% <ø> (ø)
nest-sequelize 94.44% <ø> (ø)
nest-swagger 51.13% <ø> (ø)
nova-sms 61.52% <ø> (ø)
portals-admin-regulations-admin 1.80% <ø> (ø)
portals-core 19.58% <ø> (ø)
regulations 16.78% <ø> (ø)
residence-history 85.00% <ø> (ø)
services-auth-admin-api 52.54% <ø> (ø)
services-auth-delegation-api 58.56% <ø> (+0.09%) ⬆️
services-auth-ids-api 52.58% <ø> (ø)
services-auth-public-api 49.43% <ø> (ø)
services-sessions 65.38% <ø> (ø)
services-university-gateway 49.58% <ø> (+0.11%) ⬆️
services-user-notification 46.54% <ø> (+0.02%) ⬆️
services-user-profile 56.90% <ø> (ø)
shared-components 29.49% <ø> (ø)
shared-form-fields 33.37% <ø> (ø)
shared-mocking 58.64% <ø> (ø)
shared-pii 92.85% <ø> (ø)
shared-problem 87.50% <ø> (ø)
shared-utils 27.69% <ø> (ø)
skilavottord-ws 24.26% <ø> (ø)
web 2.39% <ø> (ø)

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

see 1 file 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 7e3a370...597757b. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jan 8, 2025

Datadog Report

All test runs 7f7e2a0 🔗

4 Total Test Services: 0 Failed, 4 Passed
➡️ Test Sessions change in coverage: 7 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 2.58s 1 no change Link
application-system-api 0 0 0 46 0 2m 19.19s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 4.06s 1 no change Link
application-ui-shell 0 0 0 74 0 31.7s 1 no change Link

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/aosh/work-accident-notification/src/fields/Occupation/index.tsx (3)

Line range hint 1-40: Consider extracting reusable types and interfaces.

The component defines several TypeScript interfaces and types that could be useful across other form components. Consider moving these to a shared types file:

  • Options
  • OccupationProps
  • EventOption

This would improve reusability across different templates and make the code more maintainable.


Line range hint 41-143: Consider breaking down the component for better maintainability.

The component handles multiple responsibilities:

  • Managing form state
  • Handling group selections
  • Processing external data

Consider splitting this into smaller, more focused components or hooks for better maintainability and reusability.

For example, the group selection logic could be extracted into a custom hook:

function useOccupationGroups(allGroups: VictimsOccupationDto[]) {
  // Group filtering logic
  return {
    majorGroups,
    subMajorGroups,
    minorGroups,
    unitGroups
  }
}

Line range hint 32-39: Improve type safety with proper generics usage.

The application prop type could be more specific than relying on type assertion:

const answers = application.answers as WorkAccidentNotification

Consider using generics to properly type the application object:

interface Props<T> extends FieldBaseProps {
  application: {
    answers: T;
    // ... other properties
  };
}

export const Occupation: FC<Props<WorkAccidentNotification>> = (props) => {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e0cf15e and 609698b.

📒 Files selected for processing (6)
  • libs/application/templates/aosh/work-accident-notification/src/fields/Occupation/index.tsx (1 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/ConclusionSection/index.ts (1 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/InformationSection/companySection.ts (1 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/prerequisitesSection.ts (2 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/lib/messages/sections.ts (0 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/lib/messages/shared.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • libs/application/templates/aosh/work-accident-notification/src/lib/messages/sections.ts
🧰 Additional context used
📓 Path-based instructions (5)
libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/prerequisitesSection.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/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/InformationSection/companySection.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/aosh/work-accident-notification/src/lib/messages/shared.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/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/ConclusionSection/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/aosh/work-accident-notification/src/fields/Occupation/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."
🔇 Additional comments (5)
libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/ConclusionSection/index.ts (1)

15-15: LGTM! Good reuse of existing message.

The addition of tabTitle property maintains consistency with the application's navigation structure while efficiently reusing the existing message from conclusion.general.title.

libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/prerequisitesSection.ts (1)

8-8: LGTM! Consistent implementation of tab title.

The changes maintain consistency with other sections by:

  1. Adding the required import from shared messages
  2. Implementing the tabTitle property using the localized message

Also applies to: 19-19

libs/application/templates/aosh/work-accident-notification/src/lib/messages/shared.ts (1)

33-37: LGTM! Well-structured i18n message.

The new message definition:

  • Follows consistent ID pattern
  • Maintains naming conventions
  • Provides clear description for translators
libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/InformationSection/companySection.ts (1)

163-163: LGTM! Enhanced phone input with country selection.

The addition of country selector improves the UX for international phone numbers.

Please verify that:

  1. The phone field correctly handles and validates international formats
  2. The stored phone number format is compatible with existing backend expectations

Run this check to find phone number usage in the codebase:

✅ Verification successful

Phone number handling implementation verified

The country selector addition is compatible with the system's phone number handling:

  • Uses standard phone input component that properly formats international numbers
  • Backend services support international format processing
  • Follows consistent phone number handling patterns used across the application
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for phone number validation and processing
rg -l "phonenumber|phone.*number|mobilePhoneNumber" --type ts

Length of output: 25309


Script:

#!/bin/bash
# Check phone number formatting implementations
echo "=== Phone formatting utilities ==="
rg -A 5 "formatPhoneNumber|formatPhonenumber" --type ts

echo -e "\n=== Phone input component implementation ==="
cat libs/island-ui/core/src/lib/PhoneInput/PhoneInput.tsx

echo -e "\n=== Phone validation patterns ==="
rg "phone.*validation|validatePhone|phonePattern" --type ts

Length of output: 69451

libs/application/templates/aosh/work-accident-notification/src/fields/Occupation/index.tsx (1)

144-145: Verify the impact of resetting occupation value.

The added line resets the victim's occupation when a major group changes. While this ensures data consistency, we should verify that this doesn't cause any unintended side effects in the form's validation or submission process.

Run this script to check for other dependencies on this field:

✅ Verification successful

Resetting victim's occupation is safe and follows expected behavior.

The reset operation when changing major groups is safe because:

  • The field is properly validated before form submission
  • No other fields depend on this value
  • Only the final selected value is used in the overview display
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other components or validation logic that might depend on victimsOccupation
rg -l "victimsOccupation" | xargs rg "victimsOccupation.*validation|validate.*victimsOccupation"

# Search for form submission handlers that process this field
ast-grep --pattern 'const $submit = async ($data) => { $$$ }'

Length of output: 160


Script:

#!/bin/bash
# Find all files containing victimsOccupation with different case variations
rg -i "victimsoccupation|victims.?occupation" -l

# Search for validation schema definitions
ast-grep --pattern 'const $schema = { $$$ }'

# Look for form configuration
fd "schema.ts|config.ts" --exec cat {}

Length of output: 66089


Script:

#!/bin/bash
# Check validation schema and form configuration
cat libs/application/templates/aosh/work-accident-notification/src/lib/dataSchema.ts
cat libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/EmployeeSection/employee.ts

# Check overview generation
cat libs/application/templates/aosh/work-accident-notification/src/utils/getEmployeeInformationForOverview.ts

Length of output: 19017

@Ballioli Ballioli added the automerge Merge this PR as soon as all checks pass label Jan 8, 2025
@kodiakhq kodiakhq bot merged commit 7556fe4 into main Jan 8, 2025
265 checks passed
@kodiakhq kodiakhq bot deleted the fix/aosh-accidents-fixes-2 branch January 8, 2025 14:00
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