Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Commit 9913a4f

Browse files
committed
feat: add navigation link to scheduler in lottery route and enhance scheduled route with search parameter validation
1 parent da4ccf1 commit 9913a4f

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

frontend/src/routes/lottery.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { createFileRoute } from '@tanstack/react-router'
1+
import { createFileRoute, Link } from '@tanstack/react-router'
22
import { useCallback, useEffect, useRef, useState } from 'react'
3-
import { Dice5, Copy, Check, FileCode, Loader2 } from 'lucide-react'
3+
import { Dice5, Copy, Check, FileCode, Loader2, CalendarClock } from 'lucide-react'
44

55
import { $api } from '@/api'
66
import type { SchemaUiEntropyInput, SchemaUiEvent } from '@/api/types'
@@ -895,6 +895,19 @@ export const Route = createFileRoute('/lottery')({
895895
<Dice5 className="h-4 w-4" aria-hidden />
896896
{buttonLabel}
897897
</Button>
898+
<Button asChild variant="outline" size="icon" title="Открыть планировщик" aria-label="Открыть планировщик">
899+
<Link
900+
to="/scheduled"
901+
search={{
902+
count: countInput,
903+
minValue: minValueInput,
904+
maxValue: maxValueInput,
905+
}}
906+
>
907+
<CalendarClock className="h-4 w-4" aria-hidden />
908+
<span className="sr-only">Планировщик</span>
909+
</Link>
910+
</Button>
898911
</div>
899912
</form>
900913
) : null}

frontend/src/routes/scheduled/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,20 @@ const GAME_PRESETS: GamePreset[] = [
175175
]
176176

177177
export const Route = createFileRoute('/scheduled/')({
178+
validateSearch: (search: Record<string, unknown>) => ({
179+
count: typeof search.count === 'string' ? search.count : undefined,
180+
minValue: typeof search.minValue === 'string' ? search.minValue : undefined,
181+
maxValue: typeof search.maxValue === 'string' ? search.maxValue : undefined,
182+
}),
178183
component: function ScheduledGenerationsRoute() {
179-
const [form, setForm] = useState<FormState>(() => createDefaultFormState())
184+
const search = Route.useSearch()
185+
const [form, setForm] = useState<FormState>(() =>
186+
createDefaultFormState({
187+
count: search.count,
188+
minValue: search.minValue,
189+
maxValue: search.maxValue,
190+
}),
191+
)
180192
const [formError, setFormError] = useState<string | null>(null)
181193
const [presetHint, setPresetHint] = useState<string | null>(null)
182194
const [secondaryLabel, setSecondaryLabel] = useState<string>('Поле 2')

0 commit comments

Comments
 (0)