+ + Indie Stack + +
++ Check the README.md file for instructions on how to get this + project deployed. +
++ Check the README.md file for instructions on how to get this + project deployed. +
+{data.note.body}
++ No note selected. Select a note on the left, or{" "} + + create a new note. + +
+ ); +} diff --git a/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/routes/notes.new.tsx b/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/routes/notes.new.tsx new file mode 100644 index 00000000000..48dd52de7f4 --- /dev/null +++ b/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/routes/notes.new.tsx @@ -0,0 +1,109 @@ +import type { ActionFunctionArgs } from "@remix-run/node"; +import { json, redirect } from "@remix-run/node"; +import { Form, useActionData } from "@remix-run/react"; +import { useEffect, useRef } from "react"; + +import { createNote } from "~/models/note.server"; +import { requireUserId } from "~/session.server"; + +export const action = async ({ request }: ActionFunctionArgs) => { + const userId = await requireUserId(request); + + const formData = await request.formData(); + const title = formData.get("title"); + const body = formData.get("body"); + + if (typeof title !== "string" || title.length === 0) { + return json( + { errors: { body: null, title: "Title is required" } }, + { status: 400 }, + ); + } + + if (typeof body !== "string" || body.length === 0) { + return json( + { errors: { body: "Body is required", title: null } }, + { status: 400 }, + ); + } + + const note = await createNote({ body, title, userId }); + + return redirect(`/notes/${note.id}`); +}; + +export default function NewNotePage() { + const actionData = useActionData{user.email}
+ +No notes yet
+ ) : ( +