1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-10-17 07:27:29 +00:00

🔧 Fix warnings

This commit is contained in:
Steffo 2021-09-20 17:08:04 +02:00
parent da453db439
commit 13e5dc14f7
3 changed files with 19 additions and 21 deletions

View file

@ -1,15 +1,11 @@
import * as React from "react"
import {Anchor} from "@steffo/bluelib-react";
import {navigate} from "@reach/router";
import {Anchor, BringAttention as B} from "@steffo/bluelib-react";
import {navigate, useLocation} from "@reach/router";
import {AnchorProps} from "@steffo/bluelib-react/dist/components/common/Anchor";
interface LinkProps extends AnchorProps {
}
export function Link({href, children, onClick, ...props}: AnchorProps): JSX.Element {
const location = useLocation()
const onClickWrapped = React.useCallback(
event => {
@ -22,10 +18,17 @@ export function Link({href, children, onClick, ...props}: AnchorProps): JSX.Elem
navigate(href)
}
},
[href]
[href, onClick]
)
return (
<Anchor href={href} children={children} onClick={onClickWrapped} {...props}/>
)
if(location.pathname === href) {
return (
<B children={children} {...props}/>
)
}
else {
return (
<Anchor href={href} children={children} onClick={onClickWrapped} {...props}/>
)
}
}

View file

@ -6,12 +6,7 @@ import {useDRFManagedViewSet} from "../hooks/useDRF";
import {Loading} from "./Loading";
interface ResearchGroupListBoxProps {
}
export function ResearchGroupListBox({}: ResearchGroupListBoxProps): JSX.Element {
export function ResearchGroupListBox(): JSX.Element {
const {resources, refreshing} = useDRFManagedViewSet<ResearchGroup>("/api/core/groups/", "slug")
const groups = React.useMemo(

View file

@ -20,17 +20,17 @@ export function UserLink({id}: UserLinkProps): JSX.Element {
React.useEffect(
() => {
const abort = new AbortController()
retrieve(id.toString(), {signal: abort.signal}).then(u => setUser(u))
retrieve(id.toString(), {signal: abort.signal})
.then(u => setUser(u))
.catch(e => setError(e as Error))
return () => {
abort.abort()
}
},
[retrieve, setUser]
[retrieve, setUser, id]
)
// FIXME: use proper bluelib Anchors
if(error) return (
<Link href={`/u/${id}`} title={id.toString()}>
<FontAwesomeIcon icon={faTimesCircle}/> {id}