mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-21 06:34:30 +01:00
Merge Tag v0.2.15.0
This commit is contained in:
@@ -8,6 +8,7 @@ import { Input } from '@/components/ui/input'
|
||||
import { useCoins } from '@/hooks/useCoins'
|
||||
import { settingsAtom, usersAtom } from '@/lib/atoms'
|
||||
import { useHelpers } from '@/lib/client-helpers'
|
||||
import { MAX_COIN_LIMIT } from '@/lib/constants'
|
||||
import { TransactionType } from '@/lib/types'
|
||||
import { d2s, t2d } from '@/lib/utils'
|
||||
import { useAtom } from 'jotai'
|
||||
@@ -139,7 +140,11 @@ export default function CoinsManager() {
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="h-10 w-10 text-lg"
|
||||
onClick={() => setAmount(prev => (Number(prev) - 1).toString())}
|
||||
onClick={() => setAmount(prev => {
|
||||
const current = Number(prev);
|
||||
const next = current - 1;
|
||||
return (Math.abs(next) > MAX_COIN_LIMIT ? (next < 0 ? -MAX_COIN_LIMIT : MAX_COIN_LIMIT) : next).toString();
|
||||
})}
|
||||
>
|
||||
-
|
||||
</Button>
|
||||
@@ -147,7 +152,22 @@ export default function CoinsManager() {
|
||||
<Input
|
||||
type="number"
|
||||
value={amount}
|
||||
onChange={(e) => setAmount(e.target.value)}
|
||||
onChange={(e) => {
|
||||
const rawValue = e.target.value;
|
||||
if (rawValue === '' || rawValue === '-') {
|
||||
setAmount(rawValue);
|
||||
return;
|
||||
}
|
||||
let numericValue = Number(rawValue); // Changed const to let
|
||||
if (isNaN(numericValue)) return; // Or handle error
|
||||
|
||||
if (Math.abs(numericValue) > MAX_COIN_LIMIT) {
|
||||
numericValue = numericValue < 0 ? -MAX_COIN_LIMIT : MAX_COIN_LIMIT;
|
||||
}
|
||||
setAmount(numericValue.toString());
|
||||
}}
|
||||
min={-MAX_COIN_LIMIT}
|
||||
max={MAX_COIN_LIMIT}
|
||||
className="text-center text-xl font-medium h-12"
|
||||
/>
|
||||
<div className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground">
|
||||
@@ -158,7 +178,11 @@ export default function CoinsManager() {
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="h-10 w-10 text-lg"
|
||||
onClick={() => setAmount(prev => (Number(prev) + 1).toString())}
|
||||
onClick={() => setAmount(prev => {
|
||||
const current = Number(prev);
|
||||
const next = current + 1;
|
||||
return (Math.abs(next) > MAX_COIN_LIMIT ? (next < 0 ? -MAX_COIN_LIMIT : MAX_COIN_LIMIT) : next).toString();
|
||||
})}
|
||||
>
|
||||
+
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user