Skip to content

Commit e2c8c55

Browse files
committed
feat: option to increment/decrement more on scan
1 parent ad174ce commit e2c8c55

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

frontend/src/pages/scan/Scan.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { GraphModel } from '@tensorflow/tfjs'
22
import i18n from 'i18next'
3-
import { SquareCheck, SquareX } from 'lucide-react'
3+
import { Minus, Plus, SquareCheck, SquareX } from 'lucide-react'
44
import type { ChangeEvent, Dispatch, SetStateAction } from 'react'
55
import { useEffect, useMemo, useRef, useState } from 'react'
66
import { useTranslation } from 'react-i18next'
77
import { CardLine } from '@/components/CardLine'
8-
import { DropdownFilter, TabsFilter } from '@/components/Filters'
8+
import { DropdownFilter } from '@/components/Filters'
99
import { Spinner } from '@/components/Spinner.tsx'
1010
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
1111
import { Button } from '@/components/ui/button'
@@ -249,6 +249,9 @@ const Scan = () => {
249249
}
250250
setExtractedCards((arr) => arr.map((x, i) => (i === index ? { ...x, matchedCard: { ...x.matchedCard, card: targetCard } } : x)))
251251
}
252+
const currentAmount = ownedCards?.get(card.matchedCard.card.internal_id)?.amount_owned ?? 0
253+
const newAmount = currentAmount + card.increment
254+
const canDecrement = newAmount > 0
252255
return (
253256
<div key={index} className={`border-3 rounded-lg p-2 ${card.increment > 0 && 'border-green-400'} ${card.increment < 0 && 'border-red-400'}`}>
254257
<h3 className="flex mb-2">
@@ -263,7 +266,21 @@ const Scan = () => {
263266
/>
264267
</h3>
265268
<div className="flex gap-2 justify-between mb-2">
266-
<TabsFilter options={['-1', '0', '+1']} value={(card.increment > 0 ? '+' : '') + String(card.increment)} onChange={onIncrementChange} />
269+
<div className="flex items-center gap-1">
270+
<Button
271+
variant="outline"
272+
size="icon"
273+
className="h-8 w-8"
274+
onClick={() => onIncrementChange(String(card.increment - 1))}
275+
disabled={!canDecrement}
276+
>
277+
<Minus className="h-4 w-4" />
278+
</Button>
279+
<div className="min-w-8 text-center font-semibold select-none">{card.increment > 0 ? `+${card.increment}` : card.increment}</div>
280+
<Button variant="outline" size="icon" className="h-8 w-8" onClick={() => onIncrementChange(String(card.increment + 1))}>
281+
<Plus className="h-4 w-4" />
282+
</Button>
283+
</div>
267284
{expansions.length > 1 && (
268285
<DropdownFilter className="inline-block" options={expansions} value={card.matchedCard.card.expansion} onChange={onExpansionChange} />
269286
)}

0 commit comments

Comments
 (0)