From 0717a22dad630eb74d4ee80878161c90ece06e20 Mon Sep 17 00:00:00 2001 From: Kial Jinnah Date: Wed, 6 Nov 2024 11:25:32 -0500 Subject: [PATCH 1/4] UI - strata hotel application Signed-off-by: Kial Jinnah --- .../components/connect/form/address/Index.vue | 54 ++- .../components/connect/form/field/Group.vue | 2 +- .../components/connect/form/field/Index.vue | 6 +- .../app/composables/useCanadaPost.ts | 7 +- strr-platform-web/app/locales/en-CA.ts | 1 - strr-platform-web/package.json | 3 +- .../app/components/form/BusinessDetails.vue | 203 +++++++++++ .../app/components/form/ReviewConfirm.vue | 344 ++++++++++++++++++ .../app/components/form/StrataDetails.vue | 176 +++++++++ .../app/interfaces/strata-details.ts | 2 +- strr-strata-web/app/locales/en-CA.ts | 47 ++- strr-strata-web/app/pages/application.vue | 21 +- .../app/stores/strataApplication.ts | 14 +- strr-strata-web/app/stores/strataDetails.ts | 55 ++- strr-strata-web/nuxt.config.ts | 1 + strr-strata-web/package.json | 3 +- strr-strata-web/pnpm-lock.yaml | 12 + 17 files changed, 889 insertions(+), 62 deletions(-) create mode 100644 strr-strata-web/app/components/form/BusinessDetails.vue create mode 100644 strr-strata-web/app/components/form/ReviewConfirm.vue create mode 100644 strr-strata-web/app/components/form/StrataDetails.vue diff --git a/strr-base-web/app/components/connect/form/address/Index.vue b/strr-base-web/app/components/connect/form/address/Index.vue index 6b044f1d..7b5b0ed1 100644 --- a/strr-base-web/app/components/connect/form/address/Index.vue +++ b/strr-base-web/app/components/connect/form/address/Index.vue @@ -1,4 +1,6 @@ diff --git a/strr-strata-web/app/stores/strataApplication.ts b/strr-strata-web/app/stores/strataApplication.ts index 301aa1b7..78bf5e41 100644 --- a/strr-strata-web/app/stores/strataApplication.ts +++ b/strr-strata-web/app/stores/strataApplication.ts @@ -3,7 +3,6 @@ import type { MultiFormValidationResult, StrataApplicationPayload } from '#impor import { formatBusinessDetails, formatStrataDetails } from '~/utils/strata-formating' export const useStrrStrataApplicationStore = defineStore('strr/strataApplication', () => { - // TODO: WIP - updating for strata const { t } = useI18n() const { postApplication } = useStrrApi() const contactStore = useStrrContactStore() @@ -11,12 +10,12 @@ export const useStrrStrataApplicationStore = defineStore('strr/strataApplication const detailsStore = useStrrStrataDetailsStore() // TODO: update confirmation stuff for strata - const platformConfirmation = reactive({ + const confirmation = reactive({ confirmInfoAccuracy: false, confirmDelistAndCancelBookings: false }) - const getConfirmationSchema = () => z.object({ + const confirmationSchema = z.object({ confirmInfoAccuracy: z.boolean().refine(val => val === true, { message: t('validation.confirm') }), @@ -27,7 +26,7 @@ export const useStrrStrataApplicationStore = defineStore('strr/strataApplication const validateStrataConfirmation = (returnBool = false): MultiFormValidationResult | boolean => { const result = validateSchemaAgainstState( - getConfirmationSchema(), platformConfirmation, 'platform-confirmation-form' + confirmationSchema, confirmation, 'platform-confirmation-form' ) if (returnBool) { @@ -63,7 +62,7 @@ export const useStrrStrataApplicationStore = defineStore('strr/strataApplication return applicationBody } - const submitPlatformApplication = async () => { + const submitStrataApplication = async () => { const body = createApplicationBody() console.info('submitting application: ', body) @@ -72,8 +71,9 @@ export const useStrrStrataApplicationStore = defineStore('strr/strataApplication } return { - platformConfirmation, - submitPlatformApplication, + confirmation, + confirmationSchema, + submitStrataApplication, validateStrataConfirmation } }) diff --git a/strr-strata-web/app/stores/strataDetails.ts b/strr-strata-web/app/stores/strataDetails.ts index eca8f75f..946f4b6f 100644 --- a/strr-strata-web/app/stores/strataDetails.ts +++ b/strr-strata-web/app/stores/strataDetails.ts @@ -2,42 +2,61 @@ import { z } from 'zod' import type { StrataDetails } from '~/interfaces/strata-details' export const useStrrStrataDetailsStore = defineStore('strr/strataDetails', () => { - const { - addNewEmptyBrand: baseAddNewEmptyBrand, - getBrandSchema: getStrataBrandSchema, - removeBrandAtIndex: baseRemoveBrandAtIndex - } = useStrrBaseBrand() + const { t } = useI18n() + const { getBrandSchema: getStrataBrandSchema } = useStrrBaseBrand() - const getStrataDetailsSchema = () => z.object({ + const strataDetailsSchema = z.object({ numberOfUnits: z.number(), - brands: z.array(getStrataBrandSchema()) + brand: getStrataBrandSchema(), + buildings: z.array(getRequiredAddress( + t('validation.address.street'), + t('validation.address.city'), + t('validation.address.region'), + t('validation.address.postalCode'), + t('validation.address.country') + )), + location: getRequiredAddress( + t('validation.address.street'), + t('validation.address.city'), + t('validation.address.region'), + t('validation.address.postalCode'), + t('validation.address.country') + ) }) const strataDetails = ref({ - brands: [{ name: '', website: '' }], + brand: { name: '', website: '' }, buildings: [], location: { - country: '', + country: 'CA', street: '', streetAdditional: '', city: '', - region: '', + region: 'BC', postalCode: '', locationDescription: '' }, numberOfUnits: undefined }) - const addNewEmptyBrand = () => { - baseAddNewEmptyBrand(strataDetails) + const addNewEmptyBuilding = () => { + strataDetails.value.buildings.push({ + country: 'CA', + street: '', + streetAdditional: '', + city: '', + region: 'BC', + postalCode: '', + locationDescription: '' + }) } - const removeBrandAtIndex = (index: number) => { - baseRemoveBrandAtIndex(strataDetails, index) + const removeBuildingAtIndex = (index: number) => { + strataDetails.value.buildings.splice(index, 1) } const validateStrataDetails = (returnBool = false): MultiFormValidationResult | boolean => { - const result = validateSchemaAgainstState(getStrataDetailsSchema(), strataDetails.value, 'strata-details-form') + const result = validateSchemaAgainstState(strataDetailsSchema, strataDetails.value, 'strata-details-form') if (returnBool) { return result.success === true @@ -49,9 +68,9 @@ export const useStrrStrataDetailsStore = defineStore('strr/strataDetails', () => return { strataDetails, getStrataBrandSchema, - getStrataDetailsSchema, - addNewEmptyBrand, - removeBrandAtIndex, + strataDetailsSchema, + addNewEmptyBuilding, + removeBuildingAtIndex, validateStrataDetails } }) diff --git a/strr-strata-web/nuxt.config.ts b/strr-strata-web/nuxt.config.ts index 89821045..a03b74af 100644 --- a/strr-strata-web/nuxt.config.ts +++ b/strr-strata-web/nuxt.config.ts @@ -39,6 +39,7 @@ export default defineNuxtConfig({ }, extends: [ + // '../strr-base-web' // dev only ['github:bcgov/STRR/strr-base-web', { install: true }] ], diff --git a/strr-strata-web/package.json b/strr-strata-web/package.json index a8cf7cc2..5c6a6462 100644 --- a/strr-strata-web/package.json +++ b/strr-strata-web/package.json @@ -44,6 +44,7 @@ "@daxiom/nuxt-core-layer-test": "^0.0.10", "@vuepic/vue-datepicker": "^9.0.3", "country-codes-list": "^1.6.11", - "nuxt": "^3.12.3" + "nuxt": "^3.12.3", + "vue-country-flag-next": "^2.3.2" } } diff --git a/strr-strata-web/pnpm-lock.yaml b/strr-strata-web/pnpm-lock.yaml index a06284d6..1ee8946d 100644 --- a/strr-strata-web/pnpm-lock.yaml +++ b/strr-strata-web/pnpm-lock.yaml @@ -17,6 +17,9 @@ dependencies: nuxt: specifier: ^3.12.3 version: 3.12.3(@opentelemetry/api@1.9.0)(eslint@8.57.0)(rollup@4.18.0)(sass@1.77.6)(typescript@5.5.3)(vite@5.3.3) + vue-country-flag-next: + specifier: ^2.3.2 + version: 2.3.2(vue@3.4.31) devDependencies: '@axe-core/playwright': @@ -12161,6 +12164,15 @@ packages: resolution: {integrity: sha512-Jr5N8QVYEcbQuMN1LRgvg61758G8HTnzUlQsAFOxx6Y6X8kmhJ7C+jOvWsQruYxi3uHhhS6BghyRlyiwO99DBg==} dev: true + /vue-country-flag-next@2.3.2(vue@3.4.31): + resolution: {integrity: sha512-Lv12L1VTwlBgizpZ3xPEPO3zuIETaJmeSiPuLOWLLgu2EakwU/o72iKYiKcdZ6BXiSkfss+Ski5fDzjuxZ1DcA==} + engines: {node: '>=10'} + peerDependencies: + vue: ^3.0.0 + dependencies: + vue: 3.4.31(typescript@5.5.3) + dev: false + /vue-demi@0.14.10(vue@3.4.31): resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==} engines: {node: '>=12'} From 53e2bf1ad330d98bedb2e139df73165fc8e05b3a Mon Sep 17 00:00:00 2001 From: Kial Jinnah Date: Wed, 6 Nov 2024 11:54:34 -0500 Subject: [PATCH 2/4] updated address usage for base web changes Signed-off-by: Kial Jinnah --- .../form/platform/BusinessDetails.vue | 41 +------------------ strr-platform-web/pnpm-lock.yaml | 12 ++++++ 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/strr-platform-web/app/components/form/platform/BusinessDetails.vue b/strr-platform-web/app/components/form/platform/BusinessDetails.vue index 386c4bf3..e5ce10b2 100644 --- a/strr-platform-web/app/components/form/platform/BusinessDetails.vue +++ b/strr-platform-web/app/components/form/platform/BusinessDetails.vue @@ -66,43 +66,6 @@ watch(() => platformBusiness.value.hasRegOffAtt, } ) -// address stuff -const { - activeAddressField, - address: canadaPostAddress, - enableAddressComplete -} = useCanadaPostAddress() - -const activeAddressPath = computed(() => { - if (activeAddressField.value === 'platform-business-address') { - return 'mailingAddress' - } - return 'regOfficeOrAtt.mailingAddress' -}) - -watch(canadaPostAddress, (newAddress) => { - if (platformBusinessFormRef.value) { - // reset form validation for city/region/postalCode if address is changed - platformBusinessFormRef.value.clear(`${activeAddressPath.value}.city`) - platformBusinessFormRef.value.clear(`${activeAddressPath.value}.region`) - platformBusinessFormRef.value.clear(`${activeAddressPath.value}.postalCode`) - if (newAddress && activeAddressPath.value === 'mailingAddress') { - platformBusiness.value.mailingAddress.street = newAddress.street - platformBusiness.value.mailingAddress.streetAdditional = newAddress.streetAdditional - platformBusiness.value.mailingAddress.country = newAddress.country - platformBusiness.value.mailingAddress.city = newAddress.city - platformBusiness.value.mailingAddress.region = newAddress.region - platformBusiness.value.mailingAddress.postalCode = newAddress.postalCode - } else if (newAddress) { - // NOTE: country and region are not set because they are disabled for regOfficeOrAtt.mailingAddress - platformBusiness.value.regOfficeOrAtt.mailingAddress.street = newAddress.street - platformBusiness.value.regOfficeOrAtt.mailingAddress.streetAdditional = newAddress.streetAdditional - platformBusiness.value.regOfficeOrAtt.mailingAddress.city = newAddress.city - platformBusiness.value.regOfficeOrAtt.mailingAddress.postalCode = newAddress.postalCode - } - } -}) - onMounted(async () => { // validate form if step marked as complete if (props.isComplete) { @@ -202,7 +165,7 @@ onMounted(async () => { v-model:region="platformBusiness.mailingAddress.region" v-model:postal-code="platformBusiness.mailingAddress.postalCode" :schema-prefix="'mailingAddress.'" - :enable-address-complete="enableAddressComplete" + :form-ref="platformBusinessFormRef" /> @@ -258,8 +221,8 @@ onMounted(async () => { v-model:region="platformBusiness.regOfficeOrAtt.mailingAddress.region" v-model:postal-code="platformBusiness.regOfficeOrAtt.mailingAddress.postalCode" :schema-prefix="'regOfficeOrAtt.mailingAddress.'" - :enable-address-complete="enableAddressComplete" :disabled-fields="['country', 'region']" + :form-ref="platformBusinessFormRef" /> diff --git a/strr-platform-web/pnpm-lock.yaml b/strr-platform-web/pnpm-lock.yaml index 3893bbf8..9e4edcb0 100644 --- a/strr-platform-web/pnpm-lock.yaml +++ b/strr-platform-web/pnpm-lock.yaml @@ -17,6 +17,9 @@ dependencies: nuxt: specifier: ^3.12.3 version: 3.12.3(@opentelemetry/api@1.9.0)(eslint@8.57.0)(rollup@4.18.0)(sass@1.77.6)(typescript@5.5.3)(vite@5.3.3) + vue-country-flag-next: + specifier: ^2.3.2 + version: 2.3.2(vue@3.5.12) devDependencies: '@axe-core/playwright': @@ -12571,6 +12574,15 @@ packages: resolution: {integrity: sha512-lfgdSLQKrUmADiSV6PbBvYgQ33KF3Ztv6gP85MfGaGaSGMTXORVaHT1EHfsqCgzRNBstPKYDmvAV9Do5CmJ07A==} dev: true + /vue-country-flag-next@2.3.2(vue@3.5.12): + resolution: {integrity: sha512-Lv12L1VTwlBgizpZ3xPEPO3zuIETaJmeSiPuLOWLLgu2EakwU/o72iKYiKcdZ6BXiSkfss+Ski5fDzjuxZ1DcA==} + engines: {node: '>=10'} + peerDependencies: + vue: ^3.0.0 + dependencies: + vue: 3.5.12(typescript@5.5.3) + dev: false + /vue-demi@0.14.10(vue@3.5.12): resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==} engines: {node: '>=12'} From d8e7ffa71c7593bf83671d1f0a29c9a7615b7247 Mon Sep 17 00:00:00 2001 From: Kial Jinnah Date: Wed, 6 Nov 2024 16:36:43 -0500 Subject: [PATCH 3/4] Final initial strata form updates Signed-off-by: Kial Jinnah --- strr-base-web/app/app.config.ts | 18 ++-- .../components/connect/form/field/Index.vue | 11 +-- strr-base-web/app/composables/useStrrApi.ts | 4 +- strr-base-web/app/locales/en-CA.ts | 1 + .../app/utils/connect-validation/index.ts | 13 --- .../app/stores/platformApplication.ts | 2 +- .../app/components/form/BusinessDetails.vue | 2 +- .../app/components/form/ReviewConfirm.vue | 61 +++++++------ .../app/components/form/StrataDetails.vue | 2 +- strr-strata-web/app/locales/en-CA.ts | 3 +- strr-strata-web/app/pages/application.vue | 85 ++++++++++++++++++- .../app/stores/strataApplication.ts | 4 +- strr-strata-web/app/stores/strataDetails.ts | 2 +- 13 files changed, 142 insertions(+), 66 deletions(-) diff --git a/strr-base-web/app/app.config.ts b/strr-base-web/app/app.config.ts index 1dff880b..6dd6dedd 100644 --- a/strr-base-web/app/app.config.ts +++ b/strr-base-web/app/app.config.ts @@ -1,3 +1,4 @@ +/* eslint-disable max-len */ export default defineAppConfig({ ui: { strategy: 'merge', @@ -14,12 +15,14 @@ export default defineAppConfig({ base: 'file:text-gray-700 file:pt-2' }, color: { + gray: { + outline: 'bg-gray-100 ring-0 disabled:hover:bg-gray-100 disabled:hover:border-gray-500 hover:bg-gray-200 hover:border-gray-600 focus:border-primary-500 focus:border-b-2 focus:ring-0' + }, red: { - outline: 'bg-red-100 ring-0 border-red-600 placeholder-red-600 hover:bg-gray-200 ' + - 'focus:border-red-600 focus:border-b-2 focus:ring-0' + outline: 'bg-red-100 ring-0 border-red-600 placeholder-red-600 focus:border-red-600 focus:border-b-2 focus:ring-0' }, primary: { - outline: 'bg-primary-50 ring-0 border-primary-500 hover:bg-gray-200 focus:border-b-2 focus:ring-0' + outline: 'bg-primary-50 ring-0 border-primary-500 focus:border-b-2 focus:ring-0' } } }, @@ -28,9 +31,14 @@ export default defineAppConfig({ }, select: { color: { + gray: { + outline: 'bg-gray-100 ring-0 disabled:hover:bg-gray-100 hover:bg-gray-200 hover:border-gray-600 focus:border-primary-500 focus:border-b-2 focus:ring-0' + }, + primary: { + outline: 'bg-primary-50 ring-0 border-primary-500 disabled:hover:bg-primary-50 focus:border-b-2 focus:ring-0' + }, red: { - outline: 'bg-red-100 border-red-600 ring-0 hover:bg-gray-200 ' + - 'focus:border-red-600 focus:border-b-2 focus:ring-0' + outline: 'bg-red-100 border-red-600 ring-0 focus:border-red-600 focus:border-b-2 focus:ring-0' } } }, diff --git a/strr-base-web/app/components/connect/form/field/Index.vue b/strr-base-web/app/components/connect/form/field/Index.vue index bf25fed4..7ae753fe 100644 --- a/strr-base-web/app/components/connect/form/field/Index.vue +++ b/strr-base-web/app/components/connect/form/field/Index.vue @@ -1,6 +1,4 @@