Skip to content

Commit

Permalink
Enhanced Dealer Updates (#2058)
Browse files Browse the repository at this point in the history
* Enhanced Dealer Updates

* clean up

* Added Script Commands
  • Loading branch information
cameron-eyds authored Nov 6, 2024
1 parent b0da64a commit fd2178a
Show file tree
Hide file tree
Showing 17 changed files with 236 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ppr-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion ppr-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"name": "ppr-ui",
"version": "3.2.71",
"version": "3.3.0",
"private": true,
"appName": "Assets UI",
"sbcName": "SBC Common Components",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"build-check": "vite build",
"preview": "vite preview --port 8080",
"lint": "eslint . --ext .js,.ts,.vue",
"lint:fix": "eslint . --ext .js,.ts,.vue --fix",
"test": "vitest run",
"test:unit": "vitest run",
"test:coverage": "vitest run --coverage"
},
Expand Down
137 changes: 137 additions & 0 deletions ppr-ui/src/components/userAccess/DealerInfo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<script setup lang="ts">
import { useStore } from '@/store/store'
import { useUserAccess } from '@/composables'
import { storeToRefs } from 'pinia'
import { ref } from 'vue'
const { getIsAccountAdministrator } = storeToRefs(useStore())
const { downloadServiceAgreement } = useUserAccess()
const activePanels = ref<number[]>([0])
const qsUserGuideUrl = 'https://www2.gov.bc.ca/assets/gov/employment-business-and-economic-development/' +
'business-management/permits-licences-and-registration/registries-other-assets/qs_transfers_sale_user_guide.pdf'
const acceptTerms = () => {
console.log('API PUT accepted agreement terms here')
}
</script>

<template>
<v-expansion-panels
v-model="activePanels"
multiple
>
<v-expansion-panel>
<!-- Default Title -->
<v-expansion-panel-title>
<v-expand-transition>
<v-row
noGutters
class="fs-14"
>
<v-col
cols="12"
class="d-inline-flex"
>
<v-icon color="primary pt-3">
mdi-information-outline
</v-icon>
<h3 class="ml-2">
Update to Qualified Supplier Accounts for Home Dealers
</h3>
</v-col>
</v-row>
</v-expand-transition>
</v-expansion-panel-title>

<!-- Panel Content-->
<v-expansion-panel-text class="py-0 fs-14">
<v-col cols="12">
<p class="mt-n5">
We’ve recently updated features and policies within your Qualified Supplier – Home Dealers account to
now include:
</p>
</v-col>

<v-col
cols="12"
class="pt-1 ml-5"
>
<ul>
<li class="my-1">
Transfer due to Sale or Gift, including cases where you are not the owner.
<a
:href="qsUserGuideUrl"
target="_blank"
class="text-decoration-none pl-0"
>Read User Guide
<v-icon size="18">mdi-open-in-new</v-icon>
</a>
</li>
<li>Transport Permits can now be filed no matter the location of the home.</li>
</ul>
</v-col>

<v-divider
v-if="getIsAccountAdministrator"
class="ml-0 mb-5 mt-2"
/>

<v-row
noGutters
>
<v-col
v-if="getIsAccountAdministrator"
cols="12"
>
<p>
<b>Terms</b>: All filed documents and supporting documents will be stored for 7 years. If requested, a
copy or certified copy of filed documents (such as the Bill of Sale, or other signed forms), will be
provided within 7 business days, at the fee level set by the Registrar.
</p>
</v-col>

<v-col
v-if="getIsAccountAdministrator"
cols="12"
>
<v-btn
class="generic-link px-0 mt-3 text-decoration-none"
variant="plain"
:ripple="false"
@click="downloadServiceAgreement"
>
<img
alt=""
src="@/assets/svgs/pdf-icon-blue.svg"
>
<span class="pl-1">Review Qualified Supplier Agreement</span>
</v-btn>
</v-col>

<v-col cols="12">
<p class="fs-12 mt-2 mb-4">
<b>Note</b>: The administrator of the account must confirm the account updates.
</p>
</v-col>

