Skip to content

Commit

Permalink
Merge pull request #147 from dimak1/feat/info-modal
Browse files Browse the repository at this point in the history
Add Modal for Account Setup Help
  • Loading branch information
dimak1 authored Sep 20, 2024
2 parents 61d7d68 + b671a66 commit ae88713
Show file tree
Hide file tree
Showing 14 changed files with 244 additions and 16 deletions.
44 changes: 44 additions & 0 deletions strr-web/components/common/BcrosContactInfo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<script setup lang="ts">
const { t } = useTranslation()
</script>

<template>
<div class="flex flex-col" data-test-id="contact-info">
<div class="contact-info-detail d:items-center">
<UIcon name="i-mdi-phone" class="m:w-[20px] m:mt-1" />
<span>{{ t('bcrosContactInfo.tollFree.label') }}
<a :href="`tel:${t('bcrosContactInfo.tollFree.value')}`">
{{ t('bcrosContactInfo.tollFree.value') }}
</a>
</span>
</div>
<div class="contact-info-detail items-center">
<UIcon name="i-mdi-phone" />
<span>{{ t('bcrosContactInfo.local.label') }}
<a :href="`tel:${t('bcrosContactInfo.local.value')}`">
{{ t('bcrosContactInfo.local.value') }}
</a>
</span>
</div>
<div class="contact-info-detail items-center">
<UIcon name="i-mdi-email" />
<span>{{ t('bcrosContactInfo.email.label') }}
<a :href="`mailto:${t('bcrosContactInfo.email.value')}`">
{{ t('bcrosContactInfo.email.value') }}
</a>
</span>
</div>
</div>
</template>

<style lang="scss" scoped>
.contact-info-detail {
@apply flex space-x-2;
}
a {
@apply break-keep whitespace-nowrap;
}
.iconify {
@apply bg-bcGovColor-nonClickable;
}
</style>
86 changes: 86 additions & 0 deletions strr-web/components/common/InfoModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<script setup lang="ts">
import BcrosContactInfo from '~/components/common/BcrosContactInfo.vue'
const { t } = useTranslation()
const isOpen = ref(false)
const props = defineProps<{
header: string
openButtonLabel?: string
openButtonIcon?: string
hideContactInfo?: boolean
}>()
const { header, hideContactInfo = false, openButtonLabel, openButtonIcon = 'i-mdi-help-circle-outline' } = props
const handleCloseModal = () => {
isOpen.value = false
}
// allow ESC to close the modal
defineShortcuts({
escape: {
usingInput: true,
whenever: [isOpen],
handler: () => {
isOpen.value = false
}
}
})
</script>

<template>
<div data-test-id="info-modal-container">
<UButton
v-if="openButtonLabel"
data-test-id="info-modal-open-button"
class="p-0 text-base"
variant="ghost"
:label="openButtonLabel"
:leading-icon="openButtonIcon"
:ui="{ variant: { ghost: 'hover:bg-transparent' } }"
@click="isOpen = true"
/>
<UModal
v-model="isOpen"
prevent-close
data-test-id="info-modal"
:ui="{
container: 'items-center',
base: 'p-10',
overlay: { background: 'bg-black/60' },
width: 'w-[660px]',
rounded: 'rounded-md'
}"
>
<div class="flex justify-between mb-11">
<BcrosTypographyH2 :text="header" class="pt-0 pb-0" data-test-id="info-modal-header" />
<UButton
color="gray"
variant="ghost"
icon="i-mdi-close"
class="p-0"
size="xl"
@click="isOpen = false"
/>
</div>

<div data-test-id="info-modal-default-slot">
<slot />
</div>

<BcrosContactInfo v-if="!hideContactInfo" />

<div
class="flex justify-center mt-10"
data-test-id="info-modal-action-buttons"
>
<BcrosButtonsPrimary
:label="t('common.baseModal.closeButtonLabel')"
:action="() => handleCloseModal()"
/>
</div>
</UModal>
</div>
</template>
4 changes: 2 additions & 2 deletions strr-web/composables/useBreadcrumb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export const useBreadcrumb = () => {
setRegistrationNumber(application?.header.registrationNumber)
}

// Remove '-id' suffix and language codes (e.g., '___en') from route names to match RouteNamesE enum values
// Remove '-id' suffix from route names to match RouteNamesE enum values
const cleanupRoute = (routeName: string) => {
return routeName?.replace(/(-id|___\w{2}$)/g, '') as RouteNamesE
return routeName?.replace(/(-id)/g, '') as RouteNamesE
}

/**
Expand Down
22 changes: 22 additions & 0 deletions strr-web/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"hostDashboard": "My STR Registry Dashboard",
"examinerDashboard": "My CEU STR Registry Dashboard",
"rentalRegistration": "Short-Term Rental Registration"
},
"baseModal": {
"closeButtonLabel": "Close"
}
},
"registryDashboard": {
Expand Down Expand Up @@ -361,6 +364,11 @@
"subTitle": "Select an account below or create a new one",
"useAccountButton": "Use this account",
"createAccountButton": "Create account"
},
"helpModal": {
"header": "Need Help?",
"openButtonLabel": "Help with setting up an account",
"contactUs": "If you need help with setting up your BC Registries and Online Services account, please contact us."
}
},
"header": {
Expand Down Expand Up @@ -420,5 +428,19 @@
"bceid": "BCeID",
"idir": "IDIR"
}
},
"bcrosContactInfo": {
"tollFree": {
"label": "Canada and U.S. Toll Free:",
"value": "1-877-370-1033"
},
"local": {
"label": "Victoria Office:",
"value": "250-370-1033"
},
"email": {
"label": "Email:",
"value": "BCRegistries{'@'}gov.bc.ca"
}
}
}
3 changes: 2 additions & 1 deletion strr-web/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export default defineNuxtConfig({
langDir: './lang',
locales: [
{ code: 'en', file: 'en.json' }
]
],
strategy: 'no_prefix' // routes won't have a locale prefix __en
},
eslint: {
/* module options */
Expand Down
2 changes: 1 addition & 1 deletion strr-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "strr-web",
"version": "0.1.26",
"version": "0.1.27",
"description": "Short Term Rental Registration UI - Mono repo workspace",
"scripts": {
"preinstall": "npx only-allow pnpm",
Expand Down
16 changes: 13 additions & 3 deletions strr-web/pages/account-select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,33 @@
<div data-test-id="account-select-page">
<div v-if="userOrgs.length > 0">
<div class="mobile:px-[8px]">
<BcrosTypographyH1 :text="t('account.title')" data-test-id="accountPageTitle" class="mobile:pb-[20px]" />
<BcrosTypographyH1 :text="t('account.title')" data-test-id="account-page-title" class="mobile:pb-[20px]" />
<InfoModal
:header="t('account.helpModal.header')"
:open-button-label="t('account.helpModal.openButtonLabel')"
class="mb-6"
>
<p class="mb-10">
{{ t('account.helpModal.contactUs') }}
</p>
</InfoModal>
<BcrosAlertsMessage :flavour="alertFlavour">
<b>{{ t('general.note') }} </b>{{ t('account.existingAccountWarning') }}
</BcrosAlertsMessage>
<BcrosTypographyH2 :text="existingAccountsTitle" data-test-id="accountPageAccountSectionTitle" />
<BcrosTypographyH2 :text="existingAccountsTitle" data-test-id="account-page-sub-title" />
<span class="text-[16px] mb-[20px] block">{{ t('account.existingAccountSection.subTitle') }}</span>
</div>
<BcrosExistingAccountsList :accounts="userOrgs" />
</div>
<div v-else>
<BcrosTypographyH1 :text="t('account.logIn')" data-test-id="accountPageTitle" class="mobile:pb-[20px]" />
<BcrosTypographyH1 :text="t('account.logIn')" data-test-id="account-page-title" class="mobile:pb-[20px]" />
</div>
</div>
</template>

<script setup lang="ts">
import { AlertsFlavourE } from '#imports'
import InfoModal from '~/components/common/InfoModal.vue'
const { t } = useTranslation()
Expand Down
4 changes: 2 additions & 2 deletions strr-web/pages/application-status.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div data-test-id="account-select-page">
<div data-test-id="application-status-page">
<BcrosTypographyH1
:text="tRegistrationStatus('title')"
data-test-id="accountPageTitle"
data-test-id="account-page-title"
class="pb-[32px] mobile:pb-[24px]"
/>
<div>
Expand Down
2 changes: 1 addition & 1 deletion strr-web/pages/create-account-pre/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="mobile:px-[8px]">
<BcrosTypographyH1
:text="t('createAccount.title')"
data-test-id="accountPageTitle"
data-test-id="account-page-title"
class="mobile:pb-[20px]"
/>
<BcrosStepper
Expand Down
10 changes: 10 additions & 0 deletions strr-web/pages/finalization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
<p class="mb-[20px] mobile:px-[8px]">
{{ tFinalization('subtitle') }}
</p>
<InfoModal
:header="t('account.helpModal.header')"
:open-button-label="t('account.helpModal.openButtonLabel')"
class="mb-6"
>
<p class="mb-10">
{{ t('account.helpModal.contactUs') }}
</p>
</InfoModal>
<div class="desktop:mb-[132px] mobile:mb-[40px] pb-[32px] bg-white rounded-[4px] padding-[40px]">
<div class="bg-bcGovColor-gray2 rounded-t-[4px]">
<p class="px-[40px] mobile:px-[8px] py-[15px] font-bold">
Expand Down Expand Up @@ -102,6 +111,7 @@

<script setup lang="ts">
import { SbcCreationResponseE } from '~/enums/sbc-creation-response-e'
import InfoModal from '~/components/common/InfoModal.vue'
const { t } = useTranslation()
const tFinalization = (translationKey: string) => t(`finalization.${translationKey}`)
Expand Down
4 changes: 2 additions & 2 deletions strr-web/pages/listing-details/[listingId].vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div data-test-id="account-select-page">
<div data-test-id="listing-details-page">
<BcrosTypographyH1
:text="tApplicationConfirm('submitted')"
data-test-id="accountPageTitle"
data-test-id="account-page-title"
class="mobile:pb-[20px] mobile:mx-[8px] pb-[32px]"
/>
<div class="bg-white py-[22px] px-[30px] flex flex-row mobile:px-[8px] mobile:[py-16px] mobile:flex-col">
Expand Down
4 changes: 2 additions & 2 deletions strr-web/pages/success/[id].vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div data-test-id="account-select-page">
<div data-test-id="application-submitted-page">
<BcrosTypographyH1
:text="tApplicationConfirm('submitted')"
data-test-id="accountPageTitle"
data-test-id="account-page-title"
class="mobile:pb-[20px] mobile:mx-[8px] pb-[32px]"
/>
<div class="bg-white py-[22px] px-[30px] flex flex-row mobile:px-[8px] mobile:[py-16px] mobile:flex-col">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div data-test-id="account-select-page">
<div data-test-id="invoice-page">
<BcrosTypographyH1
:text="tApplicationConfirm('submitted')"
data-test-id="accountPageTitle"
data-test-id="account-page-title"
class="mobile:pb-5 mobile:mx-2 pb-8"
/>
<div class="bg-white py-[22px] px-[30px] flex flex-row mobile:px-2 mobile:[py-16px] mobile:flex-col">
Expand Down
55 changes: 55 additions & 0 deletions strr-web/tests/unit/components/BaseModal.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { mountSuspended } from '@nuxt/test-utils/runtime'
import InfoModal from '~/components/common/InfoModal.vue'

const { t } = useTranslation()

const MODAL_HEADER = 'Main Header'
const MODAL_OPEN_LABEL = 'Open Modal'

describe('Base Modal Tests', () => {
it('should render modal with its components and content', async () => {
const wrapper = await mountSuspended(InfoModal, {
props: {
header: MODAL_HEADER,
openButtonLabel: MODAL_OPEN_LABEL
},
slots: {
default: () => '<div>Main Content</div>'
}
})

expect(wrapper.exists()).toBeTruthy()

// check H2 header
expect(wrapper.find('[data-test-id="info-modal-header"]').exists()).toBeFalsy()

// check open modal button label
const openModalButton = wrapper.find('[data-test-id="info-modal-open-button"]')
expect(openModalButton.exists()).toBeTruthy()
expect(openModalButton.text()).toBe(MODAL_OPEN_LABEL)

// modal is not open
expect(document.querySelector('[data-test-id="info-modal"]')).toBeFalsy()

openModalButton.trigger('click')
await nextTick()

const modal = document.querySelector('[data-test-id="info-modal"]')

// modal is open
expect(modal).toBeTruthy()

const modalHeader = modal?.querySelector('[data-test-id="info-modal-header"]')?.innerHTML
expect(modalHeader).toContain(MODAL_HEADER)

const modalDefaultSlot = modal?.querySelector('[data-test-id="info-modal-default-slot"]')?.innerHTML
expect(modalDefaultSlot).toContain('Main Content')

const modalContactInfo = modal?.querySelector('[data-test-id="contact-info"]')?.innerHTML
expect(modalContactInfo).toContain(t('bcrosContactInfo.tollFree.value'))

const modalActions = modal?.querySelector('[data-test-id="info-modal-action-buttons"]')?.innerHTML
expect(modalActions).toBeTruthy()
expect(modalActions).toContain(t('common.baseModal.closeButtonLabel'))
})
})

0 comments on commit ae88713

Please sign in to comment.