Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
18 changes: 15 additions & 3 deletions components/event/DateRange.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@ import { format, parseISO, isSameDay, isSameMonth, isSameYear } from 'date-fns'

const props = defineProps<{
start: string | Date
end: string | Date
end?: string | Date | null
formatString?: string
}>()

const parse = (date: string | Date) =>
typeof date === 'string' ? parseISO(date) : date

const startDate = computed(() => parse(props.start))
const endDate = computed(() => parse(props.end))
const endDate = computed(() =>
props.end != null && props.end !== ''
? parse(props.end as string | Date)
: null
)

const isOpenEnd = computed(() => endDate.value === null)

const formattedRange = computed(() => {
const s = startDate.value
const e = endDate.value

if (e == null) {
return format(s, props.formatString || 'MMM d, yyyy')
}
if (isSameDay(s, e)) {
return format(s, props.formatString || 'MMM d, yyyy')
} else if (isSameMonth(s, e)) {
Expand All @@ -31,5 +40,8 @@ const formattedRange = computed(() => {
</script>

<template>
<span>{{ formattedRange }}</span>
<span>
{{ formattedRange }}
<span v-if="isOpenEnd" class="text-muted-foreground">(open end)</span>
</span>
</template>
6 changes: 4 additions & 2 deletions components/event/EventView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,11 @@ const navigation = computed(() => [
</div>
<div>
<div class="font-medium">
{{ getDateTime(event.endDate) }}
{{ event.endDate ? getDateTime(event.endDate) : 'Open end' }}
</div>
<div class="text-muted-foreground">
{{ event.endDate ? 'End' : 'No end time' }}
</div>
<div class="text-muted-foreground">End</div>
</div>
</div>
</div>
Expand Down
35 changes: 27 additions & 8 deletions components/event/edit/EventAboutEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const schema = z.object({
cover: z.string().optional().default(''),
status: statusSchema,
startDate: z.string().optional(),
endDate: z.string().optional(),
endDate: z.string().optional().nullable(),
type: z.string().optional().default('Party'),
venue: z
.object({
Expand Down Expand Up @@ -186,20 +186,39 @@ const askToDelete = () => {

<FormField v-slot="{ componentField }" name="startDate">
<FormItem class="flex flex-col justify-start">
<FormLabel>Start</FormLabel>
<FormLabel>Start Date</FormLabel>
<FormControl>
<DateInput v-bind="componentField" />
</FormControl>
<FormMessage />
</FormItem>
</FormField>

<FormField v-slot="{ componentField }" name="endDate">
<FormItem class="flex flex-col justify-start">
<FormLabel>End</FormLabel>
<FormControl>
<DateInput v-bind="componentField" :min-date="event.startDate" />
</FormControl>
<FormField v-slot="{ value: endDateValue, setValue: setEndDate }" name="endDate">
<FormItem class="flex flex-col justify-start space-y-3">
<div class="flex items-center gap-2">
<Checkbox
:id="'open-end-' + event?.id"
:checked="endDateValue == null || endDateValue === ''"
@update:checked="(checked) => setEndDate(checked ? null : undefined)"
/>
Comment on lines +197 to +204
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Open-end toggle cannot reliably switch back to “has end date”.

Line 203 sets undefined when unchecked, while Line 202 treats undefined as open-end (== null), so the checkbox reverts to checked and the end date input stays hidden.

💡 Suggested fix
-              :checked="endDateValue == null || endDateValue === ''"
-              `@update`:checked="(checked) => setEndDate(checked ? null : undefined)"
+              :checked="endDateValue === null || endDateValue === ''"
+              `@update`:checked="
+                (checked) =>
+                  setEndDate(
+                    checked
+                      ? null
+                      : endDateValue || event.startDate || new Date().toISOString()
+                  )
+              "

Also applies to: 212-221

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/event/edit/EventAboutEditor.vue` around lines 197 - 204, The
open-end Checkbox toggles setEndDate to undefined when unchecked which is then
treated as open-end by the checked expression (endDateValue == null), causing
the control to flip back; change the unchecked branch to set a concrete non-null
sentinel (e.g., empty string) so undefined is never used. Update the Checkbox
`@update`:checked handlers (and the corresponding other handler at lines ~212-221)
to use setEndDate(checked ? null : '') and ensure the checked binding still
reads endDateValue == null || endDateValue === '' so state remains consistent
between FormField, Checkbox, and setEndDate.

<FormLabel
:for="'open-end-' + event?.id"
class="text-sm font-normal cursor-pointer"
>
Open end party (no end date/time)
</FormLabel>
</div>
<template v-if="endDateValue != null && endDateValue !== ''">
<FormLabel>End date</FormLabel>
<FormControl>
<DateInput
:model-value="endDateValue"
@update:model-value="setEndDate"
:min-date="event.startDate"
/>
</FormControl>
</template>
<FormMessage />
</FormItem>
</FormField>
Expand Down
9 changes: 7 additions & 2 deletions server/trpc/routers/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export const eventsRouter = router({
cover: z.string().optional(),
status: z.string().optional(),
startDate: z.string().optional(),
endDate: z.string().optional(),
endDate: z.string().optional().nullable(),
type: z.string().optional(),
venue: z
.object({
Expand Down Expand Up @@ -311,7 +311,12 @@ export const eventsRouter = router({
data: {
...data,
startDate: data.startDate ? new Date(data.startDate) : undefined,
endDate: data.endDate ? new Date(data.endDate) : undefined,
endDate:
data.endDate === null || data.endDate === ''
? null
: data.endDate
? new Date(data.endDate)
: undefined,
venueId: venue?.id,
organizerId: organizer?.id,
styles: stylesData,
Expand Down