From f06344ff8d16cda08c745a65753c20d5566091a6 Mon Sep 17 00:00:00 2001 From: DimaAmega Date: Thu, 26 Dec 2024 01:09:37 +0400 Subject: [PATCH] wip: better `useFetcher` --- .../src/router-utils/components/link.tsx | 43 +++++++++++++++--- .../src/router-utils/fetchers.tsx | 40 ++++++++++------- .../src/router-utils/hooks.tsx | 11 ++++- .../src/router-utils/types.ts | 12 ++++- ui/service/src/routes/components.tsx | 44 +++---------------- ui/service/src/routes/hooks.tsx | 4 ++ .../src/routes/src/project/project-main.tsx | 1 + .../routes/src/projects-list/components.tsx | 26 +++++------ .../src/reports-list/reports-list-main.tsx | 19 ++++---- .../test-suites-list-main.tsx | 14 +++--- ui/service/src/routes/types.tsx | 2 + ui/service/vite.config.ts | 2 +- 12 files changed, 122 insertions(+), 96 deletions(-) create mode 100644 ui/service/src/routes/hooks.tsx diff --git a/ui/packages/evidently-ui-lib/src/router-utils/components/link.tsx b/ui/packages/evidently-ui-lib/src/router-utils/components/link.tsx index 9c6d02ad92..bda5d07df6 100644 --- a/ui/packages/evidently-ui-lib/src/router-utils/components/link.tsx +++ b/ui/packages/evidently-ui-lib/src/router-utils/components/link.tsx @@ -8,6 +8,8 @@ import { type TypographyProps } from '@mui/material' import { Link as ReactRouterLink } from 'react-router-dom' +import type { GetParams, MatchAny } from 'router-utils/types' +import { replaceParamsInLink } from 'router-utils/utils' export type RouterLinkTemplateComponentProps = | ({ @@ -20,7 +22,7 @@ export type RouterLinkTemplateComponentProps = type: 'tab' } & RLT) -export const RouterLinkTemplate = (props: RouterLinkTemplateComponentProps) => { +const RouterLinkTemplate = (props: RouterLinkTemplateComponentProps) => { return props.type === 'button' ? ( ) : props.type === 'tab' ? ( @@ -30,12 +32,12 @@ export const RouterLinkTemplate = (props: RouterLinkTemplateComponentProps) => { ) } -export type RLB = { +type RLB = { to: string title?: string } & ButtonProps -export const RLBComponent = ({ to, title, ...buttonProps }: RLB) => { +const RLBComponent = ({ to, title, ...buttonProps }: RLB) => { return (