fix typescript and show badge of type of edit
This commit is contained in:
parent
b3b478d6d1
commit
8675d28e96
@ -1,4 +1,4 @@
|
|||||||
import { History } from "./history_types";
|
import { History, HistoryItemType } from "./history_types";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import {
|
import {
|
||||||
@ -6,6 +6,7 @@ import {
|
|||||||
HoverCardTrigger,
|
HoverCardTrigger,
|
||||||
HoverCardContent,
|
HoverCardContent,
|
||||||
} from "../ui/hover-card";
|
} from "../ui/hover-card";
|
||||||
|
import { Badge } from "../ui/badge";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
history: History;
|
history: History;
|
||||||
@ -14,17 +15,18 @@ interface Props {
|
|||||||
shouldDisableReverts: boolean;
|
shouldDisableReverts: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// function displayHistoryItemType(itemType: HistoryItemType) {
|
function displayHistoryItemType(itemType: HistoryItemType) {
|
||||||
// switch (itemType) {
|
switch (itemType) {
|
||||||
// case "ai_create":
|
case "ai_create":
|
||||||
// return "Create";
|
return "Create";
|
||||||
// case "ai_edit":
|
case "ai_edit":
|
||||||
// return "Edit";
|
return "Edit";
|
||||||
// default:
|
default: {
|
||||||
// // TODO: Error out since this is exhaustive
|
const exhaustiveCheck: never = itemType;
|
||||||
// return "Unknown";
|
throw new Error(`Unhandled case: ${exhaustiveCheck}`);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function HistoryDisplay({
|
export default function HistoryDisplay({
|
||||||
history,
|
history,
|
||||||
@ -73,7 +75,10 @@ export default function HistoryDisplay({
|
|||||||
<h2 className="text-sm">v{index + 1}</h2>
|
<h2 className="text-sm">v{index + 1}</h2>
|
||||||
</HoverCardTrigger>
|
</HoverCardTrigger>
|
||||||
<HoverCardContent>
|
<HoverCardContent>
|
||||||
|
<div>
|
||||||
{item.type === "ai_edit" ? item.inputs.prompt : "Create"}
|
{item.type === "ai_edit" ? item.inputs.prompt : "Create"}
|
||||||
|
</div>
|
||||||
|
<Badge>{displayHistoryItemType(item.type)}</Badge>
|
||||||
</HoverCardContent>
|
</HoverCardContent>
|
||||||
</HoverCard>
|
</HoverCard>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user