<v-col
v-if="getIsAccountAdministrator"
cols="12"
>
<v-btn
class="mb-4 mt-1"
:ripple="false"
@click="acceptTerms"
>
<span class="font-weight-bold">Confirm Account Updates</span>
</v-btn>
</v-col>
</v-row>
</v-expansion-panel-text>
</v-expansion-panel>
</v-expansion-panels>
</template>
<style lang="scss" scoped>
@import '@/assets/styles/theme.scss';
</style>
1 change: 1 addition & 0 deletions ppr-ui/src/components/userAccess/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default as ServiceAgreement } from './ServiceAgreement.vue'
export { default as DealerInfo } from './DealerInfo.vue'
15 changes: 14 additions & 1 deletion ppr-ui/src/composables/userAccess/useUserAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
createQualifiedSupplier,
fromDisplayPhone,
getAccountInfoFromAuth,
getAccountMembers,
getFeatureFlag,
getKeyByValue,
getMhrManufacturerInfo,
Expand All @@ -20,6 +21,7 @@ import {
updateUserSettings
} from '@/utils'
import {
AccountProductMemberships,
ApiHomeTenancyTypes,
HomeLocationTypes,
HomeOwnerPartyTypes,
Expand Down Expand Up @@ -53,7 +55,8 @@ export const useUserAccess = () => {
setMhrQsSubmittingParty,
setMhrQsAuthorization,
setMhrQsIsRequirementsConfirmed,
setMhrQsValidation
setMhrQsValidation,
setIsAccountAdministrator
} = useStore()
const {
getAccountId,
Expand Down Expand Up @@ -194,6 +197,15 @@ export const useUserAccess = () => {
)
})

/** Returns True if the current user is an Account Admin **/
const fetchIsAccountAdmin = async (): Promise<void> => {
const { members } = await getAccountMembers()
const isAdmin = members?.some(member => member.membershipTypeCode === AccountProductMemberships.ADMIN &&
member.user && member.user.id === getCurrentUser.value.id
)
setIsAccountAdministrator(isAdmin)
}

