-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: development
Are you sure you want to change the base?
Frontend/practitioner home jurisdiction change #905
Conversation
WalkthroughA 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
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
Assessment against linked issues
Suggested reviewers
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 actionThe
updatedUser
parameter is not used in this action. Since the user data is already updated in the store viasetStoreUser
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
📒 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 implementationThe 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 inUserAccount.vue
with av-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" />
: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 | ||
}) | ||
) | ||
: ' '" |
There was a problem hiding this comment.
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.
[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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
- Use
state.isLoadingAccount
to be consistent with other account-related operations, or - 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.
[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.
get homeJurisdictionName(): string { | ||
const licensee = this.userStore.model?.licensee; | ||
|
||
return licensee?.homeJurisdiction?.name() || ''; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
Requirements List
Description List
Testing List
yarn test:unit:all
should run without errors or warningsyarn serve
should run without errors or warningsyarn build
should run without errors or warningsCloses #763
Summary by CodeRabbit