Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hosts drafts #442

Merged
merged 6 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions strr-base-web/app/components/connect/ButtonControl.vue
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with 3 extra buttons I needed to update the styling for smaller screens

example:
Screenshot 2025-01-08 at 3 36 05 PM
Screenshot 2025-01-08 at 3 35 44 PM

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 *;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@import depreciated


.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}`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when loading from a draft we need this because the api doesn't save the iso2 for the phone number. Was resulting in weird functionality when re-editing an existing person with a phone number

}
}
}
})
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>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrapped the button in a div to prevent it growing with the width of the row

<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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively we could just have these in a util like before. I like this a bit more because I think it's clearer where the 'buttonControl' functionality lives

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
1 change: 1 addition & 0 deletions strr-base-web/app/locales/en-CA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to composable

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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was able to remove this and build successfully (there was some weird issue before where we needed this component defined in each layer otherwise it would give a build error)

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
Loading