-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
127 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import { adminRoutes } from "constants/routes"; | ||
import { useLoaderData } from "react-router-dom"; | ||
import Seo from "../Seo"; | ||
import DonationsTable from "./DonationsTable"; | ||
import type { Page } from "./types"; | ||
|
||
export default function Donations() { | ||
const page1 = useLoaderData() as Page; | ||
return ( | ||
<div> | ||
<Seo title="Donations" url={adminRoutes.donations} /> | ||
<h2 className="text-[2rem] font-bold mb-4">Donations</h2> | ||
<DonationsTable /> | ||
<DonationsTable firstPage={page1} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,36 @@ | ||
import { loadAuth } from "auth/load-auth"; | ||
import { APIs } from "constants/urls"; | ||
import { cacheGet } from "helpers/cache-get"; | ||
import type { LoaderFunction } from "react-router-dom"; | ||
import { version as ver } from "services/helpers"; | ||
import * as v from "valibot"; | ||
|
||
export { default as Component } from "./Donations"; | ||
|
||
const id = v.pipe( | ||
v.string(), | ||
v.transform((x) => +x), | ||
v.number(), | ||
v.integer(), | ||
v.minValue(1), | ||
v.transform((x) => x.toString()) | ||
); | ||
|
||
export const loader: LoaderFunction = async ({ params, request }) => { | ||
const from = new URL(request.url); | ||
const page = from.searchParams.get("page") ?? "1"; | ||
|
||
const auth = await loadAuth(); | ||
if (!auth) throw `user must have been authenticated at this point`; | ||
|
||
const url = new URL(APIs.aws); | ||
url.pathname = `${ver(2)}/donations`; | ||
url.searchParams.set("asker", v.parse(id, params.id)); | ||
url.searchParams.set("status", "final"); | ||
url.searchParams.set("page", page); | ||
|
||
const req = new Request(url); | ||
req.headers.set("authorization", auth.idToken); | ||
|
||
return cacheGet(req); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type { Donation } from "types/aws"; | ||
|
||
export type Page = { Items: Donation.Record[]; nextPage?: number }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters