diff --git a/examples/firebase-auth-firestore/app/routes/index.tsx b/examples/firebase-auth-firestore/app/routes/index.tsx index 25a690c4e74..418ec4f3b2a 100644 --- a/examples/firebase-auth-firestore/app/routes/index.tsx +++ b/examples/firebase-auth-firestore/app/routes/index.tsx @@ -34,18 +34,21 @@ export type ActionData = { export const action: ActionFunction = async ({ request }) => { const { uid } = await requireAuth(request); const form = await request.formData(); - if (request.method === "POST") { + const action = form.get("action"); + if (action === "create") { const title = form.get("title"); - if (typeof title !== "string") + if (typeof title !== "string" || title.length === 0) { return json({ error: "title is required" }, { status: 400 }); + } await addTodo(uid, title); return redirect("/"); } - if (request.method === "DELETE") { + if (action === "delete") { const id = form.get("id"); - if (typeof id !== "string") + if (typeof id !== "string") { return json({ error: "id is required" }, { status: 400 }); + } await removeTodo(uid, id); return redirect("/"); } @@ -56,10 +59,12 @@ const TodoComponent: React.FC<{ id: string; title: string }> = (props) => { const fetcher = useFetcher(); return (
  • - + {props.title} - +
  • ); @@ -82,7 +87,9 @@ export default function Index() {

    Create new Todo:

    - +