Skip to content

Commit c2622b0

Browse files
committed
simplify the ux
1 parent 1a9f69a commit c2622b0

9 files changed

Lines changed: 721 additions & 977 deletions

File tree

apps/learner-ux/src/App.js

Lines changed: 218 additions & 345 deletions
Large diffs are not rendered by default.

apps/learner-ux/src/App.tsx

Lines changed: 477 additions & 614 deletions
Large diffs are not rendered by default.

apps/learner-ux/src/api.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ const API_OAUTH_CLIENT_SECRET = import.meta.env.VITE_API_OAUTH_CLIENT_SECRET ??
66
const API_OAUTH_SCOPE = import.meta.env.VITE_API_OAUTH_SCOPE ?? "";
77
let tokenCache;
88
export async function fetchLearnerContext(learnerId, options) {
9-
const query = new URLSearchParams();
9+
const query = new URLSearchParams({ learnerId });
1010
if (options?.view)
1111
query.set("view", options.view);
1212
if (options?.stackBy)
1313
query.set("stackBy", options.stackBy);
14-
const suffix = query.toString() ? `?${query.toString()}` : "";
15-
const response = await fetch(buildUrl(`/learners/${encodeURIComponent(learnerId)}/context${suffix}`), {
14+
const response = await fetch(buildUrl(`/learners/by-id/context?${query.toString()}`), {
1615
headers: await authHeaders()
1716
});
1817
if (!response.ok)

apps/learner-ux/src/api.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ export async function fetchLearnerContext(
2020
learnerId: string,
2121
options?: { view?: "timeline"; stackBy?: "day" | "hour" | "session" }
2222
): Promise<LearnerContextResponse> {
23-
const query = new URLSearchParams();
23+
const query = new URLSearchParams({ learnerId });
2424
if (options?.view) query.set("view", options.view);
2525
if (options?.stackBy) query.set("stackBy", options.stackBy);
26-
const suffix = query.toString() ? `?${query.toString()}` : "";
27-
const response = await fetch(buildUrl(`/learners/${encodeURIComponent(learnerId)}/context${suffix}`), {
26+
const response = await fetch(buildUrl(`/learners/by-id/context?${query.toString()}`), {
2827
headers: await authHeaders()
2928
});
3029
if (!response.ok) throw new Error("Failed to load learner context");

apps/learner-ux/src/components/SessionCredentialCard.js

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

apps/learner-ux/src/components/SessionCredentialCard.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export function SessionCredentialCard(props: Readonly<{
1212

1313
return (
1414
<Card>
15-
<div className="mb-3 flex items-center justify-between">
16-
<div>
17-
<h3 className="text-sm font-semibold">{credential.title}</h3>
18-
<p className="text-xs text-slate-600">{credential.issuerId} - {new Date(credential.issuedAt).toLocaleDateString()}</p>
15+
<div className="mb-3 flex items-start justify-between gap-2">
16+
<div className="min-w-0">
17+
<h3 className="text-sm font-semibold break-words">{credential.title}</h3>
18+
<p className="text-xs text-slate-600 break-all">{credential.issuerId} - {new Date(credential.issuedAt).toLocaleDateString()}</p>
1919
{credential.provenance && (
20-
<p className="text-[11px] text-slate-500">
20+
<p className="text-[11px] text-slate-500 break-all">
2121
source {credential.provenance.submissionId} | hash {credential.provenance.payloadHash.slice(0, 12)}
2222
</p>
2323
)}
@@ -29,7 +29,7 @@ export function SessionCredentialCard(props: Readonly<{
2929
const checked = selectedClaimIds.includes(claim.claimId);
3030
return (
3131
<label key={claim.claimId} className="flex items-center justify-between gap-2 rounded border border-slate-100 p-2">
32-
<span className="text-sm">{claim.label}: {String(claim.value)}</span>
32+
<span className="text-sm break-words">{claim.label}: {String(claim.value)}</span>
3333
{!readOnly && (
3434
<input
3535
type="checkbox"
174 KB
Binary file not shown.

lib/constructs/api-construct.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ export class ApiConstruct extends Construct {
7070
integration: learnerContextIntegration,
7171
...(authorizer ? { authorizer } : {})
7272
});
73+
this.api.addRoutes({
74+
path: "/learners/by-id/context",
75+
methods: [HttpMethod.GET],
76+
integration: learnerContextIntegration,
77+
...(authorizer ? { authorizer } : {})
78+
});
7379
this.api.addRoutes({
7480
path: "/users",
7581
methods: [HttpMethod.GET],

services/learner-context-handler/src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ interface HttpEvent {
4040
to?: string;
4141
stackBy?: string;
4242
includeRawEvents?: string;
43+
learnerId?: string;
4344
userId?: string;
4445
};
4546
body?: string | null;
@@ -114,8 +115,11 @@ export async function handler(event: HttpEvent): Promise<{
114115
const method = event.requestContext?.http?.method;
115116
const path = event.rawPath ?? event.requestContext?.http?.path ?? "";
116117

118+
if (method === "GET" && path === "/learners/by-id/context") {
119+
return await handleGetLearnerContext(event, true);
120+
}
117121
if (method === "GET" && path.includes("/learners/") && path.endsWith("/context")) {
118-
return await handleGetLearnerContext(event);
122+
return await handleGetLearnerContext(event, false);
119123
}
120124
if (method === "GET" && path === "/users") {
121125
return await handleListUsers();
@@ -157,13 +161,13 @@ export async function handler(event: HttpEvent): Promise<{
157161
}
158162
}
159163

160-
async function handleGetLearnerContext(event: HttpEvent) {
161-
const learnerId = event.pathParameters?.learnerId;
164+
async function handleGetLearnerContext(event: HttpEvent, fromQuery: boolean) {
165+
const learnerId = fromQuery ? event.queryStringParameters?.learnerId : event.pathParameters?.learnerId;
162166
if (!learnerId) {
163167
return json(400, {
164168
status: "rejected",
165169
reason: "missing_learner_id",
166-
details: ["learnerId path parameter is required."]
170+
details: ["learnerId is required."]
167171
});
168172
}
169173

0 commit comments

Comments
 (0)