Skip to content

Commit

Permalink
2.5.13 patch 3 (#1557)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik-aot authored Apr 22, 2021
1 parent 1f4c7b6 commit 85388f6
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
<v-data-table
class="user-list"
:headers="headerAccounts"
:items="pendingStaffOrgs"
:items="pendingOrgs"
:items-per-page.sync="tableDataOptions.itemsPerPage"
:hide-default-footer="pendingStaffOrgs.length <= tableDataOptions.itemsPerPage"
:hide-default-footer="totalAccountsCount <= tableDataOptions.itemsPerPage"
:custom-sort="columnSort"
:no-data-text="$t('noActiveAccountsLabel')"
:footer-props="{
itemsPerPageOptions: getPaginationOptions
}"
:options.sync="tableDataOptions"
:loading="isTableLoading"
@update:items-per-page="saveItemsPerPage"
:server-items-length="totalAccountsCount"
>
<template v-slot:loading>
Loading...
Expand All @@ -35,22 +37,21 @@
</template>

<script lang="ts">
import { Component, Mixins, Prop } from 'vue-property-decorator'
import { Component, Mixins, Prop, Watch } from 'vue-property-decorator'
import { OrgFilterParams, OrgList, Organization } from '@/models/Organization'
import { AccountStatus } from '@/util/constants'
import CommonUtils from '@/util/common-util'
import { DataOptions } from 'vuetify'
import { Organization } from '@/models/Organization'
import PaginationMixin from '@/components/auth/mixins/PaginationMixin.vue'
import { mapState } from 'vuex'
import { namespace } from 'vuex-class'
@Component({
computed: {
...mapState('staff', [
'pendingStaffOrgs'
])
}
})
const StaffModule = namespace('staff')
@Component({})
export default class StaffPendingAccountsTable extends Mixins(PaginationMixin) {
private readonly pendingStaffOrgs!: Organization[]
@StaffModule.State('pendingStaffOrgs') private pendingStaffOrgs!: Organization[]
@StaffModule.Action('searchOrgs') private searchOrgs!: (filterParams: OrgFilterParams) => OrgList
@StaffModule.State('pendingReviewCount') private pendingReviewCount!: number
private columnSort = CommonUtils.customSort
private tableDataOptions: Partial<DataOptions> = {}
Expand Down Expand Up @@ -85,12 +86,41 @@ export default class StaffPendingAccountsTable extends Mixins(PaginationMixin) {
]
private formatDate = CommonUtils.formatDisplayDate
private orgFilter: OrgFilterParams
private isTableLoading: boolean = false
private pendingOrgs: Organization[] = []
private totalAccountsCount = 0
mounted () {
this.tableDataOptions = this.DEFAULT_DATA_OPTIONS
if (this.hasCachedPageInfo) {
this.tableDataOptions = this.getAndPruneCachedPageInfo()
}
this.pendingOrgs = this.pendingStaffOrgs
this.totalAccountsCount = this.pendingReviewCount
}
@Watch('tableDataOptions', { deep: true })
async getAccounts (val, oldVal) {
await this.getOrgs(val?.page, val?.itemsPerPage)
}
private async getOrgs (page: number = 1, pageLimit: number = this.numberOfItems) {
// set this variable so that the chip is shown
try {
this.orgFilter = {
statuses: [AccountStatus.PENDING_STAFF_REVIEW],
pageNumber: page,
pageLimit: pageLimit
}
const activeAccountsResp:any = await this.searchOrgs(this.orgFilter)
this.pendingOrgs = activeAccountsResp?.orgs
this.totalAccountsCount = activeAccountsResp?.total || 0
} catch (error) {
this.isTableLoading = false
// eslint-disable-next-line no-console
console.error(error)
}
}
private getIndexedTag (tag, index): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<v-data-table
class="user-list"
:headers="headerAccounts"
:items="rejectedStaffOrgs"
:items="rejectedOrgs"
:items-per-page.sync="tableDataOptions.itemsPerPage"
:hide-default-footer="rejectedStaffOrgs.length <= tableDataOptions.itemsPerPage"
:hide-default-footer="totalAccountsCount <= tableDataOptions.itemsPerPage"
:custom-sort="columnSort"
:no-data-text="$t('noActiveAccountsLabel')"
:footer-props="{
Expand All @@ -31,22 +31,21 @@
</template>

<script lang="ts">
import { Component, Mixins, Prop } from 'vue-property-decorator'
import { Component, Mixins, Prop, Watch } from 'vue-property-decorator'
import { OrgFilterParams, OrgList, Organization } from '@/models/Organization'
import { AccountStatus } from '@/util/constants'
import CommonUtils from '@/util/common-util'
import { DataOptions } from 'vuetify'
import { Organization } from '@/models/Organization'
import PaginationMixin from '@/components/auth/mixins/PaginationMixin.vue'
import { mapState } from 'vuex'
import { namespace } from 'vuex-class'
@Component({
computed: {
...mapState('staff', [
'rejectedStaffOrgs'
])
}
})
const StaffModule = namespace('staff')
@Component({})
export default class StaffRejectedAccountsTable extends Mixins(PaginationMixin) {
private readonly rejectedStaffOrgs!: Organization[]
@StaffModule.State('rejectedStaffOrgs') private rejectedStaffOrgs!: Organization[]
@StaffModule.Action('searchOrgs') private searchOrgs!: (filterParams: OrgFilterParams) => OrgList
@StaffModule.State('rejectedReviewCount') private rejectedReviewCount!: number
private columnSort = CommonUtils.customSort
Expand Down Expand Up @@ -82,6 +81,11 @@ export default class StaffRejectedAccountsTable extends Mixins(PaginationMixin)
private formatDate = CommonUtils.formatDisplayDate
private orgFilter: OrgFilterParams
private isTableLoading: boolean = false
private rejectedOrgs: Organization[] = []
private totalAccountsCount = 0
private getIndexedTag (tag, index): string {
return `${tag}-${index}`
}
Expand All @@ -91,6 +95,30 @@ export default class StaffRejectedAccountsTable extends Mixins(PaginationMixin)
if (this.hasCachedPageInfo) {
this.tableDataOptions = this.getAndPruneCachedPageInfo()
}
this.rejectedOrgs = this.rejectedStaffOrgs
this.totalAccountsCount = this.rejectedReviewCount
}
@Watch('tableDataOptions', { deep: true })
async getAccounts (val, oldVal) {
await this.getOrgs(val?.page, val?.itemsPerPage)
}
private async getOrgs (page: number = 1, pageLimit: number = this.numberOfItems) {
try {
this.orgFilter = {
statuses: [AccountStatus.REJECTED],
pageNumber: page,
pageLimit: pageLimit
}
const activeAccountsResp:any = await this.searchOrgs(this.orgFilter)
this.rejectedOrgs = activeAccountsResp?.orgs
this.totalAccountsCount = activeAccountsResp?.total || 0
} catch (error) {
this.isTableLoading = false
// eslint-disable-next-line no-console
console.error(error)
}
}
private view (item) {
Expand Down
28 changes: 23 additions & 5 deletions auth-web/src/store/modules/staff.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AccountType, GLCode, ProductCode } from '@/models/Staff'
import { Action, Module, Mutation, VuexModule } from 'vuex-module-decorators'
import { MembershipType, OrgFilterParams, Organization } from '@/models/Organization'

import { AccountStatus } from '@/util/constants'
import { Address } from '@/models/address'
import { AffidavitInformation } from '@/models/affidavit'
Expand Down Expand Up @@ -31,6 +32,8 @@ export default class StaffModule extends VuexModule {
accountUnderReviewAdminContact: Contact
accountUnderReviewAffidavitInfo: AffidavitInformation
suspendedReviewTotal: number = 0
pendingReviewTotal: number = 0
rejectedReviewTotal: number = 0

public get accountNotaryName (): string {
return this.accountUnderReviewAffidavitInfo?.issuer || '-'
Expand All @@ -41,11 +44,11 @@ export default class StaffModule extends VuexModule {
}

public get pendingReviewCount (): number {
return this.pendingStaffOrgs?.length || 0
return this.pendingReviewTotal || 0
}

public get rejectedReviewCount (): number {
return this.rejectedStaffOrgs?.length || 0
return this.rejectedReviewTotal || 0
}

public get pendingInvitationsCount (): number {
Expand Down Expand Up @@ -121,6 +124,16 @@ export default class StaffModule extends VuexModule {
this.suspendedReviewTotal = count
}

@Mutation
public setRejectedReviewCount (count: number) {
this.rejectedReviewTotal = count
}

@Mutation
public setPendingReviewCount (count: number) {
this.pendingReviewTotal = count
}

@Action({ commit: 'setProducts', rawError: true })
public async getProducts (): Promise<ProductCode[]> {
const response = await StaffService.getProducts()
Expand Down Expand Up @@ -196,18 +209,23 @@ export default class StaffModule extends VuexModule {

@Action({ commit: 'setPendingStaffOrgs', rawError: true })
public async syncPendingStaffOrgs () {
const response = await StaffService.getStaffOrgs(AccountStatus.PENDING_STAFF_REVIEW)
const response:any = await StaffService.getStaffOrgs(AccountStatus.PENDING_STAFF_REVIEW)
this.context.commit('setPendingReviewCount', response?.data?.total)
return response?.data?.orgs || []
}

@Action({ commit: 'setRejectedStaffOrgs', rawError: true })
public async syncRejectedStaffOrgs () {
const response = await StaffService.getStaffOrgs(AccountStatus.REJECTED)
const response:any = await StaffService.getStaffOrgs(AccountStatus.REJECTED)
this.context.commit('setRejectedReviewCount', response?.data?.total)
return response?.data?.orgs || []
}
@Action({ commit: 'setSuspendedStaffOrgs', rawError: true })
public async syncSuspendedStaffOrgs () {
const response:any = await StaffService.getStaffOrgs(AccountStatus.NSF_SUSPENDED)
const orgFilter = {
statuses: [AccountStatus.NSF_SUSPENDED, AccountStatus.SUSPENDED]
}
const response:any = await StaffService.searchOrgs(orgFilter)
this.context.commit('setSuspendedReviewCount', response?.data?.total)
return response?.data?.orgs || []
}
Expand Down

0 comments on commit 85388f6

Please sign in to comment.