import clsx from "clsx"; import { useTranslation } from "react-i18next"; import type { Build, BuildWeapon, GearType } from "~/db/types"; import { useIsMounted } from "~/hooks/useIsMounted"; import { useUser } from "~/modules/auth"; import type { Ability as AbilityType, ModeShort, } from "~/modules/in-game-lists"; import type { BuildAbilitiesTuple } from "~/modules/in-game-lists/types"; import { databaseTimestampToDate } from "~/utils/dates"; import { gearImageUrl, modeImageUrl, mainWeaponImageUrl } from "~/utils/urls"; import { Ability } from "./Ability"; import { Button, LinkButton } from "./Button"; import { FormWithConfirm } from "./FormWithConfirm"; import { Image } from "./Image"; import { Popover } from "./Popover"; type BuildProps = Pick< Build, | "id" | "title" | "description" | "clothesGearSplId" | "headGearSplId" | "shoesGearSplId" | "updatedAt" | "modes" > & { abilities: BuildAbilitiesTuple; modes: ModeShort[] | null; weapons: Array; canEdit?: boolean; }; export function BuildCard({ id, title, description, weapons, updatedAt, headGearSplId, clothesGearSplId, shoesGearSplId, abilities, modes, canEdit = false, }: BuildProps) { const user = useUser(); const { t } = useTranslation(["weapons", "builds", "common"]); const { i18n } = useTranslation(); const isMounted = useIsMounted(); const bottomRowItems = [ description && ( {t("builds:buildCard.info")}} triggerClassName="minimal tiny build__small-text" > {description} ), canEdit && ( {t("builds:buildCard.edit")} ), canEdit && ( ), ].filter(Boolean); return (

{title}

{modes && modes.length > 0 && (
{modes.map((mode) => ( ))}
)}
{weapons.map((weaponSplId) => (
{t(`weapons:${weaponSplId}`
))} {weapons.length === 1 && (
{t(`weapons:MAIN_${weapons[0]!}` as any)}
)}
{bottomRowItems.length > 0 && (
{bottomRowItems}
)}
); } function AbilitiesRowWithGear({ gearType, abilities, gearId, }: { gearType: GearType; abilities: AbilityType[]; gearId: number; }) { return ( <> {abilities.map((ability, i) => ( ))} ); }