/** Navigate to User Access Home route **/
const goToUserAccess = async (): Promise<void> => {
if (!hasPendingQsAccess.value && !isUserAccessRoute.value) {
Expand Down Expand Up @@ -507,6 +519,7 @@ export const useUserAccess = () => {
setQsInformationModel,
setQsDefaultValidation,
updateUserMiscSettings,
fetchIsAccountAdmin,
isQsAccessEnabled,
hasPendingQsAccess,
hasRejectedQsAccess,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ export interface AccountInfoIF {
name: string // account name or business name
mailingAddress: AddressIF
accountAdmin: AccountAdminInfoIF
phoneNumber?: string
phoneExtension?: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ContactInfoIF, FeeSettingsIF, UserSettingsIF } from '.'

// User Info state model
export interface UserInfoIF {
id?: string
contacts: Array<ContactInfoIF>
feeSettings: FeeSettingsIF
firstname: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { UnitNoteIF } from '@/interfaces/unit-note-interfaces/unit-note-interfac
// State model example
export interface StateModelIF {
accountInformation: AccountInformationIF
isAccountAdministrator: boolean
accountProductSubscriptions: AccountProductSubscriptionIF
userProductSubscriptions: Array<UserProductSubscriptionIF>
userProductSubscriptionsCodes: Array<ProductCode>
Expand Down
6 changes: 3 additions & 3 deletions ppr-ui/src/resources/mhrSubProductConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export const MhrSubProductConfig: Array<SubProductConfigIF> = [
],
hasImportantBullet: false,
/* eslint-disable max-len */
note: `General Service Providers who are not lawyers or notaries cannot request Qualified Supplier access online
and <a href="https://www2.gov.bc.ca/gov/content/housing-tenancy/owning-a-home/manufactured-home-registry#qualified-supplier"
note: `General Service Providers who are not lawyers or notaries cannot request Qualified Supplier access online
and <a href="https://www2.gov.bc.ca/gov/content/housing-tenancy/owning-a-home/manufactured-home-registry#qualified-supplier"
target="_blank">must submit a paper application <span class="mdi mdi-open-in-new"></span></a> to BC Registries.`
/* eslint-enable max-len */
},
Expand All @@ -29,7 +29,7 @@ export const MhrSubProductConfig: Array<SubProductConfigIF> = [
type: MhrSubTypes.DEALERS,
label: `${MhrSubTypes.QUALIFIED_SUPPLIER} - ${MhrSubTypes.DEALERS}`,
productBullets: [
MhrActions.MHR_SEARCH, MhrActions.TRANSPORT_PERMITS_NO_CERT
MhrActions.MHR_SEARCH, MhrActions.TRANSPORT_PERMITS_NO_CERT, MhrActions.TRANSFER_TRANSACTIONS
],
hasImportantBullet: false
}
Expand Down
6 changes: 6 additions & 0 deletions ppr-ui/src/resources/userAccessRequirements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export const userAccessRequirements: Record<MhrSubTypes, RequirementsConfigIF[]>
{
boldText: 'Have comprehensive general liability insurance ',
regularText: 'equal to or greater than $2,000,000.00.'
},
{
boldText: 'All filed documents will be stored for 7 years. ',
regularText: 'If requested, a copy or certified copy of filed documents ' +
'(such as the Bill of Sale, or other signed forms), ' +
'will be provided within 7 business days, at the fee level set by the Registrar.'
}
],
[MhrSubTypes.GENERAL_PUBLIC]: [],
Expand Down
1 change: 1 addition & 0 deletions ppr-ui/src/store/state/state-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const stateModel: StateModelIF = {
label: '',
type: ''
},
isAccountAdministrator: false,
accountProductSubscriptions: null,
userProductSubscriptions: [],
userProductSubscriptionsCodes: [],
Expand Down
16 changes: 14 additions & 2 deletions ppr-ui/src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ export const useStore = defineStore('assetsStore', () => {
const getAccountModel = computed((): AccountModelIF => {
return null // account
})
const getIsAccountAdministrator = computed((): boolean => {
return state.value.isAccountAdministrator
})
const isRoleStaffSbc = computed((): boolean => {
return state.value.authorization?.isSbc
})
Expand Down Expand Up @@ -338,6 +341,9 @@ export const useStore = defineStore('assetsStore', () => {
const hasDrsEnabled = computed<boolean>(() => {
return isRoleStaffReg.value && getFeatureFlag('drs-integration-enabled')
})
const hasEnhancedDealerEnabled = computed<boolean>(() => {
return isRoleQualifiedSupplierHomeDealer.value && getFeatureFlag('mhr-enhanced-dealers-enabled')
})
const getUserServiceFee = computed<number>(() => {
return state.value.userInfo?.feeSettings?.serviceFee || 1.50
})
Expand Down Expand Up @@ -376,7 +382,7 @@ export const useStore = defineStore('assetsStore', () => {
const getIsStaffClientPayment = computed<boolean>(() => {
return state.value.isStaffClientPayment
})
const getMhrGenerateDocId = computed<string>(() => {
const getMhrGenerateDocId = computed<boolean>(() => {
return state.value.generateDocId
})
const showStepErrors = computed<boolean>(() => {
Expand Down Expand Up @@ -989,6 +995,10 @@ export const useStore = defineStore('assetsStore', () => {
state.value.accountInformation = accountInformation
}

function setIsAccountAdministrator (isAdmin: boolean) {
state.value.isAccountAdministrator = isAdmin
}

function setAddCollateral (addCollateral: AddCollateralIF) {
state.value.registration.collateral = addCollateral
setUnsavedChanges(true)
Expand Down Expand Up @@ -1531,6 +1541,7 @@ export const useStore = defineStore('assetsStore', () => {
return {
// User-related getters
getAccountModel,
getIsAccountAdministrator,
getCurrentUser,
getUserEmail,
getUserFirstName,
Expand Down Expand Up @@ -1565,10 +1576,10 @@ export const useStore = defineStore('assetsStore', () => {
hasPprEnabled,
hasMhrEnabled,
hasMhrReIssuePermitEnabled,
hasEnhancedDealerEnabled,

// Document Record Service
hasDrsEnabled,

// Add Collateral getters
getAddCollateral,
getOriginalAddCollateral,
Expand Down Expand Up @@ -1749,6 +1760,7 @@ export const useStore = defineStore('assetsStore', () => {
setUserProductSubscriptions,
setUserProductSubscriptionsCodes,
setAccountInformation,
setIsAccountAdministrator,
setAddCollateral,
setOriginalAddCollateral,
setAddSecuredPartiesAndDebtors,
Expand Down
25 changes: 25 additions & 0 deletions ppr-ui/src/utils/auth-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,31 @@ export async function getSbcFromAuth (): Promise<boolean> {
)
}

/** Get Org Members from auth api **/
export async function getAccountMembers (): Promise<any> {
const url = sessionStorage.getItem('AUTH_API_URL')
const currentAccount = sessionStorage.getItem(SessionStorageKeys.CurrentAccount)
const accountInfo = JSON.parse(currentAccount)
const accountId = accountInfo?.id

const config = { baseURL: url, headers: { Accept: 'application/json' } }
return axios.get(`orgs/${accountId}/members?active`, config)
.then(
response => {
const data = response?.data
if (!data) {
return false
}
return data
}
).catch(
error => {
throw new Error('Auth API error getting SBC: status code = ' +
error?.response?.status?.toString() || StatusCodes.NOT_FOUND.toString())
}
)
}

/**
* Fetches product subscription authorizations from Auth API.
*/
Expand Down
3 changes: 2 additions & 1 deletion ppr-ui/src/utils/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const defaultFlagSet: LDFlagSet = {
'mhr-user-access-enabled': false,
'mhr-history-enabled': false,
'mhr-re-issue-permit-enabled': false, // Enables Create New and Extend Transport Permit: Staff Targeted for now
'drs-integration-enabled': false, // Enables connections to Documents Record Services
'drs-integration-enabled': false, // Enables connections to Documents Record
'mhr-enhanced-dealers-enabled': false, // Enables Dealer permissions for MHR Permits and Transfers
'sentry-enable': false, // by default, no sentry logs
'banner-text': '' // by default, there is no banner text
}
Expand Down
Loading

0 comments on commit fd2178a

Please sign in to comment.