diff --git a/src/common/app-link/app-link.stories.tsx b/src/common/app-link/app-link.stories.tsx index 96bfbb6..beaf728 100644 --- a/src/common/app-link/app-link.stories.tsx +++ b/src/common/app-link/app-link.stories.tsx @@ -25,37 +25,33 @@ export default { } as ComponentMeta; export const Default: ComponentStory = ({ - routeName, className, targetBlank, - pathParams, - queryParams, children, + route, }) => ( - + {children} ); Default.argTypes = { - routeName: { - control: { - type: "select", - options: RouteName, + route: { + routeName: { + control: { + type: "select", + options: RouteName, + }, }, }, }; Default.args = { children: "My Link To Home", - routeName: RouteName.Home, + route: { + routeName: RouteName.Home, + pathParams: {}, + queryParams: {}, + }, className: "", targetBlank: false, - pathParams: {}, - queryParams: {}, }; diff --git a/src/common/app-link/app-link.tsx b/src/common/app-link/app-link.tsx index c37024e..652fc03 100644 --- a/src/common/app-link/app-link.tsx +++ b/src/common/app-link/app-link.tsx @@ -13,29 +13,35 @@ import type { Params, RouteName } from "../../routes/routes"; defined in this project. To link outside, use tags as usual. */ +type Route = { + pathParams?: Params; + queryParams?: Params; + routeName: RouteName; +}; + // Extract pathParams from the routeName -type AppLinkProps = { +type AppLinkProps = { children: React.ReactNode; className?: string; - pathParams?: Params; - queryParams?: Params; - routeName: R; + route: Route; targetBlank?: boolean; + replace?: boolean; + preventScrollReset?: boolean; + state?: any; + reloadDocument?: boolean; }; const defaultProps = { className: "", - pathParams: {}, - queryParams: {}, targetBlank: false, + replace: false, + preventScrollReset: false, + reloadDocument: false, }; -const AppLink = (props: AppLinkProps) => { - const routePath = getRouteFor( - props.routeName, - props.pathParams, - props.queryParams, - ); +const AppLink = (props: AppLinkProps) => { + const { routeName, pathParams, queryParams } = props.route; + const routePath = getRouteFor(routeName, pathParams, queryParams); let targetBlankProps = {}; if (props.targetBlank) { targetBlankProps = { @@ -44,7 +50,15 @@ const AppLink = (props: AppLinkProps) => { }; } return ( - + {props.children} ); diff --git a/src/common/app-redirect/app-redirect.tsx b/src/common/app-redirect/app-redirect.tsx index 16043c0..0d30153 100644 --- a/src/common/app-redirect/app-redirect.tsx +++ b/src/common/app-redirect/app-redirect.tsx @@ -13,26 +13,24 @@ import type { Params, RouteName } from "../../routes/routes"; defined in this project. To link outside, use tags as usual. */ -type AppRedirectProps = { +type Route = { pathParams?: Params; queryParams?: Params; - routeName: R; + routeName: RouteName; }; -const defaultProps = { - pathParams: {}, - queryParams: {}, +type AppRedirectProps = { + route: Route; }; -const AppRedirect = (props: AppRedirectProps) => { +const AppRedirect = (props: AppRedirectProps) => { + const { routeName, pathParams, queryParams } = props.route; const goToPage = useGoToPage(); useEffect(() => { - goToPage(props.routeName, props.pathParams, props.queryParams); + goToPage(routeName, pathParams, queryParams); }, []); return null; }; -AppRedirect.defaultProps = defaultProps; - export { AppRedirect }; diff --git a/src/common/navbar/navbar.tsx b/src/common/navbar/navbar.tsx index 0db9172..baf61e2 100644 --- a/src/common/navbar/navbar.tsx +++ b/src/common/navbar/navbar.tsx @@ -10,11 +10,16 @@ export const Navbar = () => (
- Logo goes here + + Logo goes here +
diff --git a/src/pages/not-found/not-found.tsx b/src/pages/not-found/not-found.tsx index cb25c7d..6d5ab3a 100644 --- a/src/pages/not-found/not-found.tsx +++ b/src/pages/not-found/not-found.tsx @@ -7,7 +7,7 @@ import { RouteName } from "routes/routes"; const NotFound = () => (
This page does not exist! - Go Home + Go Home
);