Skip to content

Commit

Permalink
Merge branch 'main' into issue-#774
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagofilipenunes committed Apr 17, 2024
2 parents 7db925a + 9b4b0f7 commit d19d763
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
5 changes: 4 additions & 1 deletion src/libs/routing/routes/sim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/libs/routing/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
//
}
Expand Down
26 changes: 12 additions & 14 deletions src/pages/simulator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@ export const SimulatorPage = () => {
<>
<h1 className="text-24 font-weight-500 mb-16 px-20">Simulate Strategy</h1>
<div className="flex gap-20 px-20">
{!isError && (
<div className="flex w-[440px] flex-col gap-20">
<SimInputTokenSelection
baseToken={searchState.baseToken}
quoteToken={searchState.quoteToken}
noPriceHistory={isError}
/>
<SimInputStrategyType
baseToken={searchState.baseToken}
quoteToken={searchState.quoteToken}
/>
<Outlet />
</div>
)}
<div className="flex w-[440px] flex-col gap-20">
<SimInputTokenSelection
baseToken={searchState.baseToken}
quoteToken={searchState.quoteToken}
noPriceHistory={isError}
/>
<SimInputStrategyType
baseToken={searchState.baseToken}
quoteToken={searchState.quoteToken}
/>
<Outlet />
</div>
</div>
</>
);
Expand Down
6 changes: 6 additions & 0 deletions src/pages/simulator/result/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -25,6 +27,10 @@ export const SimulatorResultPage = () => {
handleAnimationStart();
}, [handleAnimationStart]);

const { aboveBreakpoint } = useBreakpoints();

if (!aboveBreakpoint('md')) return <SimulatorMobilePlaceholder />;

return (
<div className="p-20">
{simulationType === 'recurring' && (
Expand Down

0 comments on commit d19d763

Please sign in to comment.