Skip to content

Commit

Permalink
Fix missing import in /multiple-forms example (#467)
Browse files Browse the repository at this point in the history
Co-authored-by: Mehdi Achour <machour@gmail.com>
  • Loading branch information
petecartwright and machour committed May 17, 2024
1 parent 92a17e8 commit b5e8bc6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion multiple-forms/app/data.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function writeInvitations(invitations: Array<Invitation>) {
return fs.writeFile("./data.json", JSON.stringify({ invitations }, null, 2));
}

export async function deleteInvitiation(invitation: Invitation) {
export async function deleteInvitation(invitation: Invitation) {
const invitations = await getInvitations();
await writeInvitations(invitations.filter((i) => i.id !== invitation.id));
}
Expand Down
7 changes: 4 additions & 3 deletions multiple-forms/app/routes/invitations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { json, redirect } from "@remix-run/node";
import { Form, useLoaderData } from "@remix-run/react";

import {
deleteInvitation,
getInvitations,
resendInvitation,
sendInvitation,
Expand Down Expand Up @@ -30,8 +31,8 @@ export const action = async ({ request }: ActionArgs) => {
// you'll want to handle this in a real app...
throw new Error("make sure you implement validation");
}
const invitiations = await getInvitations();
const invitation = invitiations.find((i) => i.id === invitationId);
const invitations = await getInvitations();
const invitation = invitations.find((i) => i.id === invitationId);
if (!invitation) {
// you'll want to handle this in a real app...
throw new Error("make sure you implement validation");
Expand All @@ -42,7 +43,7 @@ export const action = async ({ request }: ActionArgs) => {
return redirect(request.url);
}
if (formData.get("intent") === "delete") {
await deleteInvitiation(invitation);
await deleteInvitation(invitation);
return redirect(request.url);
}
};
Expand Down

0 comments on commit b5e8bc6

Please sign in to comment.