This commit is contained in:
2025-02-18 14:43:53 +01:00
parent 2c0cd3c42d
commit 7e2a48a469
3 changed files with 48 additions and 36 deletions
+14 -5
View File
@@ -1,6 +1,6 @@
'use client';
import { useCalendarApp, ScheduleXCalendar } from '@schedule-x/react';
import { CalendarEventExternal, createViewWeek } from '@schedule-x/calendar';
import { createViewWeek } from '@schedule-x/calendar';
import { createEventsServicePlugin } from '@schedule-x/events-service';
import { createDragAndDropPlugin } from '@schedule-x/drag-and-drop';
@@ -59,15 +59,21 @@ function CalendarApp() {
const target = event.target as HTMLElement;
if (target.className === 'sx__time-grid-event-time') {
setSelected(
const id =
target.parentElement?.parentElement?.getAttribute(
'data-event-id'
);
setSelected(id);
setDate(
parse(
calendar.events.get(parseInt(id || ''))?.start || '',
'y-MM-dd hh:mm',
new Date()
)
);
return;
} else {
setSelected(null);
}
try {
const dayElement = target.closest('.sx__time-grid-day');
@@ -86,7 +92,9 @@ function CalendarApp() {
event.preventDefault();
} else {
const toDate = parse(
(dayText || '') + ' ' + (hourElement?.textContent || ''),
(dayText || '') +
' ' +
(hourElement?.textContent || ''),
'MMMM dd, yyyy h a',
new Date()
);
@@ -94,6 +102,7 @@ function CalendarApp() {
setDate(toDate);
}
} catch {}
}
};
return (
+3 -1
View File
@@ -45,7 +45,9 @@ export default function PostDialog({
<DialogContent>
<DialogHeader>
<DialogTitle>New post</DialogTitle>
<DialogDescription>Schedule posts on multiple accounts</DialogDescription>
<DialogDescription>
Schedule posts on multiple accounts
</DialogDescription>
</DialogHeader>
<div className="flex flex-row gap-4">
<Popover>
+9 -8
View File
@@ -1,9 +1,3 @@
import {
Popover,
PopoverContent,
PopoverTrigger,
} from '@/components/ui/popover';
import { Button } from '@/components/ui/button';
import {
Select,
SelectContent,
@@ -24,7 +18,12 @@ const TimeSelect: React.FC<TimeSelectProps> = ({
className,
}) => {
const times = Array.from({ length: 24 }, (_, h) =>
[0, 15, 30, 45].map((m) => `${h.toString().padStart(2, '0')}:${m.toString().padStart(2, '0')}`)
[0, 15, 30, 45].map(
(m) =>
`${(h+1).toString().padStart(2, '0')}:${m
.toString()
.padStart(2, '0')}`
)
).flat();
const currentHour = date.getHours().toString().padStart(2, '0');
@@ -34,7 +33,9 @@ const TimeSelect: React.FC<TimeSelectProps> = ({
? curr
: prev
);
const selectedTime = `${currentHour}:${nearestMinute.toString().padStart(2, '0')}`;
const selectedTime = `${currentHour}:${nearestMinute
.toString()
.padStart(2, '0')}`;
const handleTimeChange = (newTime: string) => {
const [hour, minute] = newTime.split(':').map(Number);