import { ItemsById, itemsPerSlot } from "../lib/items"; import type { State } from "../lib/state"; import { Slots, type Item, type Slot } from "../lib/types"; import { ItemLink } from "./ItemLink"; import { ItemTypeahead } from "./ItemTypeahead"; import styles from "./Equipment.module.css"; import { QualitySelector } from "./QualitySelector"; export type Props = { state: State; onEquip: (item: Item) => void; onUnequip: (item: Item) => void; }; export const Equipment = ({ state, onEquip, onUnequip }: Props) => { return (
item && onEquip(item)} />
{Slots.map((slot) => { if (itemsPerSlot(slot, state.weaponConfig) > 0) { return ( ); } return null; })}
); }; type SlotProps = { state: State; slot: Slot; onUnequip: (item: Item) => void; }; const Slot = ({ state, slot, onUnequip }: SlotProps) => { const items = state.equipedItems .map((item) => ({ ...item, item: ItemsById[item.id] })) .filter((item) => item && item.item.slot === slot); return ( <>
{slot}
{ // Show placeholder if there are no items items.length === 0 && ( <>
) } {items.map((item) => ( <>
))} ); };