Skip to content

Commit

Permalink
update logic of setting access type while account creation for govn
Browse files Browse the repository at this point in the history
  • Loading branch information
Jxio committed May 17, 2024
1 parent 5112d8a commit dd2b346
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 12 deletions.
37 changes: 30 additions & 7 deletions auth-web/src/components/auth/common/AccountBusinessType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,14 @@
</template>

<script lang="ts">
import { defineComponent, ref, computed, onMounted, nextTick } from '@vue/composition-api'
import { defineComponent, ref, computed, onMounted, nextTick, watch } from '@vue/composition-api'
import { useCodesStore } from '@/stores/codes'
import { useOrgStore } from '@/stores/org'
import OrgNameAutoComplete from '@/views/auth/OrgNameAutoComplete.vue'

Check failure on line 184 in auth-web/src/components/auth/common/AccountBusinessType.vue

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

'watch' is defined but never used
import { OrgBusinessType, Organization } from '@/models/Organization'
import { Account, AccountType } from '@/util/constants'
import { AccessType, Account, AccountType, SessionStorageKeys } from '@/util/constants'
import { Code } from '@/models/Code'

Check failure on line 187 in auth-web/src/components/auth/common/AccountBusinessType.vue

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Imports should be sorted alphabetically
import ConfigHelper from '@/util/config-helper'

Check failure on line 188 in auth-web/src/components/auth/common/AccountBusinessType.vue

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Expected 'multiple' syntax before 'single' syntax

Check failure on line 188 in auth-web/src/components/auth/common/AccountBusinessType.vue

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

'Organization' is defined but never used

Check failure on line 189 in auth-web/src/components/auth/common/AccountBusinessType.vue

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Imports should be sorted alphabetically

Check failure on line 189 in auth-web/src/components/auth/common/AccountBusinessType.vue

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

'AccessType' is defined but never used
export default defineComponent({

Check failure on line 190 in auth-web/src/components/auth/common/AccountBusinessType.vue

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

'Code' is defined but never used
name: 'AccountBusinessType',
Expand Down Expand Up @@ -229,6 +230,7 @@ export default defineComponent({
const businessSizeCodes = computed(() => codesStore.businessSizeCodes)
const businessTypeCodes = computed(() => codesStore.businessTypeCodes)
const accountInformationForm = ref(null)
const orgType = ref(AccountType.INDIVIDUAL)
const autoCompleteIsActive = ref(false)
const autoCompleteSearchValue = ref('')
Expand All @@ -241,10 +243,9 @@ export default defineComponent({
const branchName = ref('')
const isIndividualAccount = ref(false)
const isGovnAccount = ref(false)
const orgNameRules = [v => !!v || 'An account name is required']
const orgBusinessTypeRules = [v => !!v || 'A business type is required']
const orgBusinessSizeRules = [v => !!v || 'A business size is required']
const orgNameRules = ref([])
const orgBusinessTypeRules = ref([])
const orgBusinessSizeRules = ref([])
const getOrgNameLabel = computed(() => {
if (props.govmAccount) {
Expand All @@ -271,6 +272,18 @@ export default defineComponent({
branchName.value = ''
businessType.value = ''
businessSize.value = ''
if (accountInformationForm.value) {
accountInformationForm.value.resetValidation()
}
if (isGovnAccount.value) {
orgNameRules.value = [v => !!v || 'A government agency name is required']
orgBusinessTypeRules.value = [v => !!v || 'A government agency type is required']
orgBusinessSizeRules.value = [v => !!v || 'A government agency size is required']
} else {
orgNameRules.value = [v => !!v || 'An account name is required']
orgBusinessTypeRules.value = [v => !!v || 'A business type is required']
orgBusinessSizeRules.value = [v => !!v || 'A business size is required']
}
}
async function handleAccountTypeChange(newValue) {
Expand All @@ -292,6 +305,14 @@ export default defineComponent({
emit('update:org-business-type', orgBusinessType)
}

Check warning on line 306 in auth-web/src/components/auth/common/AccountBusinessType.vue

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

This line has a length of 165. Maximum allowed is 150
function updateAccessType() {
if (isGovnAccount.value) {
ConfigHelper.addToSession(SessionStorageKeys.GOVN_USER, 'true')
return
}
ConfigHelper.removeFromSession(SessionStorageKeys.GOVN_USER)
}
function emitValid() {
let isFormValid = true
if (isBusinessAccount.value || isGovnAccount.value) {
Expand Down Expand Up @@ -353,6 +374,7 @@ export default defineComponent({
}
await nextTick()
emitUpdatedOrgBusinessType()
updateAccessType()
emitValid()
}
Expand Down Expand Up @@ -382,7 +404,8 @@ export default defineComponent({
AccountType,
getOrgTypeDropdownLabel,
getOrgSizeDropdownLabel,
isEditing: props.isEditAccount
isEditing: props.isEditAccount,
accountInformationForm
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ import { Component, Emit, Mixins, Prop } from 'vue-property-decorator'
import ConfirmCancelButton from '@/components/auth/common/ConfirmCancelButton.vue'
import { Organization } from '@/models/Organization'
import PaymentMethods from '@/components/auth/common/PaymentMethods.vue'
import { PaymentTypes } from '@/util/constants'
import { AccessType, PaymentTypes, SessionStorageKeys } from '@/util/constants'

Check failure on line 77 in auth-web/src/components/auth/create-account/PaymentMethodSelector.vue

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Expected 'multiple' syntax before 'single' syntax
import Steppable from '@/components/auth/common/stepper/Steppable.vue'
import { useOrgStore } from '@/stores/org'
import ConfigHelper from '@/util/config-helper'

Check failure on line 80 in auth-web/src/components/auth/create-account/PaymentMethodSelector.vue

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

Imports should be sorted alphabetically
@Component({
components: {
Expand All @@ -94,6 +95,8 @@ export default class PaymentMethodSelector extends Mixins(Steppable) {
@State(useOrgStore) readonly currentOrganizationType!: string
@State(useOrgStore) readonly currentOrgPaymentType!: string
@Action(useOrgStore) setAccessType!: (accessType: string) => void
@Action(useOrgStore) setCurrentOrganization!: (organization: Organization) => void
@Action(useOrgStore) setCurrentOrganizationPaymentType!: (paymentType: string) => void
@Action(useOrgStore) setCurrentOrganizationBcolProfile!: (bcolProfile: BcolProfile) => void
Expand Down Expand Up @@ -137,6 +140,12 @@ export default class PaymentMethodSelector extends Mixins(Steppable) {
async save () {
this.setCurrentOrganizationPaymentType(this.selectedPaymentMethod)
// Update Access Type, in case user select GOVN
const isGovNAccount = !!JSON.parse(ConfigHelper.getFromSession(SessionStorageKeys.GOVN_USER || 'false'))
if (isGovNAccount) {
this.setAccessType(AccessType.GOVN)
this.setCurrentOrganization({ ...this.currentOrganization, ...{ accessType: AccessType.GOVN } })
}
if (this.selectedPaymentMethod !== PaymentTypes.BCOL) {
// It's possible this is already set from being linked, so we need to empty it out.
this.setCurrentOrganizationBcolProfile(null)
Expand Down
1 change: 0 additions & 1 deletion auth-web/src/stores/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export const useCodesStore = defineStore('codes', () => {
fetchAllBusinessTypeCodes,
getBusinessSizeCodes,
getBusinessTypeCodes,
getBusinessTypeCodesDelete,
getCodes,
getGovernmentTypeCodes,
getOnholdReasonCodes,
Expand Down
10 changes: 7 additions & 3 deletions auth-web/src/views/auth/ChooseAuthMethodView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<v-divider class="mb-6 mt-1" />
<div class="mb-6 mt-1">
<header class="d-flex align-center">
<span>Other account creation options if you do not have ID issued in Canada</span>
<span>Don't have ID issued in Canada? View other account creation options</span>
<v-btn
depressed
color="primary"
Expand Down Expand Up @@ -304,7 +304,7 @@
</div>
<div>
<header class="d-flex align-center">
<span>How to create an account if you are from a Canadian government agency</span>
<span>Creating an account for Canadian government agency?</span>
<v-btn
depressed
color="primary"
Expand Down Expand Up @@ -344,7 +344,7 @@
<div class="mt-4">
If you are a B.C. Provincial Government Ministry/Employee, please follow
<a
:href="bcTokenURL"
:href="govnURL"
target="_blank"
class="learn-more-link"
rel="noopener noreferrer"
Expand Down Expand Up @@ -420,6 +420,10 @@ export default class ChooseAuthMethodView extends Vue {
return 'https://id.gov.bc.ca/account/setup-instruction'
}
get govnURL (): string {
return 'https://www2.gov.bc.ca/assets/gov/employment-business-and-economic-development/business-management/permits-licences-and-registration/registries-guides/ministry_account_creation_process_april_2022.pdf'

Check warning on line 424 in auth-web/src/views/auth/ChooseAuthMethodView.vue

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

This line has a length of 212. Maximum allowed is 150
}
get serviceCardLearnMoreURL (): string {
return 'https://id.gov.bc.ca/'
}
Expand Down

0 comments on commit dd2b346

Please sign in to comment.