Skip to content

Frontend/practitioner home jurisdiction change #905

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

Open
wants to merge 4 commits into
base: development
Choose a base branch
from

Conversation

rmolinares
Copy link
Collaborator

@rmolinares rmolinares commented Jul 2, 2025

Requirements List

  • None

Description List

  • Create component that allows practitioner user to update their home jurisdiction (state)
  • New network call to update
  • Related unit test
  • Related locale translations

Testing List

  • yarn test:unit:all should run without errors or warnings
  • yarn serve should run without errors or warnings
  • yarn build should run without errors or warnings
  • Code review
  • Testing
    • Log in as practitioner user and proceed to your account screen
    • Confirm that there is a home state change form that matches the Figma designs
    • Confirm that you are able to update the home state as expected based on designs
    • Confirm that updated state is reflected upon mobile close
    • Confirm works on mobile / desktop

Closes #763

Summary by CodeRabbit

  • New Features
    • Added the ability for users to update their home jurisdiction (state of residence) from the User Account page, including a confirmation modal and success/error feedback.
    • Introduced localized text for the new home jurisdiction update feature in both English and Spanish.
  • Bug Fixes
    • Improved error messaging with a new "Please Try again" prompt for failed actions.
  • Tests
    • Added tests to ensure the new home jurisdiction update component renders correctly.
  • Style
    • Introduced new styles for the home jurisdiction update form and modal, including responsive design adjustments.

Copy link
Contributor

coderabbitai bot commented Jul 2, 2025

Walkthrough

A new feature enables practitioners to update their home jurisdiction (state) in the user account section. This includes a new Vue component with UI, modal confirmation, form validation, localization, Vuex state management, API integration, and corresponding tests and styles. All necessary backend interaction and localization keys are included.

Changes

