Skip to content

Commit

Permalink
20818 Fixed draft amalgamation initial values (bcgov#647)
Browse files Browse the repository at this point in the history
- app version = 7.1.11
- created better getAccountId store getter and used it in place of old code
- don't save empty legalName in draft regular amalgamation
- don't save null correctNameOption in draft regular amalgamation
- improved email/phone logic

Co-authored-by: Severin Beauvais <severin.beauvais@gov.bc.ca>
  • Loading branch information
severinbeauvais and Severin Beauvais authored Apr 12, 2024
1 parent faf7c8e commit b909e19
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 20 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "business-filings-ui",
"version": "7.1.10",
"version": "7.1.11",
"private": true,
"appName": "Filings UI",
"sbcName": "SBC Common Components",
Expand Down
10 changes: 5 additions & 5 deletions src/components/Dashboard/TodoList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@
v-if="EnumUtilities.isPayMethodOnlineBanking(item)"
:filing="item"
:payApiUrl="getPayApiUrl"
:accountId="accountId"
:accountId="getAccountId"
class="mb-6"
/>
<PaymentPending v-else />
Expand Down Expand Up @@ -627,7 +627,8 @@ import {
TodoListResourceIF
} from '@/interfaces'
import { GetCorpFullDescription } from '@bcrs-shared-components/corp-type-module'
import { useBusinessStore, useConfigurationStore, useFilingHistoryListStore, useRootStore } from '@/stores'
import { useAuthenticationStore, useBusinessStore, useConfigurationStore, useFilingHistoryListStore,
useRootStore } from '@/stores'
@Component({
components: {
Expand Down Expand Up @@ -669,10 +670,10 @@ export default class TodoList extends Mixins(AllowableActionsMixin, DateMixin, E
inProcessFiling: number = null
fetchAffiliationInvitationsErrorDialog = false
authorizeAffiliationInvitationErrorDialog = false
accountId: number = null
@Prop({ default: null }) readonly highlightId!: number
@Getter(useAuthenticationStore) getAccountId!: string
@Getter(useConfigurationStore) getAuthWebUrl!: string
@Getter(useConfigurationStore) getBusinessesUrl!: string
@Getter(useConfigurationStore) getAuthApiUrl!: string
Expand Down Expand Up @@ -996,9 +997,8 @@ export default class TodoList extends Mixins(AllowableActionsMixin, DateMixin, E
}
// load all the invitations here and push them into todo items
this.accountId = JSON.parse(sessionStorage.getItem('CURRENT_ACCOUNT'))?.id
const response =
await AuthServices.fetchAffiliationInvitations(this.getAuthApiUrl, this.getIdentifier, this.accountId)
await AuthServices.fetchAffiliationInvitations(this.getAuthApiUrl, this.getIdentifier, +this.getAccountId)
.catch((err) => {
console.log('Error fetching affiliation invitations for todo', err) // eslint-disable-line no-console
this.fetchAffiliationInvitationsErrorDialog = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class PaymentPendingOnlineBanking extends Vue {
/** The subject filing. */
@Prop({ required: true }) readonly filing!: any
@Prop({ required: true }) readonly payApiUrl!: string
@Prop({ required: true }) readonly accountId!: any
@Prop({ required: true }) readonly accountId!: string
cfsAccountId: string = null;
Expand All @@ -53,7 +53,7 @@ export default class PaymentPendingOnlineBanking extends Vue {
}
async mounted () {
this.cfsAccountId = await PayServices.fetchCfsAccountId(this.payApiUrl, this.accountId)
this.cfsAccountId = await PayServices.fetchCfsAccountId(this.payApiUrl, +this.accountId)
}
}
</script>
Expand Down
12 changes: 12 additions & 0 deletions src/stores/authenticationStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ import { defineStore } from 'pinia'

export const useAuthenticationStore = defineStore('authentication', {
getters: {
/** The Account ID, from session storage. */
getAccountId (): string {
// if we can't get account id from ACCOUNT_ID
// then try to get it from CURRENT_ACCOUNT
let accountId = sessionStorage.getItem('ACCOUNT_ID')
if (!accountId) {
const currentAccount = sessionStorage.getItem('CURRENT_ACCOUNT')
accountId = JSON.parse(currentAccount)?.id
}
return accountId
},

/**
* The (Keycloak) current account object.
* @remarks This isn't set right away - may need to wait 200ms or more after login.
Expand Down
8 changes: 7 additions & 1 deletion src/utils/navigate.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { createPinia, setActivePinia } from 'pinia'
import { useAuthenticationStore } from '@/stores'

setActivePinia(createPinia())
const authenticationStore = useAuthenticationStore()

/**
* Navigates to the specified URL, including Account ID param if available.
* This function may or may not return. The caller should account for this!
Expand All @@ -7,7 +13,7 @@ export function navigate (url: string): boolean {
if (!url) throw new Error('empty URL')

// get account id and set in params
const accountId = JSON.parse(sessionStorage.getItem('CURRENT_ACCOUNT'))?.id
const accountId = authenticationStore.getAccountId
if (accountId) {
if (url.includes('?')) {
url += `&accountid=${accountId}`
Expand Down
28 changes: 19 additions & 9 deletions src/views/AmalgamationSelection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
</template>

<script lang="ts">
import { useBusinessStore, useConfigurationStore, useRootStore } from '@/stores'
import { useAuthenticationStore, useBusinessStore, useConfigurationStore, useRootStore } from '@/stores'
import { Action, Getter } from 'pinia-class'
import { Component, Vue } from 'vue-property-decorator'
import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module'
Expand All @@ -160,6 +160,7 @@ import { TechnicalErrorDialog } from '@/components/dialogs'
}
})
export default class AmalgamationSelection extends Vue {
@Getter(useAuthenticationStore) getAccountId!: string
@Getter(useConfigurationStore) getCreateUrl!: string
@Getter(useRootStore) getBusinessEmail!: string
@Getter(useRootStore) getFullPhoneNumber!: string
Expand All @@ -176,6 +177,7 @@ export default class AmalgamationSelection extends Vue {
// enum for template
readonly AmalgamationTypes = AmalgamationTypes
// local variable
showErrorDialog = false
/** Called when component is created. */
Expand Down Expand Up @@ -220,17 +222,25 @@ export default class AmalgamationSelection extends Vue {
* @returns the business identifier of the newly created amalgamation application
*/
private async createBusinessAA (type: AmalgamationTypes): Promise<string> {
const accountId = +JSON.parse(sessionStorage.getItem('CURRENT_ACCOUNT'))?.id || 0
const email = this.isShortFormAmalgamation(type) ? this.getBusinessEmail : ''
const phone = this.isShortFormAmalgamation(type) ? this.getFullPhoneNumber : ''
const legalName = this.isShortFormAmalgamation(type) ? this.getLegalName : ''
const correctNameOption = this.isShortFormAmalgamation(type) ? CorrectNameOptions.CORRECT_AML_ADOPT : null
// short-form amalgamations use the legal name of the primary business,
// otherwise don't set a legal name
const legalName = this.isShortFormAmalgamation(type) ? this.getLegalName : undefined
// short-form amalgamations adopt the name of the primary business,
// otherwise don't set a correct name option
const correctNameOption =
this.isShortFormAmalgamation(type) ? CorrectNameOptions.CORRECT_AML_ADOPT : undefined
// short-form amalgamations use the email and phone of the primary business (if they exist),
// otherwise set empty initial values
const email = (this.isShortFormAmalgamation(type) && this.getBusinessEmail) || ''
const phone = (this.isShortFormAmalgamation(type) && this.getFullPhoneNumber) || ''
const draftAmalgamationApplication = {
filing: {
header: {
name: FilingTypes.AMALGAMATION_APPLICATION,
accountId
accountId: this.getAccountId
},
business: {
legalType: this.getLegalType
Expand All @@ -243,8 +253,8 @@ export default class AmalgamationSelection extends Vue {
},
type,
contactPoint: {
email: email || '',
phone: phone || ''
email,
phone
}
}
}
Expand Down

0 comments on commit b909e19

Please sign in to comment.