
22 | 23 | Indie Stack 24 | 25 |
26 |27 | Check the README.md file for instructions on how to get this 28 | project deployed. 29 |
30 |27 | Check the README.md file for instructions on how to get this 28 | project deployed. 29 |
30 |{user.email}
30 | 38 |No notes yet
50 | ) : ( 51 |{data.note.body}
42 |6 | No note selected. Select a note on the left, or{" "} 7 | 8 | create a new note. 9 | 10 |
11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /app/routes/notes/new.tsx: -------------------------------------------------------------------------------- 1 | import type { ActionFunction } from "@remix-run/node"; 2 | import { json, redirect } from "@remix-run/node"; 3 | import { Form, useActionData } from "@remix-run/react"; 4 | import * as React from "react"; 5 | 6 | import { createNote } from "~/models/note.server"; 7 | import { requireUserId } from "~/session.server"; 8 | 9 | type ActionData = { 10 | errors?: { 11 | title?: string; 12 | body?: string; 13 | }; 14 | }; 15 | 16 | export const action: ActionFunction = async ({ request }) => { 17 | const userId = await requireUserId(request); 18 | 19 | const formData = await request.formData(); 20 | const title = formData.get("title"); 21 | const body = formData.get("body"); 22 | 23 | if (typeof title !== "string" || title.length === 0) { 24 | return json