Compare commits

..

1 commit

Author SHA1 Message Date
f3a7de357e
feat(blocked_slots): add blocked slots
Some checks failed
container-scan / Container Scan (pull_request) Failing after 35s
docker-build / docker (pull_request) Failing after 2m12s
tests / Tests (pull_request) Failing after 1m55s
2025-06-30 20:13:56 +02:00
4 changed files with 18 additions and 34 deletions

View file

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

View file

@ -11,9 +11,7 @@ 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'> <div className='text-center mt-10 text-red-500'>Error loading blocked slots</div>
Error loading blocked slots
</div>
); );
const blockedSlots = blockedSlotsData?.data?.blocked_slots || []; const blockedSlots = blockedSlotsData?.data?.blocked_slots || [];

View file

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

View file

@ -20,10 +20,7 @@ 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) => const dateForDateTimeInputValue = (date: Date) => new Date(date.getTime() + new Date().getTimezoneOffset() * -60 * 1000).toISOString().slice(0, 19)
new Date(date.getTime() + new Date().getTimezoneOffset() * -60 * 1000)
.toISOString()
.slice(0, 19);
export default function BlockedSlotForm({ export default function BlockedSlotForm({
existingBlockedSlotId, existingBlockedSlotId,
@ -112,21 +109,18 @@ export default function BlockedSlotForm({
]); ]);
const onUpdateSubmit = handleUpdateSubmit(async (data) => { const onUpdateSubmit = handleUpdateSubmit(async (data) => {
await updateBlockedSlot( await updateBlockedSlot({
{ data: {
data: { ...data,
...data, start_time: new Date(data.start_time).toISOString(),
start_time: new Date(data.start_time).toISOString(), end_time: new Date(data.end_time).toISOString(),
end_time: new Date(data.end_time).toISOString(),
},
slotID: existingBlockedSlotId || '',
}, },
{ slotID: existingBlockedSlotId || '',
onSuccess: () => { }, {
router.back(); onSuccess: () => {
}, router.back();
}, },
); });
}); });
const onDeleteSubmit = async () => { const onDeleteSubmit = async () => {