Skip to content

Commit c77c016

Browse files
fix
1 parent 7ce790e commit c77c016

File tree

2 files changed

+108
-10
lines changed

2 files changed

+108
-10
lines changed

api/.sqlx/query-b51c548092ff640f6d210365a4fb79d8d22a7868b9da6896b068e0cc0fa1298d.json

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/routes/user/[id].tsx

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { HttpError } from "fresh";
33
import { define } from "../../util.ts";
44
import { path } from "../../utils/api.ts";
5-
import { FullUser, Scope, User } from "../../utils/api_types.ts";
5+
import { FullUser, Package, Scope, User } from "../../utils/api_types.ts";
66
import { ListPanel } from "../../components/ListPanel.tsx";
77
import { AccountLayout } from "../account/(_components)/AccountLayout.tsx";
88

@@ -32,25 +32,39 @@ export default define.page<typeof handler>(function UserPage({ data, state }) {
3232
</div>
3333
)}
3434

35-
{
36-
/*<div>
37-
<span class="font-semibold">Recently published</span>
38-
<div class="text-tertiary text-base"
39-
TODO: all packages recently published by this user
40-
</div>
41-
</div>*/
42-
}
35+
{data.packages.length > 0
36+
? (
37+
<ListPanel
38+
title="Recently published"
39+
subtitle={state.user?.id === data.user.id
40+
? "Packages you have published."
41+
: "Packages this user has published."}
42+
// deno-lint-ignore jsx-no-children-prop
43+
children={data.packages.map((pkg) => ({
44+
value: `@${pkg.scope}/${pkg.name}`,
45+
href: `/@${pkg.scope}/${pkg.name}`,
46+
}))}
47+
/>
48+
)
49+
: (
50+
<div class="p-3 text-jsr-gray-500 text-center italic">
51+
{state.user?.id === data.user.id ? "You have" : "This user has"}
52+
{" "}
53+
not published any packages recently.
54+
</div>
55+
)}
4356
</div>
4457
</AccountLayout>
4558
);
4659
});
4760

4861
export const handler = define.handlers({
4962
async GET(ctx) {
50-
const [currentUser, userRes, scopesRes] = await Promise.all([
63+
const [currentUser, userRes, scopesRes, packagesRes] = await Promise.all([
5164
ctx.state.userPromise,
5265
ctx.state.api.get<User>(path`/users/${ctx.params.id}`),
5366
ctx.state.api.get<Scope[]>(path`/users/${ctx.params.id}/scopes`),
67+
ctx.state.api.get<Package[]>(path`/users/${ctx.params.id}/packages`),
5468
]);
5569
if (currentUser instanceof Response) return currentUser;
5670

@@ -62,6 +76,7 @@ export const handler = define.handlers({
6276
throw userRes; // gracefully handle errors
6377
}
6478
if (!scopesRes.ok) throw scopesRes; // gracefully handle errors
79+
if (!packagesRes.ok) throw packagesRes; // gracefully handle errors
6580

6681
let user: User | FullUser = userRes.data;
6782
if (ctx.params.id === currentUser?.id) {
@@ -75,6 +90,7 @@ export const handler = define.handlers({
7590
data: {
7691
user,
7792
scopes: scopesRes.data,
93+
packages: packagesRes.data,
7894
},
7995
};
8096
},

0 commit comments

Comments
 (0)