feat: Enhance reservation functionality

This commit is contained in:
2026-04-22 10:23:22 -04:00
parent 7f1e82acc2
commit 534d66c774
25 changed files with 1236 additions and 91 deletions

View File

@@ -88,6 +88,15 @@
</IonCard>
<IonList lines="full" class="ion-margin-top">
<IonItem v-if="auth.isAdmin">
<IonLabel position="stacked">Member</IonLabel>
<IonSelect v-model="form.targetUserId" placeholder="Self (admin)" interface="action-sheet">
<IonSelectOption value="">Self (admin)</IonSelectOption>
<IonSelectOption v-for="m in members" :key="m.user_id" :value="m.user_id">
{{ m.first_name }} {{ m.last_name }}
</IonSelectOption>
</IonSelect>
</IonItem>
<IonItem>
<IonLabel position="stacked">Reason</IonLabel>
<IonSelect v-model="form.reason" placeholder="Select reason" interface="action-sheet">
@@ -133,6 +142,7 @@ import {
} from '@ionic/vue'
import { timeOutline, warningOutline } from 'ionicons/icons'
import { useAuthStore } from '~/stores/auth'
import type { Member } from '~/stores/auth'
import { toDateToronto } from '~/utils/toronto'
import type { Database } from '~/types/supabase'
import { useBookingDraft } from '~/composables/useBookingDraft'
@@ -158,9 +168,10 @@ const submitting = ref(false)
const selectedDate = ref(todayIso())
const selectedBoat = ref<Boat | null>(null)
const selectedSlot = ref<Interval | null>(null)
const members = ref<Member[]>([])
const toast = reactive({ show: false, message: '', color: 'success' })
const form = reactive({ reason: '', comment: '' })
const form = reactive({ reason: '', comment: '', targetUserId: '' })
const reasonOptions = ['Open Sail', 'Private Sail', 'Racing', 'Training', 'Other']
// 14-day date strip starting today
@@ -210,6 +221,11 @@ onIonViewWillEnter(async () => {
selectedBoat.value = null
selectedSlot.value = null
selectedDate.value = todayIso()
form.targetUserId = ''
if (auth.isAdmin) {
const { data } = await supabase.from('members').select('*').order('last_name')
members.value = data ?? []
}
await loadSlots()
})
@@ -299,11 +315,12 @@ async function submitReservation() {
const response = await supabase.functions.invoke('create-reservation', {
body: {
boat_id: selectedBoat.value.id,
start_time: selectedSlot.value.start_time,
end_time: selectedSlot.value.end_time,
reason: form.reason,
comment: form.comment,
boat_id: selectedBoat.value.id,
start_time: selectedSlot.value.start_time,
end_time: selectedSlot.value.end_time,
reason: form.reason,
comment: form.comment,
...(auth.isAdmin && form.targetUserId ? { target_user_id: form.targetUserId } : {}),
},
headers: { Authorization: `Bearer ${accessToken}` },
})