summaryrefslogtreecommitdiff
path: root/app/routes/list-index.tsx
blob: 799506864eedafbd58d22a1fb17a76a5a915c07d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Link, useLoaderData } from "react-router";
import { listBandLists } from "~/lib/db.server";

export function loader() {
  return { lists: listBandLists() };
}

export default function ListIndex() {
  const { lists } = useLoaderData<typeof loader>();
  return (
    <main>
      <div className="page-header">
        <h1>Lists</h1>
        <Link to="/lists/new">+ List</Link>
      </div>

      {lists.length === 0 ? (
        <p className="muted">
          リストがまだありません。{" "}
          <Link to="/lists/new">作成する</Link>
        </p>
      ) : (
        <ul className="band-list">
          {lists.map((list) => (
            <li key={list.id}>
              <Link to={`/lists/of/${list.id}`}>{list.title}</Link>
              {list.description && (
                <span className="muted" style={{ fontSize: ".75rem" }}>{list.description}</span>
              )}
            </li>
          ))}
        </ul>
      )}
    </main>
  );
}