diff --git a/app/api/settings/route.ts b/app/api/settings/route.ts index 6bdebd5..cc3628d 100644 --- a/app/api/settings/route.ts +++ b/app/api/settings/route.ts @@ -3,7 +3,7 @@ import { getSetting, setSetting } from '@/lib/db'; import { scheduleBackupPush } from '@/lib/backup-sync'; import { getRequestUserAgent } from '@/lib/request-user-agent'; -const VALID_KEYS = ['max_concurrent_accounts', 'tick_interval_seconds', 'master_dashboard_url', 'instance_name', 'trading_hours', 'twocaptcha_api_key', 'twocaptcha_proxy', 'master_backup_token', 'proxy_url', 'auto_claim'] as const; +const VALID_KEYS = ['max_concurrent_accounts', 'tick_interval_seconds', 'master_dashboard_url', 'instance_name', 'trading_hours', 'twocaptcha_api_key', 'twocaptcha_proxy', 'master_backup_token', 'proxy_url', 'auto_claim', 'auto_activate'] as const; type SettingKey = typeof VALID_KEYS[number]; export async function GET() { @@ -25,10 +25,13 @@ export async function PATCH(req: NextRequest) { try { const body = await req.json() as Partial>; - // Claims run unless it reads exactly 'off' — say so exactly, and - // before anything is written. - if (body.auto_claim !== undefined && body.auto_claim !== null && body.auto_claim !== 'on' && body.auto_claim !== 'off') { - return NextResponse.json({ error: "auto_claim is 'on' or 'off'" }, { status: 400 }); + // Claims and activations run unless it reads exactly 'off' — say so + // exactly, and before anything is written. + for (const key of ['auto_claim', 'auto_activate'] as const) { + const v = body[key]; + if (v !== undefined && v !== null && v !== 'on' && v !== 'off') { + return NextResponse.json({ error: `${key} is 'on' or 'off'` }, { status: 400 }); + } } for (const key of VALID_KEYS) { diff --git a/app/page.tsx b/app/page.tsx index ff1663e..4ea9fbf 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -744,6 +744,7 @@ export default function Home() { const [tradeLoading, setTradeLoading] = useState(false); const [stopAfterAll, setStopAfterAll] = useState(false); const [autoClaim, setAutoClaim] = useState(true); + const [autoActivate, setAutoActivate] = useState(true); const handleSort = (col: SortKey) => { if (sortKey === col) { @@ -813,9 +814,10 @@ export default function Home() { fetch('/api/settings') .then((r) => r.json()) - .then((s: { tick_interval_seconds?: string | null; auto_claim?: string | null }) => { + .then((s: { tick_interval_seconds?: string | null; auto_claim?: string | null; auto_activate?: string | null }) => { if (s.tick_interval_seconds != null) setTickInterval(s.tick_interval_seconds); setAutoClaim(s.auto_claim !== 'off'); + setAutoActivate(s.auto_activate !== 'off'); }) .catch(() => {}); @@ -1024,6 +1026,28 @@ export default function Home() { Auto-claim payouts )} + {config.some((f) => f.platform === 'vest') && ( + + )}
{hasAnyPosition && (