'use client'; import styles from '../styles/QuantityCard.module.css'; import { randInRange } from '../app/items/types'; type Props = { id: string; name: string; iconUrl: string; qty: number; randMin: number; randMax: number; onSetQty: (id: string, qty: number) => void; }; const clamp = (v: number) => Math.min(32767, Math.max(0, v)); export default function QuantityCard({ id, name, iconUrl, qty, randMin, randMax, onSetQty }: Props) { const active = qty > 0; return (
{name} {name} {active ? ( <>
{ const v = parseInt(e.target.value); if (!isNaN(v)) onSetQty(id, clamp(v)); }} />
) : ( )}
); }