diff --git a/e2e/screenshots/simulator/recurring/Recurring_limit_limit/form.png b/e2e/screenshots/simulator/recurring/Recurring_limit_limit/form.png index db3e35ebd..b8733be31 100644 Binary files a/e2e/screenshots/simulator/recurring/Recurring_limit_limit/form.png and b/e2e/screenshots/simulator/recurring/Recurring_limit_limit/form.png differ diff --git a/e2e/screenshots/simulator/recurring/Recurring_limit_limit/simulator-input-price.png b/e2e/screenshots/simulator/recurring/Recurring_limit_limit/simulator-input-price.png index 2c5f8765c..8629403e5 100644 Binary files a/e2e/screenshots/simulator/recurring/Recurring_limit_limit/simulator-input-price.png and b/e2e/screenshots/simulator/recurring/Recurring_limit_limit/simulator-input-price.png differ diff --git a/e2e/screenshots/simulator/recurring/Recurring_range_limit/simulator-input-price.png b/e2e/screenshots/simulator/recurring/Recurring_range_limit/simulator-input-price.png index aab57abc6..66444396e 100644 Binary files a/e2e/screenshots/simulator/recurring/Recurring_range_limit/simulator-input-price.png and b/e2e/screenshots/simulator/recurring/Recurring_range_limit/simulator-input-price.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/form.png index 1a0d7670e..a38048d44 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/form.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/undercut/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/undercut/form.png index e0ffd028c..f5d89df50 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/undercut/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/undercut/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/deposit/form.png b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/deposit/form.png index 6faeeae05..34ef7c3e0 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_limit/deposit/form.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_limit/deposit/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_range/deposit/form.png b/e2e/screenshots/strategy/recurring/Recurring_limit_range/deposit/form.png index 63fc510fa..472c8d886 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_range/deposit/form.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_range/deposit/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/form.png index 10d7a0f30..228c75d28 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_limit/deposit/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_limit/deposit/form.png index 726e121ba..a49c517b5 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_limit/deposit/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_limit/deposit/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_limit/duplicate/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_limit/duplicate/form.png index 184069c87..68f49cc6b 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_limit/duplicate/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_limit/duplicate/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_limit/undercut/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_limit/undercut/form.png index c51ddbae2..cfa103abc 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_limit/undercut/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_limit/undercut/form.png differ diff --git a/package.json b/package.json index 233510744..738556a37 100644 --- a/package.json +++ b/package.json @@ -15,10 +15,11 @@ "@sentry/vite-plugin": "^2.21.1", "@tanstack/react-query": "^5.40.1", "@tanstack/react-query-devtools": "^5.40.1", - "@tanstack/react-router": "^1.4.9", + "@tanstack/react-router": "1.57.18", "@tanstack/react-table": "^8.9.3", "@tanstack/react-virtual": "^3.0.0-beta.30", "@tanstack/router-devtools": "^1.4.9", + "@tanstack/router-valibot-adapter": "^1.57.18", "@testing-library/dom": "^10.2.0", "@testing-library/jest-dom": "^6.4.6", "@testing-library/react": "^16.0.0", @@ -132,4 +133,4 @@ "@types/d3": "^7.4.3" }, "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" -} \ No newline at end of file +} diff --git a/src/components/activity/ActivityProvider.tsx b/src/components/activity/ActivityProvider.tsx index a5f43d68b..db0bc4a0d 100644 --- a/src/components/activity/ActivityProvider.tsx +++ b/src/components/activity/ActivityProvider.tsx @@ -19,7 +19,7 @@ interface ActivityContextType { status: 'error' | 'pending' | 'success'; fetchStatus: FetchStatus; queryParams: QueryActivityParams; - searchParams: ActivitySearchParams; + searchParams: Partial; setSearchParams: (searchParams: Partial) => any; } @@ -51,13 +51,18 @@ const getQueryParams = ( return params; }; +type ActivityUrls = + | '/strategies/activity' + | '/explore/$type/$slug/activity' + | '/strategy/$id'; interface Props { + url: ActivityUrls; params: QueryActivityParams; children: ReactNode; } type ParamsKey = Extract; -export const ActivityProvider: FC = ({ children, params }) => { - const nav = useNavigate(); +export const ActivityProvider: FC = ({ children, params, url }) => { + const nav = useNavigate({ from: url }); const searchParams: ActivitySearchParams = useSearch({ strict: false }); const limit = searchParams.limit; const offset = searchParams.offset; @@ -78,17 +83,7 @@ export const ActivityProvider: FC = ({ children, params }) => { replace: true, resetScroll: false, params: (params) => params, - search: (currentSearch) => { - const updates = structuredClone(changes); - const search = structuredClone(currentSearch); - for (const [key, value] of Object.entries(changes)) { - if (isEmpty(value)) { - delete (updates as any)[key]; - if (key in search) delete (search as any)[key]; - } - } - return { ...search, ...updates }; - }, + search: (current) => ({ ...current, ...changes }), }); }, [nav] diff --git a/src/components/activity/utils.ts b/src/components/activity/utils.ts index 4018adf4d..b8f50cbe9 100644 --- a/src/components/activity/utils.ts +++ b/src/components/activity/utils.ts @@ -1,12 +1,10 @@ -import { PaginationParams } from 'hooks/useList'; import { Activity, ActivityAction } from 'libs/queries/extApi/activity'; import { - SearchParamsValidator, + InferSearch, + searchValidator, validArrayOf, - validLiteral, - validNumber, + validNumberType, validString, - validateSearchParams, } from 'libs/routing/utils'; import { SafeDecimal } from 'libs/safedecimal'; import { @@ -16,18 +14,8 @@ import { tokenRange, } from 'utils/helpers'; import { exist } from 'utils/helpers/operators'; +import * as v from 'valibot'; -export interface ActivitySearchParams extends Partial { - pairs?: string[]; - ids?: string[]; - actions?: ActivityAction[]; - start?: Date; - end?: Date; - // This is only for StrategyPageParams, but if I don't implement it here the build breaks - priceStart?: string; - priceEnd?: string; - hideIndicators?: boolean; -} export const activityActionName: Record = { create: 'Create', edit: 'Edit Price', @@ -43,29 +31,17 @@ export const activityActions = Object.keys( activityActionName ) as ActivityAction[]; -export const activityValidators: SearchParamsValidator = { - actions: validArrayOf(validLiteral(activityActions)), - ids: validArrayOf(validString), - pairs: validArrayOf(validString), - start: validString, - end: validString, - limit: validNumber, - offset: validNumber, -}; -export const validateActivityParams = ( - activityValidators: SearchParamsValidator -) => { - return (search: Record): ActivitySearchParams => { - const rawSearch = validateSearchParams(activityValidators)(search); - const limit = Number(rawSearch.limit ?? 10); - const offset = Number(rawSearch.offset ?? 0); - return { - ...rawSearch, - limit, - offset, - }; - }; +export type ActivitySearchParams = InferSearch; +export const activityValidators = { + actions: v.optional(validArrayOf(v.picklist(activityActions))), + ids: v.optional(validArrayOf(validString)), + pairs: v.optional(validArrayOf(validString)), + start: v.optional(validString), + end: v.optional(validString), + limit: v.optional(validNumberType, 10), + offset: v.optional(validNumberType, 0), }; +export const validateActivityParams = searchValidator(activityValidators); export const activityHasPairs = (activity: Activity, pairs: string[] = []) => { if (pairs.length === 0) return true; diff --git a/src/components/core/menu/mainMenu/MainMenuLeft.tsx b/src/components/core/menu/mainMenu/MainMenuLeft.tsx index ee9da19df..adbaffb34 100644 --- a/src/components/core/menu/mainMenu/MainMenuLeft.tsx +++ b/src/components/core/menu/mainMenu/MainMenuLeft.tsx @@ -37,9 +37,6 @@ export const MainMenuLeft: FC = () => { key={index} onClick={() => handleOnItemClick(href)} to={href} - // TODO: fix this - params={{}} - search={{}} aria-current={isSamePage ? 'page' : 'false'} data-testid={testid} className={`font-title px-3 py-3 transition-colors duration-300 ${ diff --git a/src/components/core/menu/mobileMenu/MobileMenu.tsx b/src/components/core/menu/mobileMenu/MobileMenu.tsx index 5e74fc012..a1fa3d452 100644 --- a/src/components/core/menu/mobileMenu/MobileMenu.tsx +++ b/src/components/core/menu/mobileMenu/MobileMenu.tsx @@ -26,9 +26,6 @@ export const MobileMenu: FC = () => { key={index} onClick={() => handleOnItemClick(href)} to={href} - // TODO: fix this - params={{}} - search={{}} aria-current={isSamePage ? 'page' : 'false'} className={`px-3 py-3 ${ isSamePage ? 'text-white' : 'hover:text-white' diff --git a/src/components/explorer/ExplorerSearch.tsx b/src/components/explorer/ExplorerSearch.tsx index 7b9fb0fae..8c021cce3 100644 --- a/src/components/explorer/ExplorerSearch.tsx +++ b/src/components/explorer/ExplorerSearch.tsx @@ -28,7 +28,7 @@ import { useDebouncedValue } from 'hooks/useDebouncedValue'; export const _ExplorerSearch: FC = () => { const navigate = useNavigate(); const pairs = usePairs(); - const { type, slug } = useExplorerParams(); + const { type, slug } = useExplorerParams('/explore/$type'); const [search, setSearch] = useState(slug ?? ''); const [debouncedSearch] = useDebouncedValue(search, 300); // Debounce search input for ens query diff --git a/src/components/explorer/ExplorerSearchDropdownButton.tsx b/src/components/explorer/ExplorerSearchDropdownButton.tsx index b95b9dd8d..7d2482411 100644 --- a/src/components/explorer/ExplorerSearchDropdownButton.tsx +++ b/src/components/explorer/ExplorerSearchDropdownButton.tsx @@ -9,7 +9,7 @@ export const ExplorerSearchDropdownButton = forwardRef< HTMLButtonElement, MenuButtonProps >(function ExplorerSearchDropdownButton(props, ref) { - const { type } = useExplorerParams(); + const { type } = useExplorerParams('/explore/$type'); return (