8000 fix typescript and show badge of type of edit · ag-python/screenshot-to-code@8675d28 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8675d28

Browse files
committed
fix typescript and show badge of type of edit
1 parent b3b478d commit 8675d28

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

frontend/src/components/history/HistoryDisplay.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { History } from "./history_types";
1+
import { History, HistoryItemType } from "./history_types";
22
import toast from "react-hot-toast";
33
import classNames from "classnames";
44
import {
55
HoverCard,
66
HoverCardTrigger,
77
HoverCardContent,
88
} from "../ui/hover-card";
9+
import { Badge } from "../ui/badge";
910

1011
interface Props {
1112
history: History;
@@ -14,17 +15,18 @@ interface Props {
1415
shouldDisableReverts: boolean;
1516
}
1617

17-
// function displayHistoryItemType(itemType: HistoryItemType) {
18 10000 -
// switch (itemType) {
19-
// case "ai_create":
20-
// return "Create";
21-
// case "ai_edit":
22-
// return "Edit";
23-
// default:
24-
// // TODO: Error out since this is exhaustive
25-
// return "Unknown";
26-
// }
27-
// }
18+
function displayHistoryItemType(itemType: HistoryItemType) {
19+
switch (itemType) {
20+
case "ai_create":
21+
return "Create";
22+
case "ai_edit":
23+
return "Edit";
24+
default: {
25+
const exhaustiveCheck: never = itemType;
26+
throw new Error(`Unhandled case: ${exhaustiveCheck}`);
27+
}
28+
}
29+
}
2830

2931
export default function HistoryDisplay({
3032
history,
@@ -73,7 +75,10 @@ export default function HistoryDisplay({
7375
<h2 className="text-sm">v{index + 1}</h2>
7476
</HoverCardTrigger>
7577
<HoverCardContent>
76-
{item.type === "ai_edit" ? item.inputs.prompt : "Create"}
78+
<div>
79+
{item.type === "ai_edit" ? item.inputs.prompt : "Create"}
80+
</div>
81+
<Badge>{displayHistoryItemType(item.type)}</Badge>
7782
</HoverCardContent>
7883
</HoverCard>
7984
</li>

0 commit comments

Comments
 (0)
0