notes.$noteId.tsx — ui Source File
Architecture documentation for notes.$noteId.tsx, a tsx file in the ui codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c50c71cf_2f76_a310_0a77_25e34e7779ce["notes.$noteId.tsx"] ce9dd226_41a3_f031_caf3_5378288c23c1["node"] c50c71cf_2f76_a310_0a77_25e34e7779ce --> ce9dd226_41a3_f031_caf3_5378288c23c1 b969017e_0ead_3c70_277e_2e4416d7a8ed["react"] c50c71cf_2f76_a310_0a77_25e34e7779ce --> b969017e_0ead_3c70_277e_2e4416d7a8ed 6278b776_8865_1d58_5816_0e33545067f6["tiny-invariant"] c50c71cf_2f76_a310_0a77_25e34e7779ce --> 6278b776_8865_1d58_5816_0e33545067f6 81280df8_e680_3b0f_f449_ef98289c6f1f["note.server"] c50c71cf_2f76_a310_0a77_25e34e7779ce --> 81280df8_e680_3b0f_f449_ef98289c6f1f a16e75e5_8d49_95a1_3e98_b347fb9dbfb5["session.server"] c50c71cf_2f76_a310_0a77_25e34e7779ce --> a16e75e5_8d49_95a1_3e98_b347fb9dbfb5 style c50c71cf_2f76_a310_0a77_25e34e7779ce fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import {
Form,
isRouteErrorResponse,
useLoaderData,
useRouteError,
} from "@remix-run/react";
import invariant from "tiny-invariant";
import { deleteNote, getNote } from "~/models/note.server";
import { requireUserId } from "~/session.server";
export const loader = async ({ params, request }: LoaderFunctionArgs) => {
const userId = await requireUserId(request);
invariant(params.noteId, "noteId not found");
const note = await getNote({ id: params.noteId, userId });
if (!note) {
throw new Response("Not Found", { status: 404 });
}
return json({ note });
};
export const action = async ({ params, request }: ActionFunctionArgs) => {
const userId = await requireUserId(request);
invariant(params.noteId, "noteId not found");
await deleteNote({ id: params.noteId, userId });
return redirect("/notes");
};
export default function NoteDetailsPage() {
const data = useLoaderData<typeof loader>();
return (
<div>
<h3 className="text-2xl font-bold">{data.note.title}</h3>
<p className="py-6">{data.note.body}</p>
<hr className="my-4" />
<Form method="post">
<button
type="submit"
className="rounded bg-blue-500 px-4 py-2 text-white hover:bg-blue-600 focus:bg-blue-400"
>
Delete
</button>
</Form>
</div>
);
}
export function ErrorBoundary() {
const error = useRouteError();
if (error instanceof Error) {
return <div>An unexpected error occurred: {error.message}</div>;
}
if (!isRouteErrorResponse(error)) {
return <h1>Unknown Error</h1>;
}
if (error.status === 404) {
return <div>Note not found</div>;
}
return <div>An unexpected error occurred: {error.statusText}</div>;
}
Domain
Subdomains
Dependencies
- node
- note.server
- react
- session.server
- tiny-invariant
Source
Frequently Asked Questions
What does notes.$noteId.tsx do?
notes.$noteId.tsx is a source file in the ui codebase, written in tsx. It belongs to the FrameworkTooling domain, TemplateSync subdomain.
What functions are defined in notes.$noteId.tsx?
notes.$noteId.tsx defines 4 function(s): ErrorBoundary, NoteDetailsPage, action, loader.
What does notes.$noteId.tsx depend on?
notes.$noteId.tsx imports 5 module(s): node, note.server, react, session.server, tiny-invariant.
Where is notes.$noteId.tsx in the architecture?
notes.$noteId.tsx is located at packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/routes/notes.$noteId.tsx (domain: FrameworkTooling, subdomain: TemplateSync, 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