g1t/apps/web/app/routes/workspace/statement-entries.ts
Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| The statement is a month at a time, a line per kind of charge | 1 | import { data } from "react-router"; |
| 2 | ||
| 3 | import type { Route } from "./+types/statement-entries"; | |
| 4 | import { billing } from "../../lib/services.server"; | |
| 5 | import { getViewer } from "../../lib/session.server"; | |
| 6 | ||
| 7 | /** One statement line's entries, 50 at a time, for the billing page to open. */ | |
| 8 | export async function loader({ params, context, request }: Route.LoaderArgs) { | |
| 9 | const query = new URL(request.url).searchParams; | |
| 10 | const entries = await billing.statementEntries(params.owner, getViewer(context), { | |
| 11 | month: query.get("month") ?? "", | |
| 12 | kind: query.get("kind") ?? "", | |
| 13 | day: query.get("day"), | |
| 14 | project: query.get("project"), | |
| 15 | before: query.get("before"), | |
| 16 | }); | |
| 17 | if (!entries.ok) throw data({ error: entries.error.message }, { status: 404 }); | |
| 18 | return Response.json(entries.value, { headers: { "cache-control": "no-store" } }); | |
| 19 | } |