This commit is contained in:
morpheus65535 2024-06-10 08:47:51 -04:00
parent 225a3b65d4
commit a19b87cd5c
1 changed files with 9 additions and 11 deletions

View File

@ -2,7 +2,7 @@ import { FunctionComponent, useCallback, useMemo } from "react";
import { Column } from "react-table";
import { Badge, Button, Group } from "@mantine/core";
import { faTrash, faWrench } from "@fortawesome/free-solid-svg-icons";
import { cloneDeep } from "lodash";
import { cloneDeep, cond } from "lodash";
import { Action, SimpleTable } from "@/components";
import {
anyCutoff,
@ -193,16 +193,14 @@ interface ItemProps {
const ItemBadge: FunctionComponent<ItemProps> = ({ cutoff, item }) => {
const text = useMemo(() => {
let result = item.language;
if (item.hi === "only") {
result += ":HI";
} else if (item.hi === "never") {
result += ":Normal";
} else if (item.forced === "True") {
result += ":Forced";
}
return result;
}, [item.hi, item.forced, item.language]);
const suffix = cond([
[(v: { forced: string; hi: string }) => v.hi === "only", () => ":HI"],
[(v) => v.hi === "never", () => ":Normal"],
[(v) => v.forced === "True", () => ":Forced"],
[() => true, () => ""],
]);
return item.language + suffix(item);
}, [item]);
return (
<Badge
title={cutoff ? "Ignore others if this one is available" : undefined}