File(s) Change Summary
.../UpdateHomeJurisdiction/UpdateHomeJurisdiction.vue
.../UpdateHomeJurisdiction.ts
New Vue component for updating home jurisdiction, including logic, state, and modal handling.
.../UpdateHomeJurisdiction/UpdateHomeJurisdiction.less New LESS stylesheet for the component.
.../UpdateHomeJurisdiction/UpdateHomeJurisdiction.spec.ts New test spec for the component's existence.
.../UserAccount/UserAccount.vue
.../UserAccount.ts
Integrates the new component into the user account view for licensees.
.../locales/en.json
.../locales/es.json
Adds English and Spanish localization for home jurisdiction change UI and messages.
.../network/data.api.ts
.../network/userApi/data.api.ts
.../network/mocks/mock.data.api.ts
Adds API method to update home jurisdiction, including real and mock implementations.
.../network/userApi/interceptors.ts Adds new endpoint to licensee user token authorization logic.
.../store/user/user.actions.ts Adds Vuex actions for updating home jurisdiction and handling success/failure.
.../store/user/user.mutations.ts Adds Vuex mutations for request, success, and failure states of the update process.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UpdateHomeJurisdictionComponent
    participant Modal
    participant VuexStore
    participant DataApi

    User->>UpdateHomeJurisdictionComponent: Selects new home jurisdiction, submits form
    UpdateHomeJurisdictionComponent->>Modal: Opens confirmation modal
    User->>Modal: Confirms change
    Modal->>UpdateHomeJurisdictionComponent: Emits confirmation
    UpdateHomeJurisdictionComponent->>VuexStore: Dispatch updateHomeJurisdictionRequest
    VuexStore->>DataApi: Calls updateHomeJurisdiction API
    DataApi-->>VuexStore: Returns success or error
    VuexStore-->>UpdateHomeJurisdictionComponent: Updates state (success/error)
    UpdateHomeJurisdictionComponent->>Modal: Shows success or error message
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement UI for practitioner to change home state (jurisdiction) (#763)
Integrate form validation, modal confirmation, and error/success handling (#763)
Connect to backend API for updating home jurisdiction (#763)
Update Vuex store and state after successful jurisdiction change (#763)

Suggested reviewers

  • carlsims
  • jsandoval81
  • jlkravitz
  • isabeleliassen

Poem

A bunny hops with nimble code,
To help you change your state abode.
With forms and modals, green and bright,
Success and errors handled right!
Now pick your home, just click submit—
This rabbit’s work is quite legit!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

🧹 Nitpick comments (3)
webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.spec.ts (1)

12-19: Consider expanding test coverage for this critical feature.

While the basic mounting test aligns with your testing strategy, the home jurisdiction change feature involves form validation, API calls, modal interactions, and error handling. Consider adding tests for key user workflows like form submission, modal confirmation, and error states to ensure this critical functionality works correctly.

webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.vue (1)

28-44: Consider extracting modal state management to computed properties.

The complex conditional logic in the modal props could be simplified by moving the state management to computed properties in the TypeScript component, improving readability and maintainability.

webroot/src/store/user/user.actions.ts (1)

389-391: Remove unused parameter from success action

The updatedUser parameter is not used in this action. Since the user data is already updated in the store via setStoreUser in the request action, this parameter can be removed.

-    updateHomeJurisdictionSuccess: ({ commit }) => {
+    updateHomeJurisdictionSuccess: ({ commit }) => {
         commit(MutationTypes.UPDATE_HOME_JURISDICTION_SUCCESS);
     },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 121f381 and 08af317.

📒 Files selected for processing (14)
  • webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.less (1 hunks)
  • webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.spec.ts (1 hunks)
  • webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.ts (1 hunks)
  • webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.vue (1 hunks)
  • webroot/src/components/UserAccount/UserAccount.ts (2 hunks)
  • webroot/src/components/UserAccount/UserAccount.vue (1 hunks)
  • webroot/src/locales/en.json (2 hunks)
  • webroot/src/locales/es.json (2 hunks)
  • webroot/src/network/data.api.ts (1 hunks)
  • webroot/src/network/mocks/mock.data.api.ts (1 hunks)
  • webroot/src/network/userApi/data.api.ts (1 hunks)
  • webroot/src/network/userApi/interceptors.ts (1 hunks)
  • webroot/src/store/user/user.actions.ts (1 hunks)
  • webroot/src/store/user/user.mutations.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: landonshumway-ia
PR: csg-org/CompactConnect#848
File: backend/compact-connect/lambdas/python/migration/provider_user_pool_migration_551/main.py:35-39
Timestamp: 2025-06-10T03:16:16.896Z
Learning: In the provider user pool migration (provider_user_pool_migration_551), the FilterExpression intentionally only checks for the existence of compactConnectRegisteredEmailAddress. The migration should only remove currentHomeJurisdiction if compactConnectRegisteredEmailAddress is also present, targeting records that went through the old registration process. Records with only currentHomeJurisdiction but no compactConnectRegisteredEmailAddress should be left untouched.
Learnt from: landonshumway-ia
PR: csg-org/CompactConnect#848
File: backend/compact-connect/lambdas/python/provider-data-v1/handlers/registration.py:111-117
Timestamp: 2025-06-17T19:05:36.255Z
Learning: In CompactConnect PR #848, the user landonshumway-ia decided to leave timezone handling code in _should_allow_reregistration function as-is after testing in sandbox environment confirmed it works correctly. The user's reasoning was that reregistration is an edge case, the code has been tested and verified, and AWS is unlikely to change behavior that would break many clients. This represents a pragmatic engineering decision based on testing and risk assessment.
Learnt from: landonshumway-ia
PR: csg-org/CompactConnect#882
File: backend/compact-connect/lambdas/python/migration/compact_configured_states_871/main.py:127-130
Timestamp: 2025-06-26T16:42:00.772Z
Learning: In the compact_configured_states_871 migration, existing jurisdiction configurations that have licenseeRegistrationEnabled: true are migrated with isLive: true for backwards compatibility. This prevents breaking existing live functionality since those states are already operational. The migration preserves the current live state of jurisdictions to maintain service continuity, while new states added after migration can start with isLive: false and be controlled by compact admins.
Learnt from: rmolinares
PR: csg-org/CompactConnect#851
File: webroot/src/pages/RegisterLicensee/RegisterLicensee.ts:0-0
Timestamp: 2025-06-09T19:57:51.519Z
Learning: In the RegisterLicensee component, when handling DOM element availability issues, the developer prefers using Vue Watchers over retry mechanisms with requestAnimationFrame to avoid infinite recursion risks and maintain Vue's reactive patterns.
webroot/src/components/UserAccount/UserAccount.ts (3)
Learnt from: jsandoval81
PR: csg-org/CompactConnect#873
File: webroot/src/components/PrivilegeCard/PrivilegeCard.ts:0-0
Timestamp: 2025-06-19T23:43:25.512Z
Learning: In Vue form components, when programmatically setting form input values, it's more efficient to validate just the specific form element being updated (e.g., `formInput.validate()`) rather than calling `validateAll()` on the entire form.
Learnt from: jsandoval81
PR: csg-org/CompactConnect#822
File: webroot/src/components/Forms/InputEmailList/InputEmailList.vue:26-30
Timestamp: 2025-05-28T16:13:19.506Z
Learning: In the InputEmailList component (webroot/src/components/Forms/InputEmailList/InputEmailList.vue), the formInput.labelSubtext property rendered with v-html contains only developer-controlled content, not user-controlled content, so XSS concerns do not apply.
Learnt from: rmolinares
PR: csg-org/CompactConnect#843
File: webroot/src/components/Forms/InputDate/InputDate.ts:0-0
Timestamp: 2025-06-04T22:04:14.373Z
Learning: In the InputDate component (webroot/src/components/Forms/InputDate/InputDate.ts), immediate validation on every keystroke is intentional design behavior. The team prefers to alert users to encourage expected date format completion rather than deferring validation until the date is complete. This provides immediate feedback to guide users toward proper MM/dd/yyyy format completion.
webroot/src/components/UserAccount/UserAccount.vue (5)
Learnt from: landonshumway-ia
PR: csg-org/CompactConnect#848
File: backend/compact-connect/lambdas/python/migration/provider_user_pool_migration_551/main.py:35-39
Timestamp: 2025-06-10T03:16:16.896Z
Learning: In the provider user pool migration (provider_user_pool_migration_551), the FilterExpression intentionally only checks for the existence of compactConnectRegisteredEmailAddress. The migration should only remove currentHomeJurisdiction if compactConnectRegisteredEmailAddress is also present, targeting records that went through the old registration process. Records with only currentHomeJurisdiction but no compactConnectRegisteredEmailAddress should be left untouched.
Learnt from: jsandoval81
PR: csg-org/CompactConnect#822
File: webroot/src/components/Forms/InputEmailList/InputEmailList.vue:26-30
Timestamp: 2025-05-28T16:13:19.506Z
Learning: In the InputEmailList component (webroot/src/components/Forms/InputEmailList/InputEmailList.vue), the formInput.labelSubtext property rendered with v-html contains only developer-controlled content, not user-controlled content, so XSS concerns do not apply.
Learnt from: rmolinares
PR: csg-org/CompactConnect#851
File: webroot/src/pages/RegisterLicensee/RegisterLicensee.ts:0-0
Timestamp: 2025-06-09T19:57:51.519Z
Learning: In the RegisterLicensee component, when handling DOM element availability issues, the developer prefers using Vue Watchers over retry mechanisms with requestAnimationFrame to avoid infinite recursion risks and maintain Vue's reactive patterns.
Learnt from: jsandoval81
PR: csg-org/CompactConnect#873
File: webroot/src/components/LicenseCard/LicenseCard.ts:414-443
Timestamp: 2025-06-24T00:02:39.944Z
Learning: In LicenseCard component's clickUnencumberItem method (webroot/src/components/LicenseCard/LicenseCard.ts), complex event handling for checkbox interactions is intentionally designed to ensure consistent behavior across checkbox input, wrapper label, and outer selection parent elements for custom UI requirements. This complexity should be preserved rather than simplified.
Learnt from: jsandoval81
PR: csg-org/CompactConnect#873
File: webroot/src/components/LicenseCard/LicenseCard.ts:509-528
Timestamp: 2025-06-24T00:07:10.463Z
Learning: In the CompactConnect frontend codebase, the project prefers to avoid early returns in frontend code when possible, as mentioned by jsandoval81 in webroot/src/components/LicenseCard/LicenseCard.ts.
webroot/src/network/userApi/data.api.ts (1)
Learnt from: jusdino
PR: csg-org/CompactConnect#864
File: backend/compact-connect/tests/smoke/encumbrance_smoke_tests.py:256-262
Timestamp: 2025-06-18T21:57:02.978Z
Learning: The `licenseJurisdiction` field is a required field in the provider data API response from the `/v1/providers/users/me` endpoint, so it can be accessed directly without defensive programming checks.
webroot/src/network/userApi/interceptors.ts (1)
Learnt from: jusdino
PR: csg-org/CompactConnect#864
File: backend/compact-connect/tests/smoke/encumbrance_smoke_tests.py:256-262
Timestamp: 2025-06-18T21:57:02.978Z
Learning: The `licenseJurisdiction` field is a required field in the provider data API response from the `/v1/providers/users/me` endpoint, so it can be accessed directly without defensive programming checks.
webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.spec.ts (2)
Learnt from: jsandoval81
PR: csg-org/CompactConnect#822
File: webroot/src/components/Forms/InputEmailList/InputEmailList.spec.ts:12-19
Timestamp: 2025-05-28T16:09:12.906Z
Learning: The CompactConnect application uses mount testing as the general component testing strategy. They focus their testing efforts on the data layer (models and store) rather than extensive component testing, and mount tests meet their coverage needs.
Learnt from: jsandoval81
PR: csg-org/CompactConnect#822
File: webroot/src/components/StateSettingsConfig/StateSettingsConfig.spec.ts:12-19
Timestamp: 2025-05-28T16:09:24.547Z
Learning: The CompactConnect app uses mount testing as their general component testing strategy, focusing more on testing the data layer (models and store) rather than comprehensive component testing. This meets their test coverage needs and is their preferred approach.
webroot/src/network/data.api.ts (1)
Learnt from: jusdino
PR: csg-org/CompactConnect#864
File: backend/compact-connect/tests/smoke/encumbrance_smoke_tests.py:256-262
Timestamp: 2025-06-18T21:57:02.978Z
Learning: The `licenseJurisdiction` field is a required field in the provider data API response from the `/v1/providers/users/me` endpoint, so it can be accessed directly without defensive programming checks.
webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.less (1)
Learnt from: landonshumway-ia
PR: csg-org/CompactConnect#882
File: backend/compact-connect/lambdas/python/migration/compact_configured_states_871/main.py:127-130
Timestamp: 2025-06-26T16:42:00.772Z
Learning: In the compact_configured_states_871 migration, existing jurisdiction configurations that have licenseeRegistrationEnabled: true are migrated with isLive: true for backwards compatibility. This prevents breaking existing live functionality since those states are already operational. The migration preserves the current live state of jurisdictions to maintain service continuity, while new states added after migration can start with isLive: false and be controlled by compact admins.
webroot/src/locales/en.json (1)
Learnt from: landonshumway-ia
PR: csg-org/CompactConnect#882
File: backend/compact-connect/lambdas/python/migration/compact_configured_states_871/main.py:127-130
Timestamp: 2025-06-26T16:42:00.772Z
Learning: In the compact_configured_states_871 migration, existing jurisdiction configurations that have licenseeRegistrationEnabled: true are migrated with isLive: true for backwards compatibility. This prevents breaking existing live functionality since those states are already operational. The migration preserves the current live state of jurisdictions to maintain service continuity, while new states added after migration can start with isLive: false and be controlled by compact admins.
webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.vue (3)
Learnt from: jsandoval81
PR: csg-org/CompactConnect#822
File: webroot/src/components/Forms/InputEmailList/InputEmailList.vue:26-30
Timestamp: 2025-05-28T16:13:19.506Z
Learning: In the InputEmailList component (webroot/src/components/Forms/InputEmailList/InputEmailList.vue), the formInput.labelSubtext property rendered with v-html contains only developer-controlled content, not user-controlled content, so XSS concerns do not apply.
Learnt from: landonshumway-ia
PR: csg-org/CompactConnect#882
File: backend/compact-connect/lambdas/python/migration/compact_configured_states_871/main.py:127-130
Timestamp: 2025-06-26T16:42:00.772Z
Learning: In the compact_configured_states_871 migration, existing jurisdiction configurations that have licenseeRegistrationEnabled: true are migrated with isLive: true for backwards compatibility. This prevents breaking existing live functionality since those states are already operational. The migration preserves the current live state of jurisdictions to maintain service continuity, while new states added after migration can start with isLive: false and be controlled by compact admins.
Learnt from: jsandoval81
PR: csg-org/CompactConnect#873
File: webroot/src/components/PrivilegeCard/PrivilegeCard.ts:0-0
Timestamp: 2025-06-19T23:43:25.512Z
Learning: In Vue form components, when programmatically setting form input values, it's more efficient to validate just the specific form element being updated (e.g., `formInput.validate()`) rather than calling `validateAll()` on the entire form.
webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.ts (4)
Learnt from: landonshumway-ia
PR: csg-org/CompactConnect#882
File: backend/compact-connect/lambdas/python/migration/compact_configured_states_871/main.py:127-130
Timestamp: 2025-06-26T16:42:00.772Z
Learning: In the compact_configured_states_871 migration, existing jurisdiction configurations that have licenseeRegistrationEnabled: true are migrated with isLive: true for backwards compatibility. This prevents breaking existing live functionality since those states are already operational. The migration preserves the current live state of jurisdictions to maintain service continuity, while new states added after migration can start with isLive: false and be controlled by compact admins.
Learnt from: rmolinares
PR: csg-org/CompactConnect#851
File: webroot/src/pages/RegisterLicensee/RegisterLicensee.ts:0-0
Timestamp: 2025-06-09T19:57:51.519Z
Learning: In the RegisterLicensee component, when handling DOM element availability issues, the developer prefers using Vue Watchers over retry mechanisms with requestAnimationFrame to avoid infinite recursion risks and maintain Vue's reactive patterns.
Learnt from: jsandoval81
PR: csg-org/CompactConnect#873
File: webroot/src/components/LicenseCard/LicenseCard.ts:414-443
Timestamp: 2025-06-24T00:02:39.944Z
Learning: In LicenseCard component's clickUnencumberItem method (webroot/src/components/LicenseCard/LicenseCard.ts), complex event handling for checkbox interactions is intentionally designed to ensure consistent behavior across checkbox input, wrapper label, and outer selection parent elements for custom UI requirements. This complexity should be preserved rather than simplified.
Learnt from: jsandoval81
PR: csg-org/CompactConnect#873
File: webroot/src/components/PrivilegeCard/PrivilegeCard.ts:0-0
Timestamp: 2025-06-19T23:43:25.512Z
Learning: In Vue form components, when programmatically setting form input values, it's more efficient to validate just the specific form element being updated (e.g., `formInput.validate()`) rather than calling `validateAll()` on the entire form.
🧬 Code Graph Analysis (4)
webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.spec.ts (1)
webroot/tests/helpers/setup.ts (1)
  • mountShallow (221-221)
webroot/src/network/data.api.ts (1)
webroot/src/network/userApi/data.api.ts (1)
  • userDataApi (369-369)
webroot/src/store/user/user.mutations.ts (1)
webroot/src/store/user/user.state.ts (1)
  • state (33-45)
webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.ts (5)
webroot/src/models/User/User.model.ts (1)
  • User (28-80)
webroot/src/models/LicenseeUser/LicenseeUser.model.ts (1)
  • LicenseeUser (25-42)
webroot/src/models/StaffUser/StaffUser.model.ts (1)
  • StaffUser (42-389)
webroot/src/app.config.ts (1)
  • stateList (155-212)
webroot/src/models/FormInput/FormInput.model.ts (1)
  • FormInput (54-164)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: CheckWebroot
🔇 Additional comments (13)
webroot/src/components/UserAccount/UserAccount.ts (1)

28-28: Clean component integration following established patterns.

The import and registration of the UpdateHomeJurisdiction component follows the existing codebase patterns and integrates cleanly without modifying any existing functionality.

Also applies to: 38-38

webroot/src/components/UserAccount/UserAccount.vue (1)

25-25: Logical placement and appropriate conditional rendering.

The component is correctly positioned in the account flow and properly restricted to licensee users only, which aligns with the feature requirements.

webroot/src/network/mocks/mock.data.api.ts (1)

411-416: Mock implementation follows established patterns.

The method correctly uses the wait() helper for simulation delay and returns an appropriate success response, consistent with other mock methods in this file.

webroot/src/network/userApi/data.api.ts (1)

357-366: API method follows established patterns and conventions.

The implementation correctly uses PUT for the update operation, follows the RESTful endpoint pattern, includes proper JSDoc documentation, and maintains consistency with other API methods in the class.

webroot/src/network/userApi/interceptors.ts (1)

24-25: Proper authentication configuration for licensee endpoint.

Correctly adds the new endpoint to the licenseeUserEndPoints array, ensuring it receives proper licensee user token authentication. This is essential for the feature to work securely.

webroot/src/network/data.api.ts (1)

424-431: LGTM - Implementation follows existing patterns.

The method correctly follows the established patterns in this API layer with proper JSDoc documentation and delegation to the underlying userDataApi. The async/await syntax and parameter typing are consistent with other methods in the file.

webroot/src/locales/en.json (2)

42-42: LGTM - New common message key added.

The addition of "tryAgain" provides a useful common error message string.


893-905: Excellent comprehensive localization for the feature.

The localization strings are well-organized and clearly communicate the serious implications of changing home jurisdiction. The text properly warns users about privilege deactivation and state notifications, which is crucial for informed decision-making.

webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.vue (1)

8-84: Good accessibility and semantic structure.

The component properly uses semantic HTML with ARIA labels, form prevention of default submission, and appropriate Vue directives. The overall structure follows Vue best practices.

webroot/src/locales/es.json (2)

45-45: LGTM - Spanish translation for common error message.

The Spanish translation "Por favor, inténtelo de nuevo" is appropriately added.


892-904: Comprehensive Spanish localization maintains consistency.

The Spanish translations maintain the same structure and thoroughness as the English version, properly conveying the serious implications of jurisdiction changes. The translations appear contextually appropriate for the feature.

webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.less (1)

1-153: Well-structured LESS implementation

The styles are well-organized with proper use of LESS features, responsive design, and consistent naming conventions. Good separation of modal states and responsive adjustments.

webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.ts (1)

45-80: Confirmed: UpdateHomeJurisdiction is only rendered for licensee users
The component is imported and used in UserAccount.vue with a v-if="isLicensee" guard, ensuring it’s only instantiated for licensee users. No additional type‐safety checks are needed here.

• Location of guard:

  • webroot/src/components/UserAccount/UserAccount.vue:
    <UpdateHomeJurisdiction v-if="isLicensee" />

Comment on lines +32 to +41
:title="!isSuccess
? (isError
? $t('common.somethingWentWrong')
: $t('homeJurisdictionChange.modalTitle',
{ newState: $tm('common.states')
.find((s) => s.abbrev.toLowerCase() === formData.newHomeJurisdiction.value)?.full
|| formData.newHomeJurisdiction.value
})
)
: ' '"
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify complex modal title logic and add safety for state lookup.

The nested ternary operators make this code difficult to read and maintain. The state lookup could fail if the abbreviation isn't found, potentially showing undefined in the modal title.

Consider refactoring to computed properties in the TypeScript file:

// In UpdateHomeJurisdiction.ts
get modalTitle(): string {
  if (this.isError) {
    return this.$t('common.somethingWentWrong');
  }
  if (this.isSuccess) {
    return ' ';
  }
  
  const selectedState = this.$tm('common.states')
    .find((s) => s.abbrev.toLowerCase() === this.formData.newHomeJurisdiction.value);
  const stateName = selectedState?.full || this.formData.newHomeJurisdiction.value || 'Unknown State';
  
  return this.$t('homeJurisdictionChange.modalTitle', { newState: stateName });
}

Then use in template:

:title="modalTitle"
🤖 Prompt for AI Agents
In webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.vue
around lines 32 to 41, the modal title uses nested ternary operators that are
hard to read and may show undefined if the state abbreviation lookup fails.
Refactor by moving the modal title logic into a computed property in the
TypeScript file that returns the appropriate title string based on isError and
isSuccess flags, safely looks up the state name with a fallback to 'Unknown
State', and then update the template to bind the title attribute directly to
this computed property.

Comment on lines +216 to 227
[MutationTypes.UPDATE_HOME_JURISDICTION_REQUEST]: (state: any) => {
state.isLoading = true;
state.error = null;
},
[MutationTypes.UPDATE_HOME_JURISDICTION_FAILURE]: (state: any, error: Error) => {
state.isLoading = false;
state.error = error;
},
[MutationTypes.UPDATE_HOME_JURISDICTION_SUCCESS]: (state: any) => {
state.isLoading = false;
state.error = null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use consistent loading state property

The mutations are using state.isLoading which doesn't exist in the user state definition. Based on the pattern in this file and the state structure, you should either:

  1. Use state.isLoadingAccount to be consistent with other account-related operations, or
  2. Add a new specific property like state.isLoadingHomeJurisdiction to the state definition

Apply this diff to use the existing loading property:

     [MutationTypes.UPDATE_HOME_JURISDICTION_REQUEST]: (state: any) => {
-        state.isLoading = true;
+        state.isLoadingAccount = true;
         state.error = null;
     },
     [MutationTypes.UPDATE_HOME_JURISDICTION_FAILURE]: (state: any, error: Error) => {
-        state.isLoading = false;
+        state.isLoadingAccount = false;
         state.error = error;
     },
     [MutationTypes.UPDATE_HOME_JURISDICTION_SUCCESS]: (state: any) => {
-        state.isLoading = false;
+        state.isLoadingAccount = false;
         state.error = null;
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[MutationTypes.UPDATE_HOME_JURISDICTION_REQUEST]: (state: any) => {
state.isLoading = true;
state.error = null;
},
[MutationTypes.UPDATE_HOME_JURISDICTION_FAILURE]: (state: any, error: Error) => {
state.isLoading = false;
state.error = error;
},
[MutationTypes.UPDATE_HOME_JURISDICTION_SUCCESS]: (state: any) => {
state.isLoading = false;
state.error = null;
}
[MutationTypes.UPDATE_HOME_JURISDICTION_REQUEST]: (state: any) => {
state.isLoadingAccount = true;
state.error = null;
},
[MutationTypes.UPDATE_HOME_JURISDICTION_FAILURE]: (state: any, error: Error) => {
state.isLoadingAccount = false;
state.error = error;
},
[MutationTypes.UPDATE_HOME_JURISDICTION_SUCCESS]: (state: any) => {
state.isLoadingAccount = false;
state.error = null;
}
🤖 Prompt for AI Agents
In webroot/src/store/user/user.mutations.ts lines 216 to 227, the mutations use
a loading state property `state.isLoading` that does not exist in the user
state. To fix this, replace all instances of `state.isLoading` with the existing
property `state.isLoadingAccount` to maintain consistency with other
account-related loading states in the file.

Comment on lines +60 to +64
get homeJurisdictionName(): string {
const licensee = this.userStore.model?.licensee;

return licensee?.homeJurisdiction?.name() || '';
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add type guard for licensee property access

The licensee property only exists on LicenseeUser, not on User or StaffUser. This could cause runtime errors if a non-licensee user accesses this component.

Add a type check or cast to ensure type safety:

     get homeJurisdictionName(): string {
-        const licensee = this.userStore.model?.licensee;
+        const user = this.userStore.model;
+        const licensee = user && 'licensee' in user ? user.licensee : undefined;

         return licensee?.homeJurisdiction?.name() || '';
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
get homeJurisdictionName(): string {
const licensee = this.userStore.model?.licensee;
return licensee?.homeJurisdiction?.name() || '';
}
get homeJurisdictionName(): string {
const user = this.userStore.model;
const licensee = user && 'licensee' in user ? user.licensee : undefined;
return licensee?.homeJurisdiction?.name() || '';
}
🤖 Prompt for AI Agents
In webroot/src/components/UpdateHomeJurisdiction/UpdateHomeJurisdiction.ts
around lines 60 to 64, the code accesses the licensee property without
confirming the user type, which can cause runtime errors if the user is not a
LicenseeUser. Add a type guard to check if the userStore.model is of type
LicenseeUser before accessing licensee, or cast the user to LicenseeUser safely.
This ensures that licensee is only accessed when it exists, preventing potential
runtime errors.

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.

practitioner can change home state FE
1 participant