Compare commits

..

1 commit

Author SHA1 Message Date
f562de5e9f
feat(blocked_slots): add blocked slots
Some checks failed
container-scan / Container Scan (pull_request) Failing after 1m23s
docker-build / docker (pull_request) Failing after 3m4s
tests / Tests (pull_request) Failing after 2m23s
2025-06-30 20:26:59 +02:00
4 changed files with 34 additions and 18 deletions

View file

@ -1,5 +1,9 @@
import BlockedSlotForm from '@/components/forms/blocked-slot-form'; import BlockedSlotForm from '@/components/forms/blocked-slot-form';
export default function NewBlockedSlotPage({ params }: { params: { slotId?: string } }) { export default function NewBlockedSlotPage({
params,
}: {
params: { slotId?: string };
}) {
return <BlockedSlotForm existingBlockedSlotId={params.slotId} />; return <BlockedSlotForm existingBlockedSlotId={params.slotId} />;
} }

View file

@ -11,7 +11,9 @@ export default function BlockedSlots() {
if (isLoading) return <div className='text-center mt-10'>Loading...</div>; if (isLoading) return <div className='text-center mt-10'>Loading...</div>;
if (error) if (error)
return ( return (
<div className='text-center mt-10 text-red-500'>Error loading blocked slots</div> <div className='text-center mt-10 text-red-500'>
Error loading blocked slots
</div>
); );
const blockedSlots = blockedSlotsData?.data?.blocked_slots || []; const blockedSlots = blockedSlotsData?.data?.blocked_slots || [];

View file

@ -54,11 +54,15 @@ export const GET = auth(async function GET(req, { params }) {
); );
} }
return returnZodTypeCheckedResponse(BlockedSlotResponseSchema, { return returnZodTypeCheckedResponse(
blocked_slot: blockedSlot, BlockedSlotResponseSchema,
}, { {
status: 200, blocked_slot: blockedSlot,
}); },
{
status: 200,
},
);
}); });
export const PATCH = auth(async function PATCH(req, { params }) { export const PATCH = auth(async function PATCH(req, { params }) {

View file

@ -20,7 +20,10 @@ import Logo from '../misc/logo';
import { eventStartTimeSchema } from '@/app/api/event/validation'; import { eventStartTimeSchema } from '@/app/api/event/validation';
import zod from 'zod/v4'; import zod from 'zod/v4';
const dateForDateTimeInputValue = (date: Date) => new Date(date.getTime() + new Date().getTimezoneOffset() * -60 * 1000).toISOString().slice(0, 19) const dateForDateTimeInputValue = (date: Date) =>
new Date(date.getTime() + new Date().getTimezoneOffset() * -60 * 1000)
.toISOString()
.slice(0, 19);
export default function BlockedSlotForm({ export default function BlockedSlotForm({
existingBlockedSlotId, existingBlockedSlotId,
@ -109,18 +112,21 @@ export default function BlockedSlotForm({
]); ]);
const onUpdateSubmit = handleUpdateSubmit(async (data) => { const onUpdateSubmit = handleUpdateSubmit(async (data) => {
await updateBlockedSlot({ await updateBlockedSlot(
data: { {
...data, data: {
start_time: new Date(data.start_time).toISOString(), ...data,
end_time: new Date(data.end_time).toISOString(), start_time: new Date(data.start_time).toISOString(),
end_time: new Date(data.end_time).toISOString(),
},
slotID: existingBlockedSlotId || '',
}, },
slotID: existingBlockedSlotId || '', {
}, { onSuccess: () => {
onSuccess: () => { router.back();
router.back(); },
}, },
}); );
}); });
const onDeleteSubmit = async () => { const onDeleteSubmit = async () => {