import clsx from "clsx"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; import type { Build, BuildWeapon, GearType, User } 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 { discordFullName, gearTypeToInitial } from "~/utils/strings"; import { analyzerPage, gearImageUrl, mainWeaponImageUrl, modeImageUrl, navIconUrl, userBuildsPage, } from "~/utils/urls"; import { Ability } from "./Ability"; import { Button, LinkButton } from "./Button"; import { FormWithConfirm } from "./FormWithConfirm"; import { TrashIcon } from "./icons/Trash"; import { EditIcon } from "./icons/Edit"; import { Image } from "./Image"; import { Popover } from "./Popover"; import { InfoIcon } from "./icons/Info"; interface BuildProps { build: Pick< Build, | "id" | "title" | "description" | "clothesGearSplId" | "headGearSplId" | "shoesGearSplId" | "updatedAt" > & { abilities: BuildAbilitiesTuple; modes: ModeShort[] | null; weapons: Array; }; owner?: Pick; canEdit?: boolean; } export function BuildCard({ build, owner, canEdit = false }: BuildProps) { const user = useUser(); const { t } = useTranslation(["weapons", "builds", "common"]); const { i18n } = useTranslation(); const isMounted = useIsMounted(); const { id, title, description, clothesGearSplId, headGearSplId, shoesGearSplId, updatedAt, abilities, modes, weapons, } = build; return (

{title}

{modes && modes.length > 0 && (
{modes.map((mode) => ( ))}
)}
{owner && ( <> {discordFullName(owner)}
)}
{weapons.map((weaponSplId) => (
{t(`weapons:MAIN_${weaponSplId}`
))} {weapons.length === 1 && (
{t(`weapons:MAIN_${weapons[0]!}` as any)}
)}
{t("common:pages.analyzer")} {description && ( } triggerClassName="minimal tiny build__small-text" > {description} )} {canEdit && ( <> )}
); } function AbilitiesRowWithGear({ gearType, abilities, gearId, }: { gearType: GearType; abilities: AbilityType[]; gearId: number; }) { const { t } = useTranslation(["gear"]); const translatedGearName = t( `gear:${gearTypeToInitial(gearType)}_${gearId}` as any ); return ( <> {translatedGearName} {abilities.map((ability, i) => ( ))} ); }