feat: Added TypeScript version types, fetchTechniqueVersions function,…
- "frontend/src/api/public-client.ts" - "frontend/src/pages/TechniquePage.tsx" GSD-Task: S04/T03
This commit is contained in:
parent
872ffe0543
commit
2a07583d6d
2 changed files with 31 additions and 1 deletions
|
|
@ -68,6 +68,18 @@ export interface TechniquePageDetail {
|
||||||
key_moments: KeyMomentSummary[];
|
key_moments: KeyMomentSummary[];
|
||||||
creator_info: CreatorInfo | null;
|
creator_info: CreatorInfo | null;
|
||||||
related_links: RelatedLinkItem[];
|
related_links: RelatedLinkItem[];
|
||||||
|
version_count: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TechniquePageVersionSummary {
|
||||||
|
version_number: number;
|
||||||
|
created_at: string;
|
||||||
|
pipeline_metadata: Record<string, unknown> | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TechniquePageVersionListResponse {
|
||||||
|
items: TechniquePageVersionSummary[];
|
||||||
|
total: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TechniqueListItem {
|
export interface TechniqueListItem {
|
||||||
|
|
@ -217,6 +229,14 @@ export async function fetchTechnique(
|
||||||
return request<TechniquePageDetail>(`${BASE}/techniques/${slug}`);
|
return request<TechniquePageDetail>(`${BASE}/techniques/${slug}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function fetchTechniqueVersions(
|
||||||
|
slug: string,
|
||||||
|
): Promise<TechniquePageVersionListResponse> {
|
||||||
|
return request<TechniquePageVersionListResponse>(
|
||||||
|
`${BASE}/techniques/${slug}/versions`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// ── Topics ───────────────────────────────────────────────────────────────────
|
// ── Topics ───────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export async function fetchTopics(): Promise<TopicCategory[]> {
|
export async function fetchTopics(): Promise<TopicCategory[]> {
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,17 @@ export default function TechniquePage() {
|
||||||
"en-US",
|
"en-US",
|
||||||
{ year: "numeric", month: "short", day: "numeric" },
|
{ year: "numeric", month: "short", day: "numeric" },
|
||||||
);
|
);
|
||||||
return `Compiled from ${sourceCount} source${sourceCount !== 1 ? "s" : ""} · ${momentCount} key moment${momentCount !== 1 ? "s" : ""} · Last updated ${updated}`;
|
const parts = [
|
||||||
|
`Compiled from ${sourceCount} source${sourceCount !== 1 ? "s" : ""}`,
|
||||||
|
`${momentCount} key moment${momentCount !== 1 ? "s" : ""}`,
|
||||||
|
];
|
||||||
|
if (technique.version_count > 0) {
|
||||||
|
parts.push(
|
||||||
|
`${technique.version_count} version${technique.version_count !== 1 ? "s" : ""}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
parts.push(`Last updated ${updated}`);
|
||||||
|
return parts.join(" · ");
|
||||||
})()}
|
})()}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue