feat: Enhance reservation functionality
This commit is contained in:
@@ -187,7 +187,7 @@ import {
|
||||
IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonButtons,
|
||||
IonMenuButton, IonButton, IonIcon, IonCard, IonBadge,
|
||||
IonList, IonItem, IonLabel, IonInput, IonToggle, IonSpinner,
|
||||
IonModal, IonAlert, IonToast,
|
||||
IonModal, IonAlert, IonToast, onIonViewWillEnter,
|
||||
} from '@ionic/vue'
|
||||
import { addOutline, pencilOutline, trashOutline, boatOutline, cameraOutline } from 'ionicons/icons'
|
||||
import type { Database } from '~/types/supabase'
|
||||
@@ -224,7 +224,9 @@ const form = reactive({
|
||||
img_src: null as string | null,
|
||||
})
|
||||
|
||||
onMounted(fetchBoats)
|
||||
const user = useSupabaseUser()
|
||||
watch(user, (val) => { if (val) fetchBoats() }, { immediate: true })
|
||||
onIonViewWillEnter(() => { if (user.value) fetchBoats() })
|
||||
|
||||
async function fetchBoats() {
|
||||
loading.value = true
|
||||
|
||||
@@ -155,7 +155,7 @@ import {
|
||||
IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonButtons,
|
||||
IonMenuButton, IonButton, IonIcon, IonCard, IonCardHeader, IonCardTitle,
|
||||
IonCardSubtitle, IonCardContent, IonList, IonItem, IonLabel, IonInput,
|
||||
IonSpinner, IonToast,
|
||||
IonSpinner, IonToast, onIonViewWillEnter,
|
||||
} from '@ionic/vue'
|
||||
import { saveOutline, trashOutline, addOutline } from 'ionicons/icons'
|
||||
import type { Database } from '~/types/supabase'
|
||||
@@ -184,10 +184,14 @@ const local = reactive<Record<ConfigKey, number>>({
|
||||
|
||||
const original = reactive<Record<ConfigKey, number>>({ ...local })
|
||||
|
||||
onMounted(async () => {
|
||||
async function loadAll() {
|
||||
await Promise.all([fetchConfig(), fetchHolidays()])
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
const user = useSupabaseUser()
|
||||
watch(user, (val) => { if (val) loadAll() }, { immediate: true })
|
||||
onIonViewWillEnter(() => { if (user.value) loadAll() })
|
||||
|
||||
async function fetchConfig() {
|
||||
const { data } = await supabase
|
||||
|
||||
@@ -193,6 +193,7 @@ import {
|
||||
IonMenuButton, IonButton, IonIcon, IonCard, IonCardHeader, IonCardTitle,
|
||||
IonCardSubtitle, IonCardContent, IonList, IonItem, IonLabel, IonToggle,
|
||||
IonSelect, IonSelectOption, IonSpinner, IonModal, IonInput, IonToast, IonCheckbox,
|
||||
onIonViewWillEnter,
|
||||
} from '@ionic/vue'
|
||||
import {
|
||||
addOutline, timeOutline, trashOutline, constructOutline, calendarOutline,
|
||||
@@ -252,12 +253,16 @@ const dateOptions = computed(() => {
|
||||
return out
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
async function loadAll() {
|
||||
await Promise.all([fetchBoats(), fetchTemplates()])
|
||||
await fetchSlots()
|
||||
})
|
||||
}
|
||||
|
||||
watch(selectedDate, fetchSlots)
|
||||
const user = useSupabaseUser()
|
||||
watch(user, (val) => { if (val) loadAll() }, { immediate: true })
|
||||
onIonViewWillEnter(() => { if (user.value) loadAll() })
|
||||
|
||||
watch(selectedDate, () => { if (user.value) fetchSlots() })
|
||||
|
||||
async function fetchBoats() {
|
||||
const { data } = await supabase.from('boats').select('*').order('name')
|
||||
|
||||
@@ -161,7 +161,7 @@ import {
|
||||
IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonButtons,
|
||||
IonMenuButton, IonButton, IonIcon, IonCard, IonCardContent, IonBadge,
|
||||
IonList, IonItem, IonLabel, IonInput, IonTextarea, IonSelect, IonSelectOption,
|
||||
IonSpinner, IonModal, IonAlert, IonToast,
|
||||
IonSpinner, IonModal, IonAlert, IonToast, onIonViewWillEnter,
|
||||
} from '@ionic/vue'
|
||||
import { addOutline, pencilOutline, trashOutline } from 'ionicons/icons'
|
||||
import type { Database } from '~/types/supabase'
|
||||
@@ -215,12 +215,16 @@ const filteredReservations = computed(() => {
|
||||
})
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
async function loadAll() {
|
||||
await Promise.all([fetchBoats(), fetchMembers()])
|
||||
await fetchReservations()
|
||||
})
|
||||
}
|
||||
|
||||
watch([filterDateFrom, filterDateTo], fetchReservations)
|
||||
const user = useSupabaseUser()
|
||||
watch(user, (val) => { if (val) loadAll() }, { immediate: true })
|
||||
onIonViewWillEnter(() => { if (user.value) loadAll() })
|
||||
|
||||
watch([filterDateFrom, filterDateTo], () => { if (user.value) fetchReservations() })
|
||||
|
||||
async function fetchBoats() {
|
||||
const { data } = await supabase.from('boats').select('*').order('name')
|
||||
|
||||
@@ -128,7 +128,7 @@ import {
|
||||
IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonButtons,
|
||||
IonMenuButton, IonButton, IonIcon, IonCard, IonCardHeader, IonCardTitle,
|
||||
IonCardContent, IonList, IonItem, IonLabel, IonInput, IonSpinner,
|
||||
IonModal, IonAlert, IonToast,
|
||||
IonModal, IonAlert, IonToast, onIonViewWillEnter,
|
||||
} from '@ionic/vue'
|
||||
import { addOutline, pencilOutline, trashOutline, closeOutline } from 'ionicons/icons'
|
||||
import type { Database, TimeTuple } from '~/types/supabase'
|
||||
@@ -153,7 +153,9 @@ const form = reactive<{ name: string; tuples: [string, string][] }>({
|
||||
tuples: [['08:00', '12:00']],
|
||||
})
|
||||
|
||||
onMounted(fetchTemplates)
|
||||
const user = useSupabaseUser()
|
||||
watch(user, (val) => { if (val) fetchTemplates() }, { immediate: true })
|
||||
onIonViewWillEnter(() => { if (user.value) fetchTemplates() })
|
||||
|
||||
async function fetchTemplates() {
|
||||
loading.value = true
|
||||
|
||||
Reference in New Issue
Block a user