Skip to content

Commit

Permalink
25239 pad confirmation period (#462)
Browse files Browse the repository at this point in the history
* UI - handling for pad confirmation period

Signed-off-by: Kial Jinnah <[email protected]>

* cleanup

Signed-off-by: Kial Jinnah <[email protected]>

---------

Signed-off-by: Kial Jinnah <[email protected]>
  • Loading branch information
kialj876 authored Jan 16, 2025
1 parent 348267f commit 54685e5
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 21 deletions.
11 changes: 8 additions & 3 deletions strr-base-web/app/composables/useStrrModals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,21 @@ export const useStrrModals = () => {
})
}

function openConfirmSwitchAccountModal (newAccountId: string) {
function openConfirmSwitchAccountModal (newAccountId: string, localPath?: string) {
modal.open(ModalBase, {
title: t('modal.changeAccountConfirm.title'),
content: t('modal.changeAccountConfirm.content'),
actions: [
{
label: t('modal.changeAccountConfirm.leaveBtn'),
handler: () => {
handler: async () => {
accountStore.switchCurrentAccount(newAccountId)
handleExternalRedirect(config.registryHomeURL + 'dashboard')
if (localPath) {
await navigateTo(localPath)
close()
} else {
handleExternalRedirect(config.registryHomeURL + 'dashboard')
}
}
},
{
Expand Down
5 changes: 5 additions & 0 deletions strr-base-web/app/enums/connect-pay-cfs-status.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum ConnectPayCfsStatus {
PENDING = 'PENDING',
PENDING_PAD_ACTIVATION = 'PENDING_PAD_ACTIVATION'
// TODO: fill these out as needed
}
4 changes: 4 additions & 0 deletions strr-base-web/app/locales/en-CA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ export default {
content: 'Any personal information required is collected to support the administration and enforcement of the {straAct}, under the authority of section 33(1) of that Act. Any questions about the collection of any information can be directed to the Executive Director of the Short-Term Rental Branch, at {email}.'
}
},
padConfirmationPeriod: {
title: 'PAD Account in Confirmation Period',
content: 'This account will not be able to perform any PAD transactions until the mandatory (3) day confirmation period has ended. Until then you may continue to pay using credit card.'
},
error: {
applicationSubmit: {
badRequest: {
Expand Down
30 changes: 28 additions & 2 deletions strr-base-web/app/stores/connectFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,42 @@ export const useConnectFeeStore = defineStore('connect/fee', () => {
}

// alternate payment option stuff
const PAD_PENDING_STATES = [ConnectPayCfsStatus.PENDING, ConnectPayCfsStatus.PENDING_PAD_ACTIVATION]
const userPaymentAccount = ref<ConnectPayAccount>({} as ConnectPayAccount)
const userSelectedPaymentMethod = ref<ConnectPaymentMethod>(ConnectPaymentMethod.DIRECT_PAY)
const allowAlternatePaymentMethod = ref<boolean>(false)
const allowedPaymentMethods = ref<{ label: string, value: ConnectPaymentMethod }[]>([])

watch(userSelectedPaymentMethod, () => {
// if pad in confirmation period then set selected payment to CC
if (PAD_PENDING_STATES.includes(userPaymentAccount.value?.cfsAccount?.status)) {
userSelectedPaymentMethod.value = ConnectPaymentMethod.DIRECT_PAY
// show modal for user
useStrrModals().openErrorModal(
t('modal.padConfirmationPeriod.title'),
t('modal.padConfirmationPeriod.content'),
false
)
}
})

const $resetAlternatePayOptions = () => {
userPaymentAccount.value = {} as ConnectPayAccount
userSelectedPaymentMethod.value = ConnectPaymentMethod.DIRECT_PAY
allowAlternatePaymentMethod.value = false
allowedPaymentMethods.value = []
}

const initAlternatePaymentMethod = async () => {
$resetAlternatePayOptions()
const accountId = useConnectAccountStore().currentAccount.id
try {
// get payment account
const res = await $payApi<ConnectPayAccount>(`/accounts/${accountId}`)
userPaymentAccount.value = res
userSelectedPaymentMethod.value = res.paymentMethod

// add options to allowedPaymentMethods
const defaultMethod = userPaymentAccount.value.paymentMethod
let defaultMethod = userPaymentAccount.value.paymentMethod
if (defaultMethod !== undefined) {
const accountNum = userPaymentAccount.value.cfsAccount?.bankAccountNumber ?? ''
allowedPaymentMethods.value.push({
Expand All @@ -144,8 +165,13 @@ export const useConnectFeeStore = defineStore('connect/fee', () => {
label: t(`ConnectFeeWidget.paymentMethod.${ConnectPaymentMethod.DIRECT_PAY}`),
value: ConnectPaymentMethod.DIRECT_PAY
})
// if pad in confirmation period then set default payment to CC
if (PAD_PENDING_STATES.includes(res.cfsAccount.status)) {
defaultMethod = ConnectPaymentMethod.DIRECT_PAY
}
}
}
userSelectedPaymentMethod.value = defaultMethod

// only set allowed flag to true if previous steps didnt cause an error
allowAlternatePaymentMethod.value = true
Expand Down
2 changes: 1 addition & 1 deletion strr-base-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"vitest": "^1.6.0"
},
"dependencies": {
"@daxiom/nuxt-core-layer-test": "^0.0.20",
"@daxiom/nuxt-core-layer-test": "^0.0.21",
"@vuepic/vue-datepicker": "^10.0.0",
"country-codes-list": "^1.6.11",
"luxon": "^3.5.0",
Expand Down
8 changes: 4 additions & 4 deletions strr-base-web/pnpm-lock.yaml

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

11 changes: 10 additions & 1 deletion strr-host-pm-web/app/pages/application.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const loading = ref(false)
const {
addReplaceFee,
getFee,
initAlternatePaymentMethod,
removeFee,
setPlaceholderFilingTypeCode,
setPlaceholderServiceFee
Expand All @@ -40,6 +41,7 @@ const hostFee3 = ref<ConnectFeeItem | undefined>(undefined)
onMounted(async () => {
loading.value = true
await initAlternatePaymentMethod()
applicationReset()
if (applicationId.value) {
await permitStore.loadHostData(applicationId.value, true)
Expand Down Expand Up @@ -281,7 +283,14 @@ useHead({
definePageMeta({
layout: 'connect-form',
middleware: ['auth', 'require-account']
middleware: ['auth', 'require-account'],
onAccountChange: (_: Account, newAccount: Account) => {
useStrrModals().openConfirmSwitchAccountModal(
newAccount.id,
useLocalePath()('/dashboard')
)
return false
}
})
setBreadcrumbs([
Expand Down
2 changes: 2 additions & 0 deletions strr-host-pm-web/app/pages/dashboard/[applicationId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ definePageMeta({
middleware: ['auth', 'require-account'],
onAccountChange: async () => {
const { $router, $i18n } = useNuxtApp()
useStrrModals().openErrorModal('test', 'test', false)
await $router.push(`/${$i18n.locale.value}/dashboard`)
return true
}
Expand Down
4 changes: 2 additions & 2 deletions 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.38",
"version": "0.0.37",
"scripts": {
"build-check": "nuxt build",
"build": "nuxt generate",
Expand Down Expand Up @@ -44,7 +44,7 @@
"vitest": "^1.6.0"
},
"dependencies": {
"@daxiom/nuxt-core-layer-test": "^0.0.20",
"@daxiom/nuxt-core-layer-test": "^0.0.21",
"country-codes-list": "^1.6.11",
"lodash.uniqby": "^4.7.0",
"nuxt": "^3.15.0",
Expand Down
8 changes: 4 additions & 4 deletions strr-host-pm-web/pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion strr-platform-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "strr-platform-web",
"private": true,
"type": "module",
"version": "0.0.39",
"version": "0.0.40",
"scripts": {
"build-check": "nuxt build",
"build": "nuxt generate",
Expand Down
13 changes: 11 additions & 2 deletions strr-strata-web/app/pages/strata-hotel/application.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ const loading = ref(false)
const {
addReplaceFee,
getFee,
setPlaceholderFilingTypeCode
setPlaceholderFilingTypeCode,
initAlternatePaymentMethod
} = useConnectFeeStore()
const strataFee = ref<ConnectFeeItem | undefined>(undefined)
onMounted(async () => {
loading.value = true
await initAlternatePaymentMethod()
applicationReset()
if (applicationId.value) {
await permitStore.loadStrata(applicationId.value, true)
Expand Down Expand Up @@ -196,7 +198,14 @@ useHead({
definePageMeta({
layout: 'connect-form',
middleware: ['auth', 'require-account']
middleware: ['auth', 'require-account'],
onAccountChange: (_: Account, newAccount: Account) => {
useStrrModals().openConfirmSwitchAccountModal(
newAccount.id,
useLocalePath()('/strata-hotel/dashboard')
)
return false
}
})
setBreadcrumbs([
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.42",
"version": "0.0.43",
"scripts": {
"build-check": "nuxt build",
"build": "nuxt generate",
Expand Down

0 comments on commit 54685e5

Please sign in to comment.