Skip to content

Commit

Permalink
tweaks for govn type dropdown (#2842)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jxio authored May 27, 2024
1 parent 0297e35 commit e9302d0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{{ orgName }}
</div>
<div
v-if="nameChangeAllowed && viewOnlyMode"
v-if="canOrgChange"
v-can:CHANGE_ORG_NAME.hide
>
<span
Expand Down Expand Up @@ -139,7 +139,7 @@ export default defineComponent({
const codeStore = useCodesStore()
const orgStore = useOrgStore()
const businessSizeCodes = computed(() => codeStore.businessSizeCodes)
const businessTypeCodes = computed(() => codeStore.businessTypeCodes)
const allBusinessTypeCodes = computed(() => codeStore.allBusinessTypeCodes)
const localVars = (reactive({
orgName: '',
Expand Down Expand Up @@ -177,7 +177,7 @@ export default defineComponent({
return (codeArray && codeArray[0] && codeArray[0]?.desc) || ''
}
const getBusinessTypeLabel = computed(() => {
return getCodeLabel(businessTypeCodes.value, localVars.orgBusinessType.businessType)
return getCodeLabel(allBusinessTypeCodes.value, localVars.orgBusinessType.businessType)
})
const getBusinessSizeLabel = computed(() => {
return getCodeLabel(businessSizeCodes.value, localVars.orgBusinessType.businessSize)
Expand Down
17 changes: 10 additions & 7 deletions auth-web/src/components/auth/common/AccountBusinessType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
:label="getOrgTypeDropdownLabel"
item-text="desc"
item-value="code"
:items="businessTypeCodes"
:items="typeCodesItems"
data-test="select-business-type"
:rules="orgBusinessTypeRules"
:menu-props="{
Expand Down Expand Up @@ -182,7 +182,7 @@
</template>

<script lang="ts">
import { AccessType, Account, AccountType, OrgNameLabel, SessionStorageKeys } from '@/util/constants'
import { Account, AccountType, OrgNameLabel, SessionStorageKeys } from '@/util/constants'
import { computed, defineComponent, nextTick, onMounted, reactive, toRefs, watch } from '@vue/composition-api'
import ConfigHelper from '@/util/config-helper'
import { OrgBusinessType } from '@/models/Organization'
Expand Down Expand Up @@ -232,11 +232,12 @@ export default defineComponent({
const {
businessSizeCodes,
businessTypeCodes
businessTypeCodes,
governmentTypeCodes
} = storeToRefs(codesStore)
const currentOrganization = computed(() => orgStore.currentOrganization)
const isCurrentGovnOrg = currentOrganization.value?.accessType === AccessType.GOVN
const isCurrentGovnOrg = computed(() => orgStore.isGovnOrg)
const state = reactive({
accountInformationForm: null,
Expand All @@ -254,7 +255,8 @@ export default defineComponent({
isGovnAccount: false,
orgNameRules: [],
orgBusinessTypeRules: [],
orgBusinessSizeRules: []
orgBusinessSizeRules: [],
typeCodesItems: []
})
const getOrgNameLabel = computed(() => {
Expand All @@ -281,6 +283,7 @@ export default defineComponent({
state.isBusinessAccount = state.orgType === AccountType.BUSINESS
state.isGovnAccount = state.orgType === AccountType.GOVN
state.isIndividualAccount = state.orgType === AccountType.INDIVIDUAL
cleanOrgInfo()
})
function cleanOrgInfo () {
Expand All @@ -295,16 +298,17 @@ export default defineComponent({
state.orgNameRules = [v => !!v || 'A government agency name is required']
state.orgBusinessTypeRules = [v => !!v || 'A government agency type is required']
state.orgBusinessSizeRules = [v => !!v || 'A government agency size is required']
state.typeCodesItems = governmentTypeCodes.value
} else {
state.orgNameRules = [v => !!v || 'An account name is required']
state.orgBusinessTypeRules = [v => !!v || 'A business type is required']
state.orgBusinessSizeRules = [v => !!v || 'A business size is required']
state.typeCodesItems = businessTypeCodes.value
}
}
async function handleAccountTypeChange (newValue) {
state.orgType = newValue
cleanOrgInfo()
await onOrgBusinessTypeChange(!props.isEditAccount)
}
Expand Down Expand Up @@ -401,7 +405,6 @@ export default defineComponent({
onOrgNameChange,
onOrgBusinessTypeChange,
businessSizeCodes,
businessTypeCodes,
handleAccountTypeChange,
AccountType,
getOrgTypeDropdownLabel,
Expand Down
7 changes: 5 additions & 2 deletions auth-web/src/stores/org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export const useOrgStore = defineStore('org', () => {
currentOrgPaymentDetails: null as OrgPaymentDetails,
isCurrentSelectedProductsPremiumOnly: false,
resetAccountTypeOnSetupAccount: false, // this flag use to check need to reset accounttype select when moving back and forth in stepper
vDisplayModeValue: ''// DisplayModeValues.VIEW_ONLY
vDisplayModeValue: '', // DisplayModeValues.VIEW_ONLY
originAccessType: undefined as string
})

function $reset () {
Expand Down Expand Up @@ -132,6 +133,7 @@ export const useOrgStore = defineStore('org', () => {
state.isCurrentSelectedProductsPremiumOnly = false
state.resetAccountTypeOnSetupAccount = false
state.vDisplayModeValue = ''
state.originAccessType = undefined as string
}

/** Is True if the current account is premium. */
Expand All @@ -154,7 +156,7 @@ export const useOrgStore = defineStore('org', () => {
})

const isGovnOrg = computed<boolean>(() => {
return state.currentOrganization?.accessType === AccessType.GOVN
return state.originAccessType === AccessType.GOVN
})

// Note this will only work while the current organization is set for SBC_STAFF.
Expand Down Expand Up @@ -278,6 +280,7 @@ export const useOrgStore = defineStore('org', () => {
const response = await OrgService.getOrganization(orgId)
const organization = response?.data
setCurrentOrganization(organization)
state.originAccessType = organization?.accessType
return organization
}

Expand Down
4 changes: 2 additions & 2 deletions auth-web/tests/unit/components/AccountDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('AccountDetails.vue', () => {
orgStore.currentOrganization.accessType = AccessType.GOVN
await wrapper.setProps({ viewOnlyMode: true, nameChangeAllowed: true })
await wrapper.vm.$nextTick()
expect(wrapper.vm.accountTypeLabel).toBe('Government Agency Type:')
expect(wrapper.vm.accountSizeLabel).toBe('Government Agency Size:')
expect(wrapper.vm.accountTypeLabel).toBe('Business Type:')
expect(wrapper.vm.accountSizeLabel).toBe('Business Size:')
})
})

0 comments on commit e9302d0

Please sign in to comment.