diff --git a/src/renderer/src/components/TimeRangeEditor.tsx b/src/renderer/src/components/TimeRangeEditor.tsx index 62c2494..b728989 100644 --- a/src/renderer/src/components/TimeRangeEditor.tsx +++ b/src/renderer/src/components/TimeRangeEditor.tsx @@ -5,8 +5,10 @@ export function TimeRangeEditor(): React.JSX.Element { const { timeRanges, setTimeRanges } = useAppStore() const sorted = [...timeRanges].sort((a, b) => a - b) - const update = (index: number, hours: number): void => { - const sec = Math.max(300, Math.round(hours * 3600)) + const ORS_MAX_SEC = 3600 + + const update = (index: number, minutes: number): void => { + const sec = Math.min(ORS_MAX_SEC, Math.max(60, Math.round(minutes) * 60)) const next = sorted.map((v, i) => (i === index ? sec : v)).sort((a, b) => a - b) setTimeRanges(next) } @@ -18,7 +20,9 @@ export function TimeRangeEditor(): React.JSX.Element { const add = (): void => { if (sorted.length >= 5) return - setTimeRanges([...sorted, Math.max(...sorted) + 3600]) + const next = Math.min(ORS_MAX_SEC, Math.max(...sorted) + 600) + if (next === Math.max(...sorted)) return // already at max + setTimeRanges([...sorted, next]) } return ( @@ -32,13 +36,13 @@ export function TimeRangeEditor(): React.JSX.Element { update(i, parseFloat(e.target.value) || 0.5)} + min={1} + max={60} + step={5} + value={Math.round(t / 60)} + onChange={(e) => update(i, parseInt(e.target.value) || 5)} /> - {formatDuration(t)} + min — {formatDuration(t)} ))} - {sorted.length < 5 && ( + {sorted.length < 5 && Math.max(...sorted) < ORS_MAX_SEC && ( )} +

Max 60 min — limite API ORS gratuit

) } diff --git a/src/renderer/src/store/useAppStore.ts b/src/renderer/src/store/useAppStore.ts index c22a31a..1fda60d 100644 --- a/src/renderer/src/store/useAppStore.ts +++ b/src/renderer/src/store/useAppStore.ts @@ -25,7 +25,7 @@ const STORAGE_KEY = 'ors_api_key' export const useAppStore = create((set) => ({ point: null, mode: 'driving-car', - timeRanges: [3600, 7200, 10800], + timeRanges: [1200, 2400, 3600], // 20min, 40min, 1h isochrones: null, loading: false, error: null,