diff --git a/frontend/src/app/api/arrangementer/[id]/route.ts b/frontend/src/app/api/arrangementer/[id]/route.ts index 436642e..b5c1818 100644 --- a/frontend/src/app/api/arrangementer/[id]/route.ts +++ b/frontend/src/app/api/arrangementer/[id]/route.ts @@ -58,13 +58,13 @@ export async function PUT( try { const { id } = params; const body = await req.json(); - const validatedData = createArrangementSchema.parse({ - ...body, - }); - + // console.log(body); + // const validatedData = createArrangementSchema.parse({ + // ...body, + // }); const updatedEvent = await db.arrangement.update({ where: { id }, - data: validatedData, + data: body, }); if (!updatedEvent) { diff --git a/frontend/src/components/admin/arrangementForm.tsx b/frontend/src/components/admin/arrangementForm.tsx index 2bdd402..a0efdd3 100644 --- a/frontend/src/components/admin/arrangementForm.tsx +++ b/frontend/src/components/admin/arrangementForm.tsx @@ -57,8 +57,10 @@ const ArrangementComponentNew = () => { const [imagePreview, setImagePreview] = useState(null); const [isEditMode, setIsEditMode] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false); + const [refreshKey, setRefreshKey] = useState(0); const { data, loading, error } = useFetch<{ data: Arrangement[] }>( "/api/arrangementer", + refreshKey, ); const form = useForm>({ @@ -78,7 +80,7 @@ const ArrangementComponentNew = () => { if (data && data.data) { setEvents(data.data); } - }, [data]); + }, [data, refreshKey]); const handleCreateEvent = () => { setSelectedEvent(null); @@ -221,6 +223,7 @@ const ArrangementComponentNew = () => { setImageFile(null); setImagePreview(null); setIsModalOpen(false); + setRefreshKey((prevState) => prevState + 1); } catch (error) { console.error("Error submitting form:", error); } finally { @@ -349,7 +352,7 @@ const ArrangementComponentNew = () => { - + {isEditMode ? "Rediger arrangement" : "Lag nytt arrangement"}