Skip to content

Commit

Permalink
UI - hosts/strata, permit dash payment due issue (#393)
Browse files Browse the repository at this point in the history
* UI - hosts/strata, permit dash payment due issue

Signed-off-by: Kial Jinnah <kialj876@gmail.com>

* UI - Hosts update comp party functionality

Signed-off-by: Kial Jinnah <kialj876@gmail.com>

---------

Signed-off-by: Kial Jinnah <kialj876@gmail.com>
  • Loading branch information
kialj876 authored Dec 13, 2024
1 parent 8359374 commit 68dace9
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 13 deletions.
8 changes: 7 additions & 1 deletion strr-base-web/app/composables/useStrrApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,17 @@ export const useStrrApi = () => {
})
}

const updatePaymentDetails = async <T extends ApiApplicationBaseResp>(applicationNumber: string) => {
return await $strrApi<T>(`/applications/${applicationNumber}/payment-details`,
{ method: 'PUT' })
}

return {
getAccountRegistrations,
getAccountApplications,
getApplicationReceipt,
getRegistrationCert,
postApplication
postApplication,
updatePaymentDetails
}
}
7 changes: 6 additions & 1 deletion strr-base-web/app/composables/useStrrBasePermit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const useStrrBasePermit = <R extends ApiRegistrationResp, A extends ApiAp
getAccountApplications,
getAccountRegistrations,
getApplicationReceipt,
getRegistrationCert
getRegistrationCert,
updatePaymentDetails
} = useStrrApi()

// Typescript not unwrapping the generic ref properly without the 'as ...'
Expand All @@ -34,6 +35,10 @@ export const useStrrBasePermit = <R extends ApiRegistrationResp, A extends ApiAp
if (applicationId) {
// Get specific application
application.value = await getAccountApplications<A>(applicationId) as A
if (application.value.header.status === ApplicationStatus.PAYMENT_DUE) {
// there is a lag in the payment Q, trigger the strr api to grab the most current pay details
application.value = await updatePaymentDetails<A>(applicationId)
}
if (application.value?.header.registrationId) {
// Get linked registration if applicable
registration.value = await getAccountRegistrations<R>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,9 @@ defineEmits<{
}>()
const ownerStore = useHostOwnerStore()
const { hostOwners, hasCompParty } = storeToRefs(ownerStore)
const isCompParty = ref(owner.value.isCompParty)
watch(isCompParty, (val) => {
if (val && hasCompParty.value) {
// if a different owner has it set to true as well then set the old one to false
const compPartyIndex = ownerStore.findCompPartyIndex()
// @ts-expect-error - ts doesn't recognize that the value must be defined in this case
hostOwners.value[compPartyIndex].isCompParty = false
}
// set owner isCompParty and update the name with user creds
owner.value.isCompParty = val
ownerStore.SetOwnerNameWithUserCreds(owner)
Expand Down
2 changes: 1 addition & 1 deletion strr-host-pm-web/app/middleware/create-account-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default defineNuxtRouteMiddleware(() => {
const localePath = useLocalePath()
return navigateTo({ path: localePath('/auth/account/choose-existing') })
}
})
})
4 changes: 3 additions & 1 deletion strr-host-pm-web/app/pages/auth/account/choose-existing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ function handleAccountSwitch (id: string) {
icon="i-mdi-chevron-right"
trailing
:block="isSmallScreen"
:to="$keycloak.tokenParsed.loginSource === LoginSource.BCSC ? localePath('/auth/account/create-new') : useConnectNav().createAccountUrl()"
:to="$keycloak.tokenParsed.loginSource === LoginSource.BCSC
? localePath('/auth/account/create-new')
: useConnectNav().createAccountUrl()"
:external="$keycloak.tokenParsed.loginSource !== LoginSource.BCSC"
:target="$keycloak.tokenParsed.loginSource === LoginSource.BCSC ? '_self' : '_blank'"
/>
Expand Down
11 changes: 11 additions & 0 deletions strr-host-pm-web/app/stores/hostOwner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,17 @@ export const useHostOwnerStore = defineStore('host/owner', () => {
const hasPropertyManager = computed(() => !!findByRole(OwnerRole.PROPERTY_MANAGER))
const hasCompParty = computed(() => findCompPartyIndex() !== -1)

const checkCompParty = (owner: HostOwner) => {
const compPartyIndex = findCompPartyIndex()
if (owner.isCompParty && compPartyIndex !== -1) {
// if a different owner has it set to true as well then set the old one to false
// @ts-expect-error - ts doesn't recognize that the value must be defined in this case
hostOwners.value[compPartyIndex].isCompParty = false
}
}

const addHostOwner = (owner: HostOwner) => {
checkCompParty(owner)
hostOwners.value.push(owner)
}

Expand All @@ -78,6 +88,7 @@ export const useHostOwnerStore = defineStore('host/owner', () => {
}

const updateHostOwner = (owner: HostOwner, index: number) => {
checkCompParty(owner)
hostOwners.value.splice(index, 1, owner)
}

Expand Down
2 changes: 1 addition & 1 deletion strr-host-pm-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "strr-host-pm-web",
"private": true,
"type": "module",
"version": "0.0.7",
"version": "0.0.8",
"scripts": {
"build-check": "nuxt build",
"build": "nuxt generate",
Expand Down
2 changes: 1 addition & 1 deletion strr-strata-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "strr-strata-web",
"private": true,
"type": "module",
"version": "0.0.17",
"version": "0.0.18",
"scripts": {
"build-check": "nuxt build",
"build": "nuxt generate",
Expand Down

0 comments on commit 68dace9

Please sign in to comment.