Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Oct 9, 2024
1 parent a41d441 commit 897a91a
Showing 1 changed file with 3 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FernButton, FernDropdown, FernSegmentedControl } from "@fern-ui/compone
import { NavArrowDown } from "iconoir-react";
import dynamic from "next/dynamic";
import { memo, useCallback, useMemo, useState } from "react";
import { renderTypeShorthand } from "../../type-shorthand";
import { getEmptyValueForType, matchesTypeReference } from "../utils";
import { PlaygroundTypeReferenceForm } from "./PlaygroundTypeReferenceForm";

Expand Down Expand Up @@ -43,35 +44,15 @@ export const PlaygroundUniscriminatedUnionForm = memo<PlaygroundUniscriminatedUn
const options = useMemo(
() =>
undiscriminatedUnion.variants.map((variant, idx): FernDropdown.Option => {
let labelFallback: string;
switch (variant.shape.type) {
case "literal":
labelFallback =
variant.shape.value.type === "booleanLiteral"
? variant.shape.value.value
? "true"
: "false"
: variant.shape.value.value;
break;
case "primitive":
labelFallback = variant.shape.value.type;
break;
case "optional":
labelFallback = variant.shape.shape.type;
break;
default:
labelFallback = variant.shape.type;
break;
}
return {
type: "value",
label: variant.displayName ?? labelFallback,
label: variant.displayName ?? renderTypeShorthand(variant.shape, {}, types),
value: idx.toString(),
// todo: handle availability
tooltip: variant.description != null ? <Markdown size="xs" mdx={variant.description} /> : undefined,
};
}),
[undiscriminatedUnion.variants],
[types, undiscriminatedUnion.variants],
);

const selectedOption = options
Expand Down

0 comments on commit 897a91a

Please sign in to comment.