18 lines · 995 BRaw
| 1 | import type { Route } from "./+types/repo-tasks"; |
| 2 | import { TaskList } from "@refs/design-system"; |
| 3 | import { found, signedIn, fullName, nowSeconds } from "../lib/session"; |
| 4 | |
| 5 | export const meta: Route.MetaFunction = ({ params }) => [{ title: `Tasks · ${fullName(params)} · refs` }]; |
| 6 | |
| 7 | export async function loader({ request, params, context }: Route.LoaderArgs) { |
| 8 | const search = new URL(request.url).searchParams; |
| 9 | const status = search.get("state") === "closed" ? ("closed" as const) : ("open" as const); |
| 10 | const label = search.get("label") || null; |
| 11 | const list = await found(signedIn(context).tasks({ status, repo: fullName(params), label: label ?? undefined })); |
| 12 | return { repo: fullName(params), status, label, now: nowSeconds(), ...list }; |
| 13 | } |
| 14 | |
| 15 | export default function RepoTasks({ loaderData }: Route.ComponentProps) { |
| 16 | const { repo, ...list } = loaderData; |
| 17 | return <TaskList {...list} base={`/${repo}/tasks`} showRepo={false} newHref={`/tasks/new?repo=${encodeURIComponent(repo)}`} />; |
| 18 | } |