diff --git a/packages/iceform-next-sandbox/src/pages/a/notes/[noteId].ts b/packages/iceform-next-sandbox/src/pages/a/notes/[noteId].ts index 9f7d994..4986fea 100644 --- a/packages/iceform-next-sandbox/src/pages/a/notes/[noteId].ts +++ b/packages/iceform-next-sandbox/src/pages/a/notes/[noteId].ts @@ -6,6 +6,18 @@ const ActionNotesResourcePage: NextPage = () => null; const getServerSideProps = Iceform.action.getServerSideProps({ fn: noteResource, + onAction: async (context) => { + if (context.req.method?.toLowerCase() === 'delete') { + return { + redirect: { + destination: '/notes', + permanent: false, + }, + }; + } + + // use default behavior + }, }); export { diff --git a/packages/iceform-next-sandbox/src/pages/notes/[noteId].tsx b/packages/iceform-next-sandbox/src/pages/notes/[noteId].tsx index 18efec1..7d94bcf 100644 --- a/packages/iceform-next-sandbox/src/pages/notes/[noteId].tsx +++ b/packages/iceform-next-sandbox/src/pages/notes/[noteId].tsx @@ -1,11 +1,21 @@ import * as Iceform from '@modal-sh/iceform-next'; import * as React from 'react'; -const NotesItemPage: Iceform.NextPage = ({ +export interface NotesItemPageProps { + note: { + id: string; + title: string; + content: string; + image: string; + } +} + +const NotesItemPage: Iceform.NextPage = ({ req, res, + note, }) => { - const body = (res.body ?? {}) as Record; + const body = (res.body ?? note ?? {}) as Record; const {response, loading, ...isoformProps} = Iceform.useResponse({ res }); @@ -26,22 +36,23 @@ const NotesItemPage: Iceform.NextPage = ({ method="post" action={`/a/notes/${req.query.noteId}`} clientAction={`/api/notes/${req.query.noteId}`} + clientMethod="put" >