mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-23 07:14:21 +00:00
🔧 Fix warnings
This commit is contained in:
parent
87965c4288
commit
b052218a13
3 changed files with 19 additions and 21 deletions
|
@ -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]
|
||||
)
|
||||
|
||||
if(location.pathname === href) {
|
||||
return (
|
||||
<B children={children} {...props}/>
|
||||
)
|
||||
}
|
||||
else {
|
||||
return (
|
||||
<Anchor href={href} children={children} onClick={onClickWrapped} {...props}/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in a new issue