Skip to content

Commit

Permalink
hosts drafts (#442)
Browse files Browse the repository at this point in the history
* hosts drafts

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

* feature flag, phone number issue, btn control updates, depreciation fix, other fixes

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

* added delete draft call

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

* fix for base-web ci?

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

* Update for PR comment

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 9, 2025
1 parent 28977b2 commit d37eb5b
Show file tree
Hide file tree
Showing 20 changed files with 237 additions and 465 deletions.
11 changes: 6 additions & 5 deletions strr-base-web/app/components/connect/ButtonControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const rightButtons = computed(() => buttonControl.value?.rightButtons || [])
<template>
<div class="bg-white py-10" data-testid="button-control">
<div class="app-inner-container">
<div class="grid grid-cols-2">
<div v-if="leftButtons.length > 0" class="col-start-1">
<div class="flex gap-4">
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<div>
<div class="flex justify-center gap-4 md:justify-start">
<UButton
v-for="(button, i) in leftButtons"
:key="'left-button-' + i"
Expand All @@ -28,15 +28,16 @@ const rightButtons = computed(() => buttonControl.value?.rightButtons || [])
/>
</div>
</div>
<div class="col-span-1 col-start-2">
<div v-if="rightButtons.length > 0" class="flex justify-end gap-4">
<div>
<div class="flex justify-center gap-4 md:justify-end">
<UButton
v-for="(button, i) in rightButtons"
:key="'right-button-' + i"
class="max-w-fit px-7 py-3"
:class="button.class"
block
:color="button.color || 'primary'"
:disabled="button.disabled || false"
:icon="button.icon || ''"
:label="button.label"
:loading="button.loading || false"
Expand Down
8 changes: 4 additions & 4 deletions strr-base-web/app/components/connect/form/date/Picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ watch(() => props.setMinDate, (val) => { minDate.value = val || null })
</div>
</template>
<style lang="scss">
@import '@vuepic/vue-datepicker/dist/main.css';
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
@use '@vuepic/vue-datepicker/dist/main.css' as *;
@use 'tailwindcss/base' as *;
@use 'tailwindcss/components' as *;
@use 'tailwindcss/utilities' as *;
.connect-date-picker {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,15 @@ onMounted(() => {
if (countryIso2.value !== undefined) {
selectCountry(countryIso2.value)
} else if (countryCallingCode.value) {
selectedCountry.value = {
callingCode: `+${countryCallingCode.value}`
// Set a country based on the calling code if available
const iso2 = search(countryCallingCode.value)[0]?.iso2
if (iso2) {
selectCountry(iso2)
} else {
selectedCountry.value = {
callingCode: countryCallingCode.value,
label: `+${countryCallingCode.value}`
}
}
}
})
Expand Down
14 changes: 8 additions & 6 deletions strr-base-web/app/components/todo/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ defineProps<{
</p>
</slot>
</div>
<UButton
:label="button.label"
:color="button.colour || 'primary'"
:icon="button.icon"
@click="button.action()"
/>
<div>
<UButton
:label="button.label"
:color="button.colour || 'primary'"
:icon="button.icon"
@click="button.action()"
/>
</div>
</div>
<slot />
</div>
Expand Down
39 changes: 39 additions & 0 deletions strr-base-web/app/composables/useButtonControl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { ConnectBtnControl } from '#imports'

export const useButtonControl = () => {
const route = useRoute()

function setButtonControl (buttonControl: ConnectBtnControl) {
route.meta.buttonControl = buttonControl
}

function getButtonControl (): ConnectBtnControl {
return route.meta.buttonControl as ConnectBtnControl
}

function handleButtonLoading (reset: boolean, buttonGrp?: 'left' | 'right', buttonIndex?: number) {
// set button control for loading / disabling buttons on submit or save or reset to default
const updateButtonGrp = (buttonArray: ConnectBtnControlItem[], grp: 'left' | 'right') => {
for (const [index, element] of buttonArray.entries()) {
if (reset) {
element.disabled = false
element.loading = false
} else {
element.loading = (grp === buttonGrp) && index === buttonIndex
element.disabled = !element.loading
}
}
}
const buttonControl = getButtonControl()
// update left buttons with loading / disabled as required
updateButtonGrp(buttonControl.leftButtons, 'left')
// update right buttons with loading / disabled as required
updateButtonGrp(buttonControl.rightButtons, 'right')
}

return {
getButtonControl,
setButtonControl,
handleButtonLoading
}
}
17 changes: 14 additions & 3 deletions strr-base-web/app/composables/useStrrApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,23 @@ export const useStrrApi = () => {
return resp.applications
}

const postApplication = async <T extends { registration: any }, R extends T>(body: T) => {
return await $strrApi<R>('/applications', {
method: 'POST',
const postApplication = async <T extends { registration: any }, R extends T>(
body: T,
isDraft = false,
applicationId?: string
) => {
const path = applicationId ? `/applications/${applicationId}` : '/applications'
return await $strrApi<R>(path, {
method: applicationId ? 'PUT' : 'POST',
headers: (isDraft ? { isDraft: true } : {}) as HeadersInit,
body
})
}

const deleteApplication = async (applicationId: string) => {
return await $strrApi(`/applications/${applicationId}`, { method: 'DELETE' })
}

const getApplicationReceipt = async (applicationNumber: string) => {
return await $strrApi<Blob>(`/applications/${applicationNumber}/payment/receipt`)
.catch((e) => {
Expand All @@ -65,6 +75,7 @@ export const useStrrApi = () => {
}

return {
deleteApplication,
getAccountRegistrations,
getAccountApplications,
getApplicationReceipt,
Expand Down
2 changes: 2 additions & 0 deletions strr-base-web/app/locales/en-CA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default {
decline: 'Decline',
close: 'Close',
openHelpDocs: 'Read the Overview',
deleteApplication: 'Delete Application',
downloadCertificate: 'Download Certificate',
downloadReceipt: 'Download Receipt',
downloadReport: 'Download Report',
Expand All @@ -60,6 +61,7 @@ export default {
save: 'Save',
saveExit: 'Save and Resume Later',
beginApplication: 'Begin Application',
resume: 'Resume',
resumeApplication: 'Resume Application',
acceptTos: {
main: 'Accept Terms of Use',
Expand Down
6 changes: 0 additions & 6 deletions strr-base-web/app/utils/setButtonControl.ts

This file was deleted.

2 changes: 1 addition & 1 deletion strr-base-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"postinstall": "nuxt prepare",
"lint": "eslint --ext .ts,.vue app --ignore-path .gitignore",
"lint:fix": "pnpm lint --fix",
"test": "vitest --dir tests/unit --passWithNoTests --coverage && cp ./tests/coverage/clover.xml ./coverage.xml",
"test": "vitest --dir tests/unit --passWithNoTests --coverage && cp ./coverage/clover.xml ./coverage.xml",
"test:unit": "vitest --dir tests/unit",
"test:unit:cov": "vitest run --dir tests/unit --coverage",
"test:e2e": "npx playwright test",
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions strr-host-pm-web/app/locales/en-CA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export default {
showDetails: 'Show Details',
hideDetails: 'Hide Details',
returnToStep: 'Return to the step to finish it',
ariaResumeDraft: 'Resume Draft for {number}',
ariaViewDetails: 'View details for property: {name}, {address}',
registerAStr: 'Register a Short-Term Rental'
},
Expand Down
Loading

0 comments on commit d37eb5b

Please sign in to comment.