Skip to content

Commit

Permalink
Fix redirecting logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperpeulen committed May 15, 2024
1 parent a3353a6 commit 2a1c3b3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ export async function saveNote(
}

if (!noteId) {
await db.note.create({ data: payload })
} else {
await db.note.update({
where: { id: noteId },
data: payload,
})
const newNote = await db.note.create({ data: payload })
redirect(`/note/${newNote.id}`)
}

await db.note.update({
where: { id: noteId },
data: payload,
})
redirect(`/note/${noteId}`)
}

Expand Down

0 comments on commit 2a1c3b3

Please sign in to comment.