New source found from dndbeyond.com
This commit is contained in:
+47
-31
@@ -3,11 +3,11 @@ import { orderBy } from "lodash";
|
||||
import * as React from "react";
|
||||
import { useContext } from "react";
|
||||
import { connect, DispatchProp } from "react-redux";
|
||||
import { AnyAction } from "redux";
|
||||
|
||||
import {
|
||||
CreaturePreview,
|
||||
ItemPreview,
|
||||
MarketplaceCta,
|
||||
LoadingPlaceholder,
|
||||
} from "@dndbeyond/character-components/es";
|
||||
import {
|
||||
@@ -42,10 +42,12 @@ import {
|
||||
ClassUtils,
|
||||
BaseCharClass,
|
||||
ContainerManager,
|
||||
ContainerLookup,
|
||||
} from "@dndbeyond/character-rules-engine/es";
|
||||
import { InventoryManager } from "@dndbeyond/character-rules-engine/es";
|
||||
|
||||
import { HtmlContent } from "~/components/HtmlContent";
|
||||
import { MarketplaceCta } from "~/components/MarketplaceCta";
|
||||
import { useSidebar } from "~/contexts/Sidebar";
|
||||
import { PaneInfo } from "~/contexts/Sidebar/Sidebar";
|
||||
import { Header } from "~/subApps/sheet/components/Sidebar/components/Header";
|
||||
@@ -72,7 +74,9 @@ enum UiViewEnum {
|
||||
|
||||
type SimpleOnClickHandler = () => void;
|
||||
|
||||
interface Props extends DispatchProp {
|
||||
// TODO: We are typing with AnyAction here to work around issues with UnknownAction, the type that was introduced in Redux 5.
|
||||
// If we decide to modernize to Redux 5, we will need to refactor much of the Rules Engine redux usage.
|
||||
interface Props extends DispatchProp<AnyAction> {
|
||||
infusionChoices: Array<InfusionChoice>;
|
||||
inventory: Array<Item>;
|
||||
inventoryLookup: InventoryLookup;
|
||||
@@ -87,7 +91,6 @@ interface Props extends DispatchProp {
|
||||
|
||||
identifiers: PaneIdentifiersInfusionChoice;
|
||||
isReadonly: boolean;
|
||||
proficiencyBonus: number;
|
||||
maximumInfusions?: number;
|
||||
currentInfusions?: number;
|
||||
characterId: number;
|
||||
@@ -95,6 +98,8 @@ interface Props extends DispatchProp {
|
||||
inventoryManager: InventoryManager;
|
||||
classes: Array<BaseCharClass>;
|
||||
paneHistoryPush: PaneInfo["paneHistoryPush"];
|
||||
containerLookup: ContainerLookup;
|
||||
partyInventoryLookup: InventoryLookup;
|
||||
}
|
||||
interface StateData {
|
||||
infusionChoice: InfusionChoice | null;
|
||||
@@ -408,7 +413,13 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
};
|
||||
|
||||
handleInfusionRemove = (): void => {
|
||||
const { dispatch, inventoryLookup } = this.props;
|
||||
const {
|
||||
dispatch,
|
||||
inventoryLookup,
|
||||
partyInventoryLookup,
|
||||
inventoryManager,
|
||||
containerLookup,
|
||||
} = this.props;
|
||||
const { infusionChoice } = this.state;
|
||||
|
||||
if (infusionChoice === null) {
|
||||
@@ -424,7 +435,7 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
|
||||
const inventoryMappingId = InfusionUtils.getInventoryMappingId(infusion);
|
||||
const item = HelperUtils.lookupDataOrFallback(
|
||||
inventoryLookup,
|
||||
{ ...inventoryLookup, ...partyInventoryLookup },
|
||||
inventoryMappingId
|
||||
);
|
||||
|
||||
@@ -434,7 +445,12 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
dispatch(
|
||||
serviceDataActions.infusionMappingDestroy(
|
||||
infusionId,
|
||||
InfusionUtils.getInventoryMappingId(infusion)
|
||||
InfusionUtils.getInventoryMappingId(infusion),
|
||||
item
|
||||
? inventoryManager.handleAcceptOnSuccess(
|
||||
ItemUtils.isShared(item, containerLookup)
|
||||
)
|
||||
: undefined
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -624,8 +640,7 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
|
||||
renderUiChooseItem = (): React.ReactNode => {
|
||||
const { infusionChoice } = this.state;
|
||||
const { inventory, ruleData, proficiencyBonus, theme, inventoryManager } =
|
||||
this.props;
|
||||
const { inventory, ruleData, theme, inventoryManager } = this.props;
|
||||
|
||||
if (infusionChoice === null) {
|
||||
return null;
|
||||
@@ -653,7 +668,7 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<>
|
||||
<Header
|
||||
parent={this.renderInfusionChoiceName()}
|
||||
onClick={this.handleChangeUiView.bind(this, UiViewEnum.REVIEW)}
|
||||
@@ -683,7 +698,6 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
infusionChoice={infusionChoice}
|
||||
ruleData={ruleData}
|
||||
onItemSelected={this.handleChooseExistingItem}
|
||||
proficiencyBonus={proficiencyBonus}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -703,7 +717,7 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -742,7 +756,7 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<>
|
||||
<Header
|
||||
parent={this.renderInfusionChoiceName()}
|
||||
onClick={this.handleChangeUiView.bind(this, UiViewEnum.REVIEW)}
|
||||
@@ -784,7 +798,7 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -870,10 +884,10 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<>
|
||||
Infusion: {InfusionUtils.getName(simulatedInfusion)}
|
||||
{extraNameNode}
|
||||
</React.Fragment>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -958,11 +972,7 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
}
|
||||
} else if (infusionType === Constants.InfusionTypeEnum.REPLICATE) {
|
||||
itemHeaderNode = "Item to be replicated";
|
||||
itemContentNode = (
|
||||
<React.Fragment>
|
||||
{KnownInfusionUtils.getItemName(knownInfusion)}
|
||||
</React.Fragment>
|
||||
);
|
||||
itemContentNode = <>{KnownInfusionUtils.getItemName(knownInfusion)}</>;
|
||||
}
|
||||
|
||||
const modifierData = InfusionUtils.getModifierData(simulatedInfusion);
|
||||
@@ -1014,7 +1024,7 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<>
|
||||
<Header>{this.renderInfusionChoiceName()}</Header>
|
||||
{currentInfusions >= maximumInfusions && (
|
||||
<ThemeButton
|
||||
@@ -1047,7 +1057,7 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
)}
|
||||
{!isReadonly && this.renderActions()}
|
||||
{this.renderDescription()}
|
||||
</React.Fragment>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1087,8 +1097,14 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
|
||||
renderInfusedUi = (): React.ReactNode => {
|
||||
const { infusionChoice } = this.state;
|
||||
const { ruleData, creatureLookup, inventoryLookup, isReadonly, theme } =
|
||||
this.props;
|
||||
const {
|
||||
ruleData,
|
||||
creatureLookup,
|
||||
inventoryLookup,
|
||||
isReadonly,
|
||||
theme,
|
||||
partyInventoryLookup,
|
||||
} = this.props;
|
||||
|
||||
if (infusionChoice === null) {
|
||||
return null;
|
||||
@@ -1101,7 +1117,7 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
|
||||
const inventoryMappingId = InfusionUtils.getInventoryMappingId(infusion);
|
||||
const item = HelperUtils.lookupDataOrFallback(
|
||||
inventoryLookup,
|
||||
{ ...inventoryLookup, ...partyInventoryLookup },
|
||||
inventoryMappingId
|
||||
);
|
||||
const creatureMappingId = InfusionUtils.getCreatureMappingId(infusion);
|
||||
@@ -1114,7 +1130,7 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<>
|
||||
<Header>{this.renderInfusionChoiceName()}</Header>
|
||||
{item !== null && (
|
||||
<InfusionChoicePaneStep
|
||||
@@ -1138,17 +1154,17 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
</div>
|
||||
)}
|
||||
{this.renderDescription()}
|
||||
</React.Fragment>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
renderLoadingUi = (): React.ReactNode => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<>
|
||||
<Header>{this.renderInfusionChoiceName()}</Header>
|
||||
<LoadingPlaceholder />
|
||||
{this.renderDescription()}
|
||||
</React.Fragment>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1195,7 +1211,6 @@ class InfusionChoicePane extends React.PureComponent<Props, State> {
|
||||
return (
|
||||
<div className="ct-infusion-choice-pane__marketplace-cta">
|
||||
<MarketplaceCta
|
||||
showImage={false}
|
||||
sourceName={sourceName}
|
||||
description="To unlock this infusion, check out the Marketplace to view purchase options."
|
||||
/>
|
||||
@@ -1258,10 +1273,11 @@ function mapStateToProps(state: SharedAppState) {
|
||||
typeValueLookup: rulesEngineSelectors.getCharacterValueLookupByType(state),
|
||||
ruleData: rulesEngineSelectors.getRuleData(state),
|
||||
isReadonly: appEnvSelectors.getIsReadonly(state),
|
||||
proficiencyBonus: rulesEngineSelectors.getProficiencyBonus(state),
|
||||
characterId: rulesEngineSelectors.getId(state),
|
||||
theme: rulesEngineSelectors.getCharacterTheme(state),
|
||||
classes: rulesEngineSelectors.getClasses(state),
|
||||
containerLookup: rulesEngineSelectors.getContainerLookup(state),
|
||||
partyInventoryLookup: rulesEngineSelectors.getPartyInventoryLookup(state),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
import * as React from "react";
|
||||
import { ReactNode, PureComponent, PropsWithChildren, MouseEvent } from "react";
|
||||
|
||||
interface Props {
|
||||
header: React.ReactNode;
|
||||
extra?: React.ReactNode;
|
||||
interface Props extends PropsWithChildren {
|
||||
header: ReactNode;
|
||||
extra?: ReactNode;
|
||||
onClick?: () => void;
|
||||
}
|
||||
export class InfusionChoicePaneStep extends React.PureComponent<Props> {
|
||||
handleClick = (evt: React.MouseEvent): void => {
|
||||
export class InfusionChoicePaneStep extends PureComponent<Props> {
|
||||
handleClick = (evt: MouseEvent): void => {
|
||||
const { onClick } = this.props;
|
||||
|
||||
if (onClick) {
|
||||
|
||||
-3
@@ -30,7 +30,6 @@ interface Props {
|
||||
infusionChoice: InfusionChoice;
|
||||
onItemSelected: (item: Item) => void;
|
||||
ruleData: RuleData;
|
||||
proficiencyBonus: number;
|
||||
theme: CharacterTheme;
|
||||
}
|
||||
export class InfusionChoicePaneStore extends React.PureComponent<Props> {
|
||||
@@ -60,7 +59,6 @@ export class InfusionChoicePaneStore extends React.PureComponent<Props> {
|
||||
items,
|
||||
onItemSelected,
|
||||
ruleData,
|
||||
proficiencyBonus,
|
||||
theme,
|
||||
} = this.props;
|
||||
|
||||
@@ -133,7 +131,6 @@ export class InfusionChoicePaneStore extends React.PureComponent<Props> {
|
||||
showActions={false}
|
||||
showImage={false}
|
||||
showAbilities={false}
|
||||
proficiencyBonus={proficiencyBonus}
|
||||
/>
|
||||
</Collapsible>
|
||||
);
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import withAvailableItems from "./withAvailableItems";
|
||||
|
||||
export default withAvailableItems;
|
||||
export { withAvailableItems };
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
import axios, { Canceler } from "axios";
|
||||
import * as React from "react";
|
||||
import { ComponentProps, ComponentType, JSX, PureComponent } from "react";
|
||||
|
||||
import {
|
||||
CharacterTheme,
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
import DataLoadingStatusEnum from "../../../../constants/DataLoadingStatusEnum";
|
||||
import { AppLoggerUtils } from "../../../../utils";
|
||||
|
||||
function getDisplayName(WrappedComponent: React.ComponentType) {
|
||||
function getDisplayName(WrappedComponent: ComponentType) {
|
||||
return WrappedComponent.displayName || WrappedComponent.name || "Component";
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ interface State {
|
||||
availableItems: Array<Item>;
|
||||
}
|
||||
export function withAvailableItems<
|
||||
C extends React.ComponentType<React.ComponentProps<C>>,
|
||||
ResolvedProps = JSX.LibraryManagedAttributes<C, React.ComponentProps<C>>
|
||||
C extends ComponentType<ComponentProps<C>>,
|
||||
ResolvedProps = JSX.LibraryManagedAttributes<C, ComponentProps<C>>
|
||||
>(WrappedComponent) {
|
||||
return class withAvailableItems extends React.PureComponent<
|
||||
return class withAvailableItems extends PureComponent<
|
||||
ResolvedProps & RequiredWithAvailableItemsProps,
|
||||
State
|
||||
> {
|
||||
@@ -115,7 +115,7 @@ export function withAvailableItems<
|
||||
itemLoadingStatus={loadingStatus}
|
||||
{...(this.props as JSX.LibraryManagedAttributes<
|
||||
C,
|
||||
React.ComponentProps<C>
|
||||
ComponentProps<C>
|
||||
>)}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user