Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
joonashak committed Jan 11, 2025
1 parent 24ccfb6 commit a008f21
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
16 changes: 0 additions & 16 deletions web/src/components/common/AppLink.tsx

This file was deleted.

13 changes: 13 additions & 0 deletions web/src/components/common/Link.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { LinkProps, Link as MuiLink } from "@mui/material";
import { Link as RouterLink } from "react-router-dom";

/**
* MUI `<Link>` with React Router's `<Link>` as base component.
*
* Helps with imports as the two components are exported with the same name.
*/
const Link = (props: LinkProps<typeof RouterLink>) => (
<MuiLink {...props} component={RouterLink} />
);

export default Link;
9 changes: 4 additions & 5 deletions web/src/components/map/SystemNode.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Box, Link, Typography } from "@mui/material";
import { Box, Typography } from "@mui/material";
import { Handle, Position } from "@xyflow/react";
import { Link as RouterLink } from "react-router-dom";

import Link from "../common/Link";
import { SystemNodeData } from "./data/map-flow-types";

type SystemNodeProps = {
Expand Down Expand Up @@ -30,9 +31,7 @@ const SystemNode = ({ data }: SystemNodeProps) => {
<Handle type="target" position={Position.Top} style={{ opacity: 0 }} />

{to ? (
<Link component={RouterLink} to={to}>
{name || systemName}
</Link>
<Link to={to}>{name || systemName}</Link>
) : (
<Typography>{name || systemName}</Typography>
)}
Expand Down

0 comments on commit a008f21

Please sign in to comment.