Files
BuyingAgent/frontend/src/pages/CandidateDetailPage.tsx
T
LarsandCursor b276758ee1
Deploy Development / deploy (push) Successful in 1m19s
Test Suite / pytest-backend (push) Successful in 31s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-checks (push) Successful in 28s
Stelle den Frontend-MVP und die v0.3-API auf develop bereit, damit Dev API und PWA zusammen deployen.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-04 13:04:59 +02:00

54 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useQuery } from "@tanstack/react-query";
import { useParams } from "react-router-dom";
import { api } from "../api";
import { EmptyState, ErrorState, LoadingState } from "../components/State";
export function CandidateDetailPage() {
const { projectId = "", candidateId = "" } = useParams();
const detail = useQuery({
queryKey: ["candidate", projectId, candidateId],
queryFn: () => api.candidate(projectId, candidateId),
});
const history = useQuery({
queryKey: ["observations", projectId, candidateId],
queryFn: () => api.observations(projectId, candidateId),
});
if (detail.isLoading) return <LoadingState />;
if (detail.isError) return <ErrorState message={(detail.error as Error).message} />;
const item = detail.data!;
return (
<section className="grid">
<h1>{item.title}</h1>
<div className="card">
<p>
{item.manufacturer} {item.model}
</p>
<p>
Preis: {item.current_best_price || "–"} {item.currency || ""}
</p>
<p>Ranking: {item.ranking_status}</p>
<p>Diff: {item.current_diff_status}</p>
<p>Lifecycle: {item.product_lifecycle_status}</p>
</div>
<div className="card">
<h2>Attribute</h2>
{(item.current_dynamic_attributes || []).map((attr) => (
<p key={attr.raw_name}>
{attr.raw_name}: {String(attr.normalized_value ?? "")} {attr.unit || ""}
</p>
))}
</div>
<div className="card">
<h2>Historie</h2>
{history.isLoading ? <LoadingState /> : null}
{(history.data?.items || []).length === 0 ? <EmptyState>Noch keine Beobachtungen.</EmptyState> : null}
{(history.data?.items || []).map((obs) => (
<p key={obs.observation_id}>
{obs.observed_at}: {obs.best_price} {obs.currency}
</p>
))}
</div>
</section>
);
}