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