From 12d7b69784cafa1971e7e4926bbfea5859e86dda Mon Sep 17 00:00:00 2001 From: CameronEYDS <53542131+cameron-eyds@users.noreply.github.com> Date: Thu, 17 Aug 2023 08:40:01 -0700 Subject: [PATCH] Updated QS Status Message Handling (#1492) --- .../ReviewConfirm/Authorization.vue | 4 +- .../composables/userAccess/useUserAccess.ts | 45 +++++++++++++++---- ppr-ui/src/enums/settingOptions.ts | 4 +- .../user-access-authorization-interface.ts | 2 +- ppr-ui/src/store/state/state-model.ts | 2 +- ppr-ui/src/utils/ppr-api-helper.ts | 2 +- ppr-ui/src/views/Dashboard.vue | 19 ++++---- ppr-ui/tests/unit/QsReviewConfirm.spec.ts | 10 ++--- 8 files changed, 60 insertions(+), 28 deletions(-) diff --git a/ppr-ui/src/components/userAccess/ReviewConfirm/Authorization.vue b/ppr-ui/src/components/userAccess/ReviewConfirm/Authorization.vue index 529430052..cc9a689bb 100644 --- a/ppr-ui/src/components/userAccess/ReviewConfirm/Authorization.vue +++ b/ppr-ui/src/components/userAccess/ReviewConfirm/Authorization.vue @@ -10,7 +10,7 @@ id="authorization-text-field" filled label="Legal name of authorized person (must be a lawyer or notary)" - v-model="authorization.legalName" + v-model="authorization.authorizationName" :rules="authorizationRules" /> - {{ authorization.legalName }} + {{ authorization.authorizationName }} certifies that they have relevant knowledge of the Qualified Supplier and is authorized to submit this application. diff --git a/ppr-ui/src/composables/userAccess/useUserAccess.ts b/ppr-ui/src/composables/userAccess/useUserAccess.ts index 35814929e..2c8a30bfa 100644 --- a/ppr-ui/src/composables/userAccess/useUserAccess.ts +++ b/ppr-ui/src/composables/userAccess/useUserAccess.ts @@ -7,9 +7,10 @@ import { getAccountInfoFromAuth, getFeatureFlag, getKeyByValue, - requestProductAccess + requestProductAccess, + updateUserSettings } from '@/utils' -import { ProductCode, MhrSubTypes, ProductStatus, RouteNames } from '@/enums' +import { MhrSubTypes, ProductCode, ProductStatus, RouteNames, SettingOptions } from '@/enums' import { storeToRefs } from 'pinia' import { useStore } from '@/store/store' import { useAuth, useNavigation } from '@/composables' @@ -19,6 +20,7 @@ export const useUserAccess = () => { const { initializeUserProducts } = useAuth() const { goToDash, goToRoute, containsCurrentRoute } = useNavigation() const { + setUserSettings, setUnsavedChanges, setMhrQsInformation, setMhrSubProduct, @@ -29,6 +31,7 @@ export const useUserAccess = () => { } = useStore() const { isRoleStaffReg, + getUserSettings, getUserLastName, getUserFirstName, getMhrSubProduct, @@ -90,10 +93,12 @@ export const useUserAccess = () => { /** Content for the QS Application Caution and Alert component **/ const qsMsgContent: ComputedRef = computed((): UserAccessMessageIF => { - const productName = MhrSubTypes[getKeyByValue(ProductCode, currentSubProduct.value?.code)] - const helpEmail = currentSubProduct.value?.code === ProductCode.LAWYERS_NOTARIES + const product = currentSubProduct.value + const productName = MhrSubTypes[getKeyByValue(ProductCode, product?.code)] + const helpEmail = product?.code === ProductCode.LAWYERS_NOTARIES ? 'bcolhelp@gov.bc.ca' : 'bcregistries@gov.bc.ca' + const content: UserAccessMessageIF[] = [ { status: ProductStatus.ACTIVE, @@ -119,15 +124,20 @@ export const useUserAccess = () => { } ] - return content.find(content => content.status === currentSubProduct.value?.subscriptionStatus) + // Return if the user has previously close the status message + if (getUserSettings.value?.[SettingOptions.MISCELLANEOUS_PREFERENCES]?.[SettingOptions.QS_STATUS_MSG_HIDE]) { + return + } + + return content.find(content => content.status === product?.subscriptionStatus) }) /** Returns true while the Authorization Component is valid **/ const isAuthorizationValid: ComputedRef = computed(() => { return ( getMhrQsAuthorization.value.isAuthorizationConfirmed && - getMhrQsAuthorization.value.legalName.trim() !== '' && - getMhrQsAuthorization.value.legalName.length <= 150 + getMhrQsAuthorization.value.authorizationName.trim() !== '' && + getMhrQsAuthorization.value.authorizationName.length <= 150 ) }) @@ -173,7 +183,7 @@ export const useUserAccess = () => { setMhrQsIsRequirementsConfirmed(false) setMhrQsAuthorization({ isAuthorizationConfirmed: false, - legalName: getUserFirstName.value + ' ' + getUserLastName.value, + authorizationName: getUserFirstName.value + ' ' + getUserLastName.value, date: convertDate(new Date(), false, false) }) @@ -186,6 +196,16 @@ export const useUserAccess = () => { setUnsavedChanges(true) } + /** Close Qualified Supplier status message - update locally and user settings **/ + const closeQsMessage = async (): Promise => { + const updatedPreference = { [SettingOptions.QS_STATUS_MSG_HIDE]: true } + await updateUserSettings(SettingOptions.MISCELLANEOUS_PREFERENCES, updatedPreference) + await setUserSettings({ + ...getUserSettings.value, + [SettingOptions.MISCELLANEOUS_PREFERENCES]: updatedPreference + }) + } + /** * Submit qualified supplier application * Includes a request to CREATE a Qualified Supplier in MHR @@ -194,7 +214,7 @@ export const useUserAccess = () => { const submitQsApplication = async (): Promise => { const payload: MhrQsPayloadIF = { ...cleanEmpty(getMhrQsInformation.value), - legalName: getMhrQsAuthorization.value.legalName, + authorizationName: getMhrQsAuthorization.value.authorizationName, phoneNumber: fromDisplayPhone(getMhrQsInformation.value.phoneNumber) } @@ -208,6 +228,12 @@ export const useUserAccess = () => { await initializeUserProducts() await nextTick() + // Reset user preferences to show application messages on new submission + await updateUserSettings( + SettingOptions.MISCELLANEOUS_PREFERENCES, { + [SettingOptions.QS_STATUS_MSG_HIDE]: false + }) + setUnsavedChanges(false) await goToDash() } @@ -221,6 +247,7 @@ export const useUserAccess = () => { initUserAccess, goToUserAccess, qsMsgContent, + closeQsMessage, isQsAccessEnabled, hasPendingQsAccess, hasRejectedQsAccess, diff --git a/ppr-ui/src/enums/settingOptions.ts b/ppr-ui/src/enums/settingOptions.ts index fd9b5864d..0cc81479d 100644 --- a/ppr-ui/src/enums/settingOptions.ts +++ b/ppr-ui/src/enums/settingOptions.ts @@ -1,5 +1,7 @@ export enum SettingOptions { PAYMENT_CONFIRMATION_DIALOG = 'paymentConfirmationDialog', SELECT_CONFIRMATION_DIALOG = 'selectConfirmationDialog', - REGISTRATION_TABLE = 'registrationsTable' + REGISTRATION_TABLE = 'registrationsTable', + MISCELLANEOUS_PREFERENCES = 'miscellaneousPreferences', + QS_STATUS_MSG_HIDE = 'qsStatusMsgHide', // miscellaneousPreferences: Boolean - User has hidden the Qs status msg } diff --git a/ppr-ui/src/interfaces/user-access-interfaces/user-access-authorization-interface.ts b/ppr-ui/src/interfaces/user-access-interfaces/user-access-authorization-interface.ts index a1d46ef5e..e54b9941a 100644 --- a/ppr-ui/src/interfaces/user-access-interfaces/user-access-authorization-interface.ts +++ b/ppr-ui/src/interfaces/user-access-interfaces/user-access-authorization-interface.ts @@ -1,5 +1,5 @@ export interface UserAccessAuthorizationIF { isAuthorizationConfirmed: boolean - legalName: string + authorizationName: string date: string } diff --git a/ppr-ui/src/store/state/state-model.ts b/ppr-ui/src/store/state/state-model.ts index e9d906060..8ecd3ec73 100644 --- a/ppr-ui/src/store/state/state-model.ts +++ b/ppr-ui/src/store/state/state-model.ts @@ -383,7 +383,7 @@ export const stateModel: StateModelIF = { isRequirementsConfirmed: false, authorization: { isAuthorizationConfirmed: false, - legalName: '', + authorizationName: '', date: '' }, qsSubmittingParty: null diff --git a/ppr-ui/src/utils/ppr-api-helper.ts b/ppr-ui/src/utils/ppr-api-helper.ts index 8bbbdc0c3..6074fb024 100644 --- a/ppr-ui/src/utils/ppr-api-helper.ts +++ b/ppr-ui/src/utils/ppr-api-helper.ts @@ -417,7 +417,7 @@ export async function getPPRUserSettings (): Promise { // Update user setting export async function updateUserSettings ( setting: SettingOptions, - settingValue: boolean | { columns: BaseHeaderIF[], mhrColumns: BaseHeaderIF[] } + settingValue: boolean | { columns: BaseHeaderIF[], mhrColumns: BaseHeaderIF[] } | object ): Promise { const url = sessionStorage.getItem('PPR_API_URL') const config = { baseURL: url, headers: { Accept: 'application/json' } } diff --git a/ppr-ui/src/views/Dashboard.vue b/ppr-ui/src/views/Dashboard.vue index 1e62506d4..7b3b471ea 100644 --- a/ppr-ui/src/views/Dashboard.vue +++ b/ppr-ui/src/views/Dashboard.vue @@ -20,13 +20,15 @@ {{ qsMsgContent.icon }} - - - - - - - + @@ -159,7 +161,7 @@ export default defineComponent({ const router = useRouter() const { navigateTo } = useNavigation() const { isAuthenticated } = useAuth() - const { qsMsgContent } = useUserAccess() + const { qsMsgContent, closeQsMessage } = useUserAccess() const { // Actions setSearchHistory, @@ -314,6 +316,7 @@ export default defineComponent({ setSearchedType, setSearchedValue, qsMsgContent, + closeQsMessage, getUserServiceFee, setSearchDebtorName, redirectRegistryHome, diff --git a/ppr-ui/tests/unit/QsReviewConfirm.spec.ts b/ppr-ui/tests/unit/QsReviewConfirm.spec.ts index 8f40fd49b..508455c96 100644 --- a/ppr-ui/tests/unit/QsReviewConfirm.spec.ts +++ b/ppr-ui/tests/unit/QsReviewConfirm.spec.ts @@ -22,7 +22,7 @@ describe('QsReviewConfirm', () => { const authorization = { isAuthorizationConfirmed: false, date: convertDate(new Date(), false, false), - legalName: 'Test User' + authorizationName: 'Test User' } beforeAll(async () => { defaultFlagSet['mhr-user-access-enabled'] = true @@ -103,7 +103,7 @@ describe('QsReviewConfirm', () => { expect(heading.exists()).toBe(true) expect(heading.text()).toBe('Authorization') - expect(store.getMhrQsAuthorization.legalName).toBe('Test User') + expect(store.getMhrQsAuthorization.authorizationName).toBe('Test User') // setup const authorizationCheckbox = authorizationSection.find('#authorization-checkbox') @@ -116,12 +116,12 @@ describe('QsReviewConfirm', () => { expect(checkboxText.exists()).toBe(true) // Checks that text is updated and reflected in text next to checkbox - expect(checkboxText.text().includes(store.getMhrQsAuthorization.legalName)).toBe(true) + expect(checkboxText.text().includes(store.getMhrQsAuthorization.authorizationName)).toBe(true) await authorizationTextField.setValue('Hello its me') - expect(store.getMhrQsAuthorization.legalName).toBe('Hello its me') - expect(checkboxText.text().includes(store.getMhrQsAuthorization.legalName)).toBe(true) + expect(store.getMhrQsAuthorization.authorizationName).toBe('Hello its me') + expect(checkboxText.text().includes(store.getMhrQsAuthorization.authorizationName)).toBe(true) await authorizationCheckbox.trigger('click')