diff --git a/package-lock.json b/package-lock.json index d0beebc..a47eedc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "aio-shadcn-vite", "version": "0.0.0", "dependencies": { + "@internationalized/date": "^3.12.1", "@tanstack/vue-table": "^8.21.3", "@vee-validate/zod": "^4.15.1", "@vueuse/components": "^12.5.0", @@ -28,7 +29,7 @@ "qr-scanner": "^1.4.2", "qrcode": "^1.5.4", "radix-vue": "^1.9.13", - "reka-ui": "^2.6.0", + "reka-ui": "^2.9.7", "tailwind-merge": "^2.6.0", "tailwindcss-animate": "^1.0.7", "unique-names-generator": "^4.7.1", @@ -3948,9 +3949,9 @@ } }, "node_modules/@internationalized/date": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@internationalized/date/-/date-3.7.0.tgz", - "integrity": "sha512-VJ5WS3fcVx0bejE/YHfbDKR/yawZgKqn/if+oEeLqNwBtPzVB06olkfcnojTmEMX+gTpH+FlQ69SHNitJ8/erQ==", + "version": "3.12.1", + "resolved": "https://registry.npmjs.org/@internationalized/date/-/date-3.12.1.tgz", + "integrity": "sha512-6IedsVWXyq4P9Tj+TxuU8WGWM70hYLl12nbYU8jkikVpa6WXapFazPUcHUMDMoWftIDE2ILDkFFte6W2nFCkRQ==", "license": "Apache-2.0", "dependencies": { "@swc/helpers": "^0.5.0" @@ -7054,9 +7055,9 @@ } }, "node_modules/defu": { - "version": "6.1.4", - "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz", - "integrity": "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==", + "version": "6.1.7", + "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.7.tgz", + "integrity": "sha512-7z22QmUWiQ/2d0KkdYmANbRUVABpZ9SNYyH5vx6PZ+nE5bcC0l7uFvEfHlyld/HcGBFTL536ClDt3DEcSlEJAQ==", "license": "MIT" }, "node_modules/detect-libc": { @@ -12225,9 +12226,9 @@ } }, "node_modules/reka-ui": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/reka-ui/-/reka-ui-2.6.0.tgz", - "integrity": "sha512-NrGMKrABD97l890mFS3TNUzB0BLUfbL3hh0NjcJRIUSUljb288bx3Mzo31nOyUcdiiW0HqFGXJwyCBh9cWgb0w==", + "version": "2.9.7", + "resolved": "https://registry.npmjs.org/reka-ui/-/reka-ui-2.9.7.tgz", + "integrity": "sha512-aX7foYYR20v4+majO58OJJdBNfLMm0eJb448l9N4JVy8JB7GXOr4H/S4a+J1pkcoxZH8Cb7YHpJ855+miAm7sA==", "license": "MIT", "dependencies": { "@floating-ui/dom": "^1.6.13", @@ -12235,26 +12236,62 @@ "@internationalized/date": "^3.5.0", "@internationalized/number": "^3.5.0", "@tanstack/vue-virtual": "^3.12.0", - "@vueuse/core": "^12.5.0", - "@vueuse/shared": "^12.5.0", + "@vueuse/core": "^14.1.0", + "@vueuse/shared": "^14.1.0", "aria-hidden": "^1.2.4", - "defu": "^6.1.4", + "defu": "^6.1.5", "ohash": "^2.0.11" }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/zernonia" + }, "peerDependencies": { - "vue": ">= 3.2.0" + "vue": ">= 3.4.0" } }, - "node_modules/reka-ui/node_modules/@vueuse/shared": { - "version": "12.8.2", - "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-12.8.2.tgz", - "integrity": "sha512-dznP38YzxZoNloI0qpEfpkms8knDtaoQ6Y/sfS0L7Yki4zh40LFHEhur0odJC6xTHG5dxWVPiUWBXn+wCG2s5w==", + "node_modules/reka-ui/node_modules/@types/web-bluetooth": { + "version": "0.0.21", + "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.21.tgz", + "integrity": "sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==", + "license": "MIT" + }, + "node_modules/reka-ui/node_modules/@vueuse/core": { + "version": "14.3.0", + "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-14.3.0.tgz", + "integrity": "sha512-aHfz47g0ZhMtTVHmIzMVpJy8ePhhOy68GY5bv110+5DVtZ+W7BsOx+m61UNQqfrWyPztIHIanWa3E2tib3NFIw==", "license": "MIT", "dependencies": { - "vue": "^3.5.13" + "@types/web-bluetooth": "^0.0.21", + "@vueuse/metadata": "14.3.0", + "@vueuse/shared": "14.3.0" }, "funding": { "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "vue": "^3.5.0" + } + }, + "node_modules/reka-ui/node_modules/@vueuse/metadata": { + "version": "14.3.0", + "resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-14.3.0.tgz", + "integrity": "sha512-BwxmbAzwAVF50+MW57GXOUEV61nFBGnlBvrTqj49PqWJu3uw7hdu72ztXeZ33RdZtDY6kO+bfCAE1PCn88Tktw==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/reka-ui/node_modules/@vueuse/shared": { + "version": "14.3.0", + "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-14.3.0.tgz", + "integrity": "sha512-bZpge9eSXwa4ToSiqJ7j6KRwhAsneMFoSz3LMWKQDkqimm3D/tbFlrklrs/IOqC8tEcYmXQZJ6N0UrjhBirVCg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "vue": "^3.5.0" } }, "node_modules/require-directory": { diff --git a/package.json b/package.json index 2c2f2dd..36cf2cf 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "make": "electron-forge make" }, "dependencies": { + "@internationalized/date": "^3.12.1", "@tanstack/vue-table": "^8.21.3", "@vee-validate/zod": "^4.15.1", "@vueuse/components": "^12.5.0", @@ -63,7 +64,7 @@ "qr-scanner": "^1.4.2", "qrcode": "^1.5.4", "radix-vue": "^1.9.13", - "reka-ui": "^2.6.0", + "reka-ui": "^2.9.7", "tailwind-merge": "^2.6.0", "tailwindcss-animate": "^1.0.7", "unique-names-generator": "^4.7.1", diff --git a/src/components/ui/calendar/Calendar.vue b/src/components/ui/calendar/Calendar.vue new file mode 100644 index 0000000..d112cf3 --- /dev/null +++ b/src/components/ui/calendar/Calendar.vue @@ -0,0 +1,58 @@ + + + diff --git a/src/components/ui/calendar/CalendarCell.vue b/src/components/ui/calendar/CalendarCell.vue new file mode 100644 index 0000000..53ff2d9 --- /dev/null +++ b/src/components/ui/calendar/CalendarCell.vue @@ -0,0 +1,22 @@ + + + diff --git a/src/components/ui/calendar/CalendarCellTrigger.vue b/src/components/ui/calendar/CalendarCellTrigger.vue new file mode 100644 index 0000000..a4beb75 --- /dev/null +++ b/src/components/ui/calendar/CalendarCellTrigger.vue @@ -0,0 +1,36 @@ + + + diff --git a/src/components/ui/calendar/CalendarGrid.vue b/src/components/ui/calendar/CalendarGrid.vue new file mode 100644 index 0000000..5f52519 --- /dev/null +++ b/src/components/ui/calendar/CalendarGrid.vue @@ -0,0 +1,22 @@ + + + diff --git a/src/components/ui/calendar/CalendarGridBody.vue b/src/components/ui/calendar/CalendarGridBody.vue new file mode 100644 index 0000000..4fe36d7 --- /dev/null +++ b/src/components/ui/calendar/CalendarGridBody.vue @@ -0,0 +1,12 @@ + + + diff --git a/src/components/ui/calendar/CalendarGridHead.vue b/src/components/ui/calendar/CalendarGridHead.vue new file mode 100644 index 0000000..376d70b --- /dev/null +++ b/src/components/ui/calendar/CalendarGridHead.vue @@ -0,0 +1,13 @@ + + + diff --git a/src/components/ui/calendar/CalendarGridRow.vue b/src/components/ui/calendar/CalendarGridRow.vue new file mode 100644 index 0000000..ae99082 --- /dev/null +++ b/src/components/ui/calendar/CalendarGridRow.vue @@ -0,0 +1,19 @@ + + + diff --git a/src/components/ui/calendar/CalendarHeadCell.vue b/src/components/ui/calendar/CalendarHeadCell.vue new file mode 100644 index 0000000..911f909 --- /dev/null +++ b/src/components/ui/calendar/CalendarHeadCell.vue @@ -0,0 +1,19 @@ + + + diff --git a/src/components/ui/calendar/CalendarHeader.vue b/src/components/ui/calendar/CalendarHeader.vue new file mode 100644 index 0000000..706f78b --- /dev/null +++ b/src/components/ui/calendar/CalendarHeader.vue @@ -0,0 +1,19 @@ + + + diff --git a/src/components/ui/calendar/CalendarHeading.vue b/src/components/ui/calendar/CalendarHeading.vue new file mode 100644 index 0000000..3b84ee8 --- /dev/null +++ b/src/components/ui/calendar/CalendarHeading.vue @@ -0,0 +1,29 @@ + + + diff --git a/src/components/ui/calendar/CalendarNextButton.vue b/src/components/ui/calendar/CalendarNextButton.vue new file mode 100644 index 0000000..ae8861c --- /dev/null +++ b/src/components/ui/calendar/CalendarNextButton.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/components/ui/calendar/CalendarPrevButton.vue b/src/components/ui/calendar/CalendarPrevButton.vue new file mode 100644 index 0000000..43e32a0 --- /dev/null +++ b/src/components/ui/calendar/CalendarPrevButton.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/components/ui/calendar/index.ts b/src/components/ui/calendar/index.ts new file mode 100644 index 0000000..f222de0 --- /dev/null +++ b/src/components/ui/calendar/index.ts @@ -0,0 +1,12 @@ +export { default as Calendar } from "./Calendar.vue" +export { default as CalendarCell } from "./CalendarCell.vue" +export { default as CalendarCellTrigger } from "./CalendarCellTrigger.vue" +export { default as CalendarGrid } from "./CalendarGrid.vue" +export { default as CalendarGridBody } from "./CalendarGridBody.vue" +export { default as CalendarGridHead } from "./CalendarGridHead.vue" +export { default as CalendarGridRow } from "./CalendarGridRow.vue" +export { default as CalendarHeadCell } from "./CalendarHeadCell.vue" +export { default as CalendarHeader } from "./CalendarHeader.vue" +export { default as CalendarHeading } from "./CalendarHeading.vue" +export { default as CalendarNextButton } from "./CalendarNextButton.vue" +export { default as CalendarPrevButton } from "./CalendarPrevButton.vue" diff --git a/src/modules/activities/components/CreateEventDialog.vue b/src/modules/activities/components/CreateEventDialog.vue index 2a9861a..1855049 100644 --- a/src/modules/activities/components/CreateEventDialog.vue +++ b/src/modules/activities/components/CreateEventDialog.vue @@ -24,7 +24,6 @@ import { Input } from '@/components/ui/input' import { Textarea } from '@/components/ui/textarea' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' -import { Separator } from '@/components/ui/separator' import { ScrollArea } from '@/components/ui/scroll-area' import { Select, @@ -33,15 +32,12 @@ import { SelectTrigger, SelectValue, } from '@/components/ui/select' -import { - Collapsible, - CollapsibleContent, - CollapsibleTrigger, -} from '@/components/ui/collapsible' -import { Calendar, Loader2, ChevronDown, MapPin } from 'lucide-vue-next' +import { Calendar, Loader2, MapPin } from 'lucide-vue-next' import { toastService } from '@/core/services/ToastService' import { injectService, SERVICE_TOKENS } from '@/core/di-container' import ImageUpload from '@/modules/base/components/ImageUpload.vue' +import DatePicker from '@/modules/base/components/DatePicker.vue' +import TimePicker from '@/modules/base/components/TimePicker.vue' import type { ImageUploadService, UploadedImage } from '@/modules/base/services/ImageUploadService' import type { TicketApiService } from '../services/TicketApiService' import type { CreateEventRequest } from '../types/ticket' @@ -60,18 +56,45 @@ const emit = defineEmits<{ const { t } = useI18n() -const formSchema = toTypedSchema(z.object({ - name: z.string().min(1, "Title is required").max(200, "Title too long"), - info: z.string().max(2000, "Description too long").optional().default(''), - event_start_date: z.string().min(1, "Start date is required"), - event_start_time: z.string().optional().default(''), - event_end_date: z.string().optional().default(''), - event_end_time: z.string().optional().default(''), - location: z.string().max(500).optional().default(''), - currency: z.string().default("sat"), - amount_tickets: z.number().min(0).max(100000).default(0), - price_per_ticket: z.number().min(0).default(0), -})) +// Fold a date input ("YYYY-MM-DD") and an optional time input ("HH:MM") +// into the events-extension wire format: date-only when no time given, +// ISO 8601 datetime otherwise. The publisher switches NIP-52 kinds on +// the "T" delimiter. Hoisted above the schema so the validation refine +// can reuse it. +function foldDateTime(date: string, time: string): string { + if (!date) return '' + return time ? `${date}T${time}` : date +} + +const formSchema = toTypedSchema( + z + .object({ + name: z.string().min(1, "Title is required").max(200, "Title too long"), + info: z.string().max(2000, "Description too long").optional().default(''), + event_start_date: z.string().min(1, "Start date is required"), + event_start_time: z.string().optional().default(''), + event_end_date: z.string().optional().default(''), + event_end_time: z.string().optional().default(''), + location: z.string().max(500).optional().default(''), + currency: z.string().default("sat"), + amount_tickets: z.number().min(0).max(100000).default(0), + price_per_ticket: z.number().min(0).default(0), + }) + .superRefine((v, ctx) => { + // End must not precede start. Compare on the folded date+time + // string so equal-date / later-time is enforced too. + if (!v.event_end_date) return + const start = foldDateTime(v.event_start_date, v.event_start_time) + const end = foldDateTime(v.event_end_date, v.event_end_time) + if (start && end && end < start) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + path: ['event_end_date'], + message: 'End must be on or after start', + }) + } + }) +) const form = useForm({ validationSchema: formSchema, @@ -94,14 +117,21 @@ interface BannerImage extends UploadedImage { } const bannerImages = ref([]) -// Fold a date input ("YYYY-MM-DD") and an optional time input ("HH:MM") -// into the events-extension wire format: date-only when no time given, -// ISO 8601 datetime otherwise. The publisher switches NIP-52 kinds on -// the "T" delimiter. -function foldDateTime(date: string, time: string): string { - if (!date) return '' - return time ? `${date}T${time}` : date -} +// Auto-mirror end date to start: when the user picks a start date, +// surface that same date in the end-date picker so a one-day event +// requires no extra clicks. Don't overwrite an end date the user +// already set *after* the start — only fill when empty or when the +// existing end has fallen behind the new start. +watch( + () => form.values.event_start_date, + (start, prev) => { + if (!start) return + const end = form.values.event_end_date + if (!end || end < start || end === prev) { + form.setFieldValue('event_end_date', start) + } + } +) const paymentService = injectService(SERVICE_TOKENS.PAYMENT_SERVICE) const ticketApi = injectService(SERVICE_TOKENS.TICKET_API) as TicketApiService | null @@ -110,7 +140,6 @@ const imageService = injectService(SERVICE_TOKENS.IMAGE_UPLO const availableCurrencies = ref(['sat']) const loadingCurrencies = ref(false) const selectedCategories = ref([]) -const showMoreOptions = ref(false) watch(() => props.open, async (isOpen) => { if (isOpen && ticketApi && !loadingCurrencies.value) { @@ -125,7 +154,6 @@ watch(() => props.open, async (isOpen) => { } if (!isOpen) { selectedCategories.value = [] - showMoreOptions.value = false } }) @@ -240,21 +268,67 @@ const handleOpenChange = (open: boolean) => {
- + Start date * - + - + Start time - + + + + + +
+ + +
+ + + End date + + + + + + + + + + + End time + (optional) + + + @@ -371,42 +445,6 @@ const handleOpenChange = (open: boolean) => {
- - - - - - - - -
- - - End date - - - - Defaults to start date - - - - - - - End time - - - - - - -
-
-
-