Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20929 - Implemented GET involuntary dissolution configurations endpoint #2819

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions auth-web/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 auth-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auth-web",
"version": "2.6.9",
"version": "2.6.10",
"appName": "Auth Web",
"sbcName": "SBC Common Components",
"private": true,
Expand Down
65 changes: 20 additions & 45 deletions auth-web/src/components/auth/staff/DissolutionSchedule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
>
<v-text-field
ref="numberOfBusinessesRef"
v-model="numberOfBusinesses"
v-model="numberOfBusinessesEdit"
filled
type="number"
label="Dissolution Batch Size"
Expand Down Expand Up @@ -79,7 +79,7 @@
large
outlined
class="mr-3"
@click="cancelBtnClicked()"
@click="triggerEditOnOff()"
>
Cancel
</v-btn>
Expand All @@ -103,62 +103,45 @@ import { useStaffStore } from '@/stores/staff'
export default defineComponent({
name: 'DissolutionSchedule',
emits: ['update:onHold'],
setup (_, { emit }) {
setup () {
const state = reactive({
menu: false,
numberOfBusinesses: 0,
numberOfBusinessesEdit: 0,
numberOfBusinessesNonEdit: 0,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, this looks weird (having two properties that look similar). I have an explanation though 😆

The idea is, when the edit panel is open, the schedule summary is going to be reactive to what's being typed in the text field. However, when it is not open, it's going to be what the DB is returning of the current job batch size.

So, I decided to separate those fields. One of the biggest reasons is that, in doing so, I can store the current batch size from the GET call into the nonEdit field. This way, I only need to use the GET call once on mount. Otherwise, I have to do the GET call each time cancel or save is clicked which is really not good haha

Also, this provides so much flexibility and it separates of when the edit panel is open or not.

numberOfBusinessesRef: null,
isEdit: false,
isOnHold: false
isEdit: false
})
const staffStore = useStaffStore()
/**
* Set local properties to values from the store.
* TODO: Update once BE work is done.
*/
onMounted(() => {
state.numberOfBusinesses = staffStore.getDissolutionBatchSize()
state.isOnHold = staffStore.isDissolutionBatchOnHold()
})
/** Set local properties to values from the store. */
onMounted(async () => {
// Make the call to get the involuntary dissolution configurations array and set it in store.
await staffStore.getDissolutionConfigurations()
/**
* Update whether the dissolution batch is paused or running.
* Emit the status to the parent to know whether the "Paused" badge is going to be shown.
* TODO: Modify/Update this once the BE is done.
*/
const actionBtnClicked = (): void => {
state.isOnHold = !staffStore.isDissolutionBatchOnHold()
// Emit whether on hold or not to the parent.
emit('update:onHold', state.isOnHold)
staffStore.updateDissolutionBatchOnHold(!staffStore.isDissolutionBatchOnHold())
}
// Get the batch size current value (number of businesses to be dissolved per job run)
const numDissolutions = staffStore.involuntaryDissolutionConfigurations.configurations.find(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what the BE will return:
config array

So, with minimal code, I thought this is the easiest and most straight forward way to get to the value I need.

config => config.name === 'NUM_DISSOLUTIONS_ALLOWED').value
state.numberOfBusinessesNonEdit = parseInt(numDissolutions)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I mentioned above. Basically, after making the call which will be made ONCE on mount, I'm storing that value here.

})
/** Edit, Cancel, or Save (successful) button is clicked. */
const triggerEditOnOff = (): void => {
// set text field value
state.numberOfBusinessesEdit = state.numberOfBusinessesNonEdit
state.isEdit = !state.isEdit
// closing the menu
state.menu = false
}
/**
* Cancel button clicked.
* Revert numberOfBusinesses to store value. Hide the edit components.
*/
const cancelBtnClicked = (): void => {
state.numberOfBusinesses = staffStore.getDissolutionBatchSize()
triggerEditOnOff()
}
/**
* Save button is clicked. Update the dissolution batch size.
* Only save if the inputted number is valid.
* TODO: Implement logic (job) once the BE is done.
*/
const saveBtnClicked = (): void => {
if (state.numberOfBusinessesRef.validate()) {
staffStore.updateDissolutionBatchSize(state.numberOfBusinesses)
// staffStore.updateDissolutionBatchSize(state.numberOfBusinesses)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FUTURE: When I work on the PUT.

state.numberOfBusinessesNonEdit = state.numberOfBusinessesEdit
triggerEditOnOff()
}
}
Expand All @@ -173,24 +156,16 @@ export default defineComponent({
]
})
/** The action button text depending on whether the dissolution job is paused or running. */
const actionBtnText = computed(() => {
return state.isOnHold ? 'Resume' : 'Pause'
})
/**
* If non-edit, show the number of businesses into D1 from the store.
* Otherwise, it'll be reactive to whatever is being typed in the text field.
*/
const scheduleSummaryNumber = computed(() => {
return state.isEdit ? state.numberOfBusinesses : staffStore.getDissolutionBatchSize()
return state.isEdit ? state.numberOfBusinessesEdit : state.numberOfBusinessesNonEdit
})
return {
...toRefs(state),
actionBtnClicked,
actionBtnText,
cancelBtnClicked,
dissolutionBatchSizeRules,
triggerEditOnOff,
saveBtnClicked,
Expand Down
12 changes: 9 additions & 3 deletions auth-web/src/models/Staff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ export interface FilingTypeResponse {
items: FilingType[]
}

export interface InvoluntaryDissolutionIF {
batchSize: number
onHold: boolean
export interface InvoluntaryDissolutionConfigurationIF {
fullDescription: string
name: string
shortDescription: string
value: string
}

export interface Configurations {
configurations: InvoluntaryDissolutionConfigurationIF[]
}
6 changes: 5 additions & 1 deletion auth-web/src/services/staff.services.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AccountType, ProductCode, Products, ProductsRequestBody } from '@/models/Staff'
import { AccountType, Configurations, ProductCode, Products, ProductsRequestBody } from '@/models/Staff'
import { OrgFilterParams, OrgList, Organizations } from '@/models/Organization'
import { AxiosResponse } from 'axios'
import ConfigHelper from '@/util/config-helper'
Expand Down Expand Up @@ -48,4 +48,8 @@ export default class StaffService {
static async getSafeEmails (): Promise<AxiosResponse<SafeEmail[]>> {
return axios.get(`${ConfigHelper.getNotifiyAPIUrl()}/safe_list`)
}

static async getInvoluntaryDissolutionConfigurations (): Promise<AxiosResponse<Configurations>> {
return axios.get(`${ConfigHelper.getLegalAPIV2Url()}/admin/configurations`)
}
}
37 changes: 14 additions & 23 deletions auth-web/src/stores/staff.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AccountStatus, AffidavitStatus, TaskAction, TaskRelationshipStatus, TaskRelationshipType, TaskType } from '@/util/constants'
import { AccountType, GLCode, InvoluntaryDissolutionIF, ProductCode } from '@/models/Staff'
import { AccountType, Configurations, GLCode, ProductCode } from '@/models/Staff'
import { MembershipType, OrgFilterParams, Organization } from '@/models/Organization'
import { SyncAccountPayload, Task } from '@/models/Task'
import { computed, reactive, toRefs } from '@vue/composition-api'
Expand All @@ -25,7 +25,7 @@ export const useStaffStore = defineStore('staff', () => {
accountUnderReviewAdminContact: {} as Contact,
accountUnderReviewAffidavitInfo: {} as AffidavitInformation,
activeStaffOrgs: [] as Organization[],
involuntaryDissolutionBatch: {} as InvoluntaryDissolutionIF,
involuntaryDissolutionConfigurations: {} as Configurations,
pendingInvitationOrgs: [] as Organization[],
pendingStaffOrgs: [] as Organization[],
products: [] as ProductCode[],
Expand All @@ -42,7 +42,7 @@ export const useStaffStore = defineStore('staff', () => {
state.accountUnderReviewAdminContact = {} as Contact
state.accountUnderReviewAffidavitInfo = {} as AffidavitInformation
state.activeStaffOrgs = [] as Organization[]
state.involuntaryDissolutionBatch = {} as InvoluntaryDissolutionIF
state.involuntaryDissolutionConfigurations = {} as Configurations
state.pendingInvitationOrgs = [] as Organization[]
state.pendingStaffOrgs = [] as Organization[]
state.products = [] as ProductCode[]
Expand Down Expand Up @@ -80,14 +80,13 @@ export const useStaffStore = defineStore('staff', () => {
}
}

/** TODO: Implement the call from BE to grab this number. */
function getDissolutionBatchSize (): number {
return state.involuntaryDissolutionBatch.batchSize || 0
}

/** TODO: Implement the call from BE to grab the status. */
function isDissolutionBatchOnHold (): boolean {
return state.involuntaryDissolutionBatch.onHold || false
/** Get the involuntary dissolution configurations array from Legal API. */
async function getDissolutionConfigurations (): Promise<Configurations> {
const response = await StaffService.getInvoluntaryDissolutionConfigurations()
if (response?.data && response.status === 200) {
state.involuntaryDissolutionConfigurations = response.data
return response.data
}
}

async function getAccountTypes (): Promise<AccountType[]> {
Expand Down Expand Up @@ -293,23 +292,17 @@ export const useStaffStore = defineStore('staff', () => {
}

/** TODO: Make the backend call to the number of businesses to be dissolved. */
function updateDissolutionBatchSize (dissolutionBatchSize: number) {
state.involuntaryDissolutionBatch.batchSize = dissolutionBatchSize
}

/** TODO: Make the backend call to the number of businesses to be dissolved. */
function updateDissolutionBatchOnHold (onHold: boolean) {
state.involuntaryDissolutionBatch.onHold = onHold
}
// function updateDissolutionBatchSize (dissolutionBatchSize: number) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented this out for now. Will uncomment next PR.

// state.involuntaryDissolutionBatch.batchSize = dissolutionBatchSize
// }

return {
accountNotaryContact,
accountNotaryName,
approveAccountUnderReview,
deleteOrg,
getAccountTypes,
getDissolutionBatchSize,
isDissolutionBatchOnHold,
getDissolutionConfigurations,
getGLCode,
getGLCodeList,
getGLCodeFiling,
Expand All @@ -330,8 +323,6 @@ export const useStaffStore = defineStore('staff', () => {
syncSuspendedStaffOrgs,
syncPendingStaffOrgs,
updateGLCodeFiling,
updateDissolutionBatchSize,
updateDissolutionBatchOnHold,
$reset
}
})
18 changes: 4 additions & 14 deletions auth-web/src/views/auth/staff/InvoluntaryDissolution.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@
badgeText="Paused"
icon="mdi-calendar-clock"
label="Automated Dissolution Schedule"
:showBadge="isOnHold"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all badge logic here as designs have changed. No more badge.

/>
<DissolutionSchedule
@update:onHold="isOnHold=$event"
/>
<DissolutionSchedule />
</v-card>
</v-col>
</v-row>
Expand All @@ -58,10 +55,9 @@
</template>

<script lang="ts">
import { computed, defineComponent, onMounted, ref } from '@vue/composition-api'
import { computed, defineComponent, onMounted } from '@vue/composition-api'
import { CardHeader } from '@/components'
import DissolutionSchedule from '@/components/auth/staff/DissolutionSchedule.vue'
import { useStaffStore } from '@/stores/staff'

export default defineComponent({
name: 'InvoluntaryDissolution',
Expand All @@ -70,12 +66,7 @@ export default defineComponent({
DissolutionSchedule
},
setup () {
const isOnHold = ref<boolean>(false)
const staffStore = useStaffStore()

onMounted(() => {
isOnHold.value = staffStore.isDissolutionBatchOnHold()
})
onMounted(() => {})

/**
* The number of B.C. businesses that are ready for D1 Dissolution.
Expand All @@ -84,8 +75,7 @@ export default defineComponent({
const businessesReadyforDissolutionNumber = computed(() => 0)

return {
businessesReadyforDissolutionNumber,
isOnHold
businessesReadyforDissolutionNumber
}
}
})
Expand Down
Loading