working calendar, code may be messy

This commit is contained in:
2025-02-27 17:50:26 +01:00
parent a4b75596c7
commit 09d6fcc0dd
5 changed files with 183 additions and 147 deletions
+10 -13
View File
@@ -26,6 +26,7 @@ import { Label } from '@/components/ui/label';
import { useState } from 'react';
import axios from 'axios';
import { PostRequest, ScheduleRequest } from '@/utils';
import { CalendarSchedule } from './calendar';
type PostDialogProps = {
newPostDialogOpen: boolean;
@@ -33,7 +34,7 @@ type PostDialogProps = {
date: Date;
setDate: (d: Date) => void;
eventId: number;
setEvents: (e: CalendarEventExternal) => void;
setEvents: (e: CalendarSchedule) => void;
sessionId: string;
};
@@ -137,24 +138,20 @@ export default function PostDialog({
Post now
</Button>
<Button
onClick={() => {
const end = new Date(date);
end.setHours(date.getHours() + 1);
addEvent({
title: 'Post',
id: eventId,
start: format(date, 'y-MM-dd hh:mm'),
end: format(end, 'y-MM-dd hh:mm'),
});
axios.put('/api/posts', {
onClick={async () => {
const { data } = await axios.put('/api/posts', {
scheduled: format(date, 'y-MM-dd hh:mm'),
sessionId,
platforms: ['andjksds'],
content,
} satisfies ScheduleRequest);
addEvent({
id: data.id,
date,
platforms: [{ user: 'andjksds' }],
});
setNewPostDialogOpen(false);
}}
>