import React from "react"; import { Tooltip } from "@dndbeyond/character-common-components/es"; import { CharacterCurrencyContract, Constants, FormatUtils, RuleDataUtils, } from "@dndbeyond/character-rules-engine/es"; import { NumberDisplay } from "~/components/NumberDisplay"; import CurrencyButton from "../CurrencyButton"; interface Props { currencies: CharacterCurrencyContract | null; weight: number; weightSpeedType: Constants.WeightSpeedTypeEnum; onCurrencyClick?: (evt: React.MouseEvent | React.KeyboardEvent) => void; onWeightClick?: () => void; onCampaignClick?: () => void; onManageClick?: () => void; enableManage: boolean; isReadonly: boolean; isDarkMode: boolean; shouldShowPartyInventory: boolean; campaignName: string | null; } export default class EquipmentOverview extends React.PureComponent { static defaultProps = { enableManage: true, isReadonly: false, }; handleCurrencyClick = (evt: React.MouseEvent | React.KeyboardEvent): void => { const { onCurrencyClick } = this.props; if (onCurrencyClick) { evt.stopPropagation(); evt.nativeEvent.stopImmediatePropagation(); onCurrencyClick(evt); } }; handleCampaignClick = (evt: React.MouseEvent | React.KeyboardEvent): void => { const { onCampaignClick } = this.props; if (onCampaignClick) { evt.stopPropagation(); evt.nativeEvent.stopImmediatePropagation(); onCampaignClick(); } }; handleWeightClick = (evt: React.MouseEvent | React.KeyboardEvent): void => { const { onWeightClick } = this.props; if (onWeightClick) { evt.stopPropagation(); evt.nativeEvent.stopImmediatePropagation(); onWeightClick(); } }; handleManageClick = (evt: React.MouseEvent | React.KeyboardEvent): void => { const { onManageClick } = this.props; if (onManageClick) { evt.stopPropagation(); evt.nativeEvent.stopImmediatePropagation(); onManageClick(); } }; render() { const { weight, weightSpeedType, enableManage, isReadonly, isDarkMode, shouldShowPartyInventory, campaignName, currencies, } = this.props; let weightSpeedLabel = RuleDataUtils.getWeightSpeedTypeLabel(weightSpeedType); return ( // TODO: add a min height?
{!shouldShowPartyInventory ? (
{ if (evt.key === "Enter") { this.handleWeightClick(evt); } }} >
Weight Carried:
{weightSpeedLabel}
) : (
{ if (evt.key === "Enter") { this.handleCampaignClick(evt); } }} >
CAMPAIGN: {campaignName || "N/A"}
)}
{enableManage && !isReadonly && (
{ if (evt.key === "Enter") { this.handleManageClick(evt); } }} >
)}
); } }