From 0acc326914888bba5f6a4d9a343099d64f4c8d13 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Sun, 14 Nov 2021 16:23:34 +0100 Subject: [PATCH] Added NumEdit --- src/components/CardGroup.tsx | 5 ++++- src/components/Deck.tsx | 7 ++++++- src/components/NumEdit.tsx | 24 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 src/components/NumEdit.tsx diff --git a/src/components/CardGroup.tsx b/src/components/CardGroup.tsx index 05955aa..a0d646b 100644 --- a/src/components/CardGroup.tsx +++ b/src/components/CardGroup.tsx @@ -2,6 +2,7 @@ import React from "react" import CardGroup from "../types/CardGroup" import Side from "../types/Side" import CardComp from "./Card" +import NumEdit from "./NumEdit" interface Props { cardGroup: CardGroup @@ -12,7 +13,9 @@ interface Props { const CardGroupComp: React.FC = ({cardGroup,side,onChange}) => { return (
- Num: {cardGroup.numInDeck} + Num: onChange?.(new CardGroup(Math.max(newNum,0),...cardGroup.cards))} + />
{cardGroup.cards.map((card,index) => { diff --git a/src/components/Deck.tsx b/src/components/Deck.tsx index b762c20..e0ebaab 100644 --- a/src/components/Deck.tsx +++ b/src/components/Deck.tsx @@ -2,6 +2,7 @@ import React from "react" import Deck from "../types/Deck" import Side from "../types/Side" import CardGroupComp from "./CardGroup" +import NumEdit from "./NumEdit" interface Props { deck: Deck @@ -14,7 +15,11 @@ const DeckComp: React.FC = ({deck,side,title,onChange}) => { return (
{title} - { side === Side.CT && D: {deck.numDefusers} } + { side === Side.CT && + D: onChange?.(new Deck(Math.max(newNum,0),...deck.cardGroups))} + /> }
{deck.cardGroups.map((group,index) => void +} + +const NumEdit: React.FC = ({value,onChange}) => { + return ( + <> + onChange?.(value - 1)} + >- + {value} + onChange?.(value + 1)} + >+ + + ) +} + +export default NumEdit