From 310bc72305ca41c27bd94d57feb2085e50be8fc1 Mon Sep 17 00:00:00 2001 From: Jan Langheimer Date: Mon, 15 Apr 2024 21:03:47 +0100 Subject: [PATCH 1/3] hotfix search parser --- src/libs/routing/routes/sim.tsx | 5 ++++- src/libs/routing/utils.ts | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libs/routing/routes/sim.tsx b/src/libs/routing/routes/sim.tsx index 1faf93cb0..66f16c73a 100644 --- a/src/libs/routing/routes/sim.tsx +++ b/src/libs/routing/routes/sim.tsx @@ -204,6 +204,9 @@ export const simulatorResultRoute = new Route({ throw new Error('Invalid buy is range'); } + const type: SimulatorType = + search.type === 'overlapping' ? 'overlapping' : 'recurring'; + return { start: search.start, end: search.end, @@ -222,7 +225,7 @@ export const simulatorResultRoute = new Route({ buyIsRange: search.buyIsRange, // TODO add validation spread: search.spread, - type: search.type as SimulatorType, + type, }; }, // @ts-ignore diff --git a/src/libs/routing/utils.ts b/src/libs/routing/utils.ts index 42210903c..baab66182 100644 --- a/src/libs/routing/utils.ts +++ b/src/libs/routing/utils.ts @@ -10,7 +10,7 @@ function toValue(mix: string | undefined) { if (str === 'true') return true; if (str.startsWith('0x')) return str; if (str.startsWith('0X')) return str; - return +str * 0 === 0 && +str + '' === str ? +str : str; + return +str * 0 === 0 && +str + '' === str ? str : str; } export function decode(str: string) { @@ -51,7 +51,12 @@ export const parseSearchWith = (parser: (str: string) => any) => { const value = query[key]; if (typeof value === 'string') { try { - query[key] = parser(value); + const parsed = parser(value); + if (typeof parsed === 'number') { + query[key] = parsed.toString(); + } else { + query[key] = parsed; + } } catch (err) { // } From ebd10351168ec37dd07c9d559fd52636a511346b Mon Sep 17 00:00:00 2001 From: Jan Langheimer Date: Mon, 15 Apr 2024 21:21:46 +0100 Subject: [PATCH 2/3] fix error handling --- src/pages/simulator/index.tsx | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/pages/simulator/index.tsx b/src/pages/simulator/index.tsx index 947d2a7fb..a16193465 100644 --- a/src/pages/simulator/index.tsx +++ b/src/pages/simulator/index.tsx @@ -23,20 +23,18 @@ export const SimulatorPage = () => { <>

Simulate Strategy

- {!isError && ( -
- - - -
- )} +
+ + + +
); From 634145a074580c66c5969f51b3687f5c5ede109a Mon Sep 17 00:00:00 2001 From: Jan Langheimer Date: Tue, 16 Apr 2024 08:14:31 +0100 Subject: [PATCH 3/3] fix simulator mobile screen --- src/pages/simulator/result/index.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pages/simulator/result/index.tsx b/src/pages/simulator/result/index.tsx index fac1a72f0..fb731ad39 100644 --- a/src/pages/simulator/result/index.tsx +++ b/src/pages/simulator/result/index.tsx @@ -1,7 +1,9 @@ import { Link } from '@tanstack/react-router'; +import { SimulatorMobilePlaceholder } from 'components/simulator/mobile-placeholder'; import { SimResultChart } from 'components/simulator/result/SimResultChart'; import { SimResultSummary } from 'components/simulator/result/SimResultSummary'; import { useSimulator } from 'components/simulator/result/SimulatorProvider'; +import { useBreakpoints } from 'hooks/useBreakpoints'; import { useCallback, useEffect } from 'react'; import { ReactComponent as IconChevronLeft } from 'assets/icons/chevron-left.svg'; import { wait } from 'utils/helpers'; @@ -25,6 +27,10 @@ export const SimulatorResultPage = () => { handleAnimationStart(); }, [handleAnimationStart]); + const { aboveBreakpoint } = useBreakpoints(); + + if (!aboveBreakpoint('md')) return ; + return (
{simulationType === 'recurring' && (