Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 19x 19x 23x 4x 8x 11x 11x 39x 11x 22x 66x | import { Table2 } from "lucide-react";
import {
type EconomicsStudyRead,
useEconomicsStudiesComparisonRetrieveQuery,
} from "@/api/apiStore.gen";
import { ComparisonEditor } from "./ComparisonEditor";
export function EconomicsComparisonPanel({
study,
canEdit,
}: {
study: EconomicsStudyRead;
canEdit: boolean;
}) {
const comparisonQuery = useEconomicsStudiesComparisonRetrieveQuery({
id: study.id,
});
if (comparisonQuery.isError) {
return (
<section className="rounded-md border bg-background p-3 text-sm text-muted-foreground">
Comparison data could not be loaded.
</section>
);
}
if (comparisonQuery.isLoading || !comparisonQuery.currentData) {
return (
<section className="rounded-md border bg-background p-3">
<div className="flex items-center gap-2 text-sm text-muted-foreground">
<Table2 className="size-4" />
Loading comparison
</div>
</section>
);
}
const editorKey = [
comparisonQuery.currentData.config.updated_at ?? "new",
comparisonQuery.currentData.config.baseline_mode,
comparisonQuery.currentData.config.baseline_study_id,
...comparisonQuery.currentData.config.comparison_study_ids,
].join("-");
return (
<ComparisonEditor
key={editorKey}
study={study}
canEdit={canEdit}
comparison={comparisonQuery.currentData}
onSaved={() => comparisonQuery.refetch()}
/>
);
}
|