import { Form, useLoaderData } from "@remix-run/react"; import type { FunctionComponent } from "react"; import type { LoaderFunctionArgs } from "@remix-run/node"; import type { ContactRecord } from "../data"; import { getContact } from "../data"; import invariant from "tiny-invariant"; export const loader = async ({ params, }: LoaderFunctionArgs) => { invariant(params.contactId, "Missing contactId param"); const contact = await getContact(params.contactId); if (!contact) { throw new Response("Not Found", {status: 404}); } return { contact }; }; export default function Contact() { const { contact } = useLoaderData(); return (
{`${contact.first}

{contact.first || contact.last ? ( <> {contact.first} {contact.last} ) : ( No Name )}{" "}

{contact.twitter ? (

{contact.twitter}

) : null} {contact.notes ?

{contact.notes}

: null}
{ const response = confirm( "Please confirm you want to delete this record." ); if (!response) { event.preventDefault(); } }} >
); } const Favorite: FunctionComponent<{ contact: Pick; }> = ({ contact }) => { const favorite = contact.favorite; return (
); };