notes.new.tsx — ui Source File
Architecture documentation for notes.new.tsx, a tsx file in the ui codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 2f3ed508_f176_75d1_4058_09e604e2f1cb["notes.new.tsx"] ce9dd226_41a3_f031_caf3_5378288c23c1["node"] 2f3ed508_f176_75d1_4058_09e604e2f1cb --> ce9dd226_41a3_f031_caf3_5378288c23c1 b969017e_0ead_3c70_277e_2e4416d7a8ed["react"] 2f3ed508_f176_75d1_4058_09e604e2f1cb --> b969017e_0ead_3c70_277e_2e4416d7a8ed 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] 2f3ed508_f176_75d1_4058_09e604e2f1cb --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 81280df8_e680_3b0f_f449_ef98289c6f1f["note.server"] 2f3ed508_f176_75d1_4058_09e604e2f1cb --> 81280df8_e680_3b0f_f449_ef98289c6f1f a16e75e5_8d49_95a1_3e98_b347fb9dbfb5["session.server"] 2f3ed508_f176_75d1_4058_09e604e2f1cb --> a16e75e5_8d49_95a1_3e98_b347fb9dbfb5 style 2f3ed508_f176_75d1_4058_09e604e2f1cb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
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<typeof action>();
const titleRef = useRef<HTMLInputElement>(null);
const bodyRef = useRef<HTMLTextAreaElement>(null);
useEffect(() => {
if (actionData?.errors?.title) {
titleRef.current?.focus();
} else if (actionData?.errors?.body) {
bodyRef.current?.focus();
}
}, [actionData]);
return (
<Form
method="post"
style={{
display: "flex",
flexDirection: "column",
gap: 8,
width: "100%",
}}
>
<div>
<label className="flex w-full flex-col gap-1">
<span>Title: </span>
<input
ref={titleRef}
name="title"
className="flex-1 rounded-md border-2 border-blue-500 px-3 text-lg leading-loose"
aria-invalid={actionData?.errors?.title ? true : undefined}
aria-errormessage={
actionData?.errors?.title ? "title-error" : undefined
}
/>
</label>
{actionData?.errors?.title ? (
<div className="pt-1 text-red-700" id="title-error">
{actionData.errors.title}
</div>
) : null}
</div>
<div>
<label className="flex w-full flex-col gap-1">
<span>Body: </span>
<textarea
ref={bodyRef}
name="body"
rows={8}
className="w-full flex-1 rounded-md border-2 border-blue-500 px-3 py-2 text-lg leading-6"
aria-invalid={actionData?.errors?.body ? true : undefined}
aria-errormessage={
actionData?.errors?.body ? "body-error" : undefined
}
/>
</label>
{actionData?.errors?.body ? (
<div className="pt-1 text-red-700" id="body-error">
{actionData.errors.body}
</div>
) : null}
</div>
<div className="text-right">
<button
type="submit"
className="rounded bg-blue-500 px-4 py-2 text-white hover:bg-blue-600 focus:bg-blue-400"
>
Save
</button>
</div>
</Form>
);
}
Domain
Subdomains
Functions
Dependencies
- node
- note.server
- react
- react
- session.server
Source
Frequently Asked Questions
What does notes.new.tsx do?
notes.new.tsx is a source file in the ui codebase, written in tsx. It belongs to the FrameworkTooling domain, SchemaValidation subdomain.
What functions are defined in notes.new.tsx?
notes.new.tsx defines 2 function(s): NewNotePage, action.
What does notes.new.tsx depend on?
notes.new.tsx imports 5 module(s): node, note.server, react, react, session.server.
Where is notes.new.tsx in the architecture?
notes.new.tsx is located at packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/routes/notes.new.tsx (domain: FrameworkTooling, subdomain: SchemaValidation, directory: packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/routes).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free