Allows for editing Hunt details
This commit is contained in:
@@ -35,6 +35,9 @@ export const apiGetAllHunts = (status?: 'UNSTARTED' | 'ONGOING' | 'CLOSED') =>
|
||||
export const apiCreateHunt = (title: string, startDateTime: string, endDateTime: string) =>
|
||||
client.post<HuntResponse>('/hunt', { title, startDateTime, endDateTime })
|
||||
|
||||
export const apiUpdateHunt = (huntId: string, title: string, startDateTime: string, endDateTime: string, isTerminated: boolean) =>
|
||||
client.patch<HuntResponse>(`/hunt/${huntId}`, { title, startDateTime, endDateTime, isTerminated })
|
||||
|
||||
// ── Hunter ────────────────────────────────────────────────────────────────────
|
||||
|
||||
export const apiGetOngoingHunts = () =>
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
let {
|
||||
value = $bindable(''),
|
||||
defaultTimeIndex = 36,
|
||||
initialValue = '',
|
||||
}: {
|
||||
value?: string
|
||||
defaultTimeIndex?: number
|
||||
initialValue?: string
|
||||
} = $props()
|
||||
|
||||
const months = [
|
||||
@@ -25,11 +27,19 @@
|
||||
return { value: i, label: `${displayHour}:${minute.toString().padStart(2, '0')} ${ampm}` }
|
||||
})
|
||||
|
||||
const today = new Date()
|
||||
let month = $state(today.getMonth())
|
||||
let day = $state(today.getDate())
|
||||
let year = $state(today.getFullYear())
|
||||
let timeIndex = $state(untrack(() => defaultTimeIndex))
|
||||
const seed = untrack(() => {
|
||||
if (initialValue) {
|
||||
const d = new Date(initialValue)
|
||||
return { month: d.getMonth(), day: d.getDate(), year: d.getFullYear(), timeIndex: d.getHours() * 4 + Math.round(d.getMinutes() / 15) }
|
||||
}
|
||||
const today = new Date()
|
||||
return { month: today.getMonth(), day: today.getDate(), year: today.getFullYear(), timeIndex: defaultTimeIndex }
|
||||
})
|
||||
|
||||
let month = $state(seed.month)
|
||||
let day = $state(seed.day)
|
||||
let year = $state(seed.year)
|
||||
let timeIndex = $state(seed.timeIndex)
|
||||
|
||||
const daysInMonth = $derived(new Date(year, month + 1, 0).getDate())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user