mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-22 14:54:22 +00:00
🔧 Fix warnings
This commit is contained in:
parent
da453db439
commit
13e5dc14f7
3 changed files with 19 additions and 21 deletions
|
@ -1,15 +1,11 @@
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import {Anchor} from "@steffo/bluelib-react";
|
import {Anchor, BringAttention as B} from "@steffo/bluelib-react";
|
||||||
import {navigate} from "@reach/router";
|
import {navigate, useLocation} from "@reach/router";
|
||||||
import {AnchorProps} from "@steffo/bluelib-react/dist/components/common/Anchor";
|
import {AnchorProps} from "@steffo/bluelib-react/dist/components/common/Anchor";
|
||||||
|
|
||||||
|
|
||||||
interface LinkProps extends AnchorProps {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export function Link({href, children, onClick, ...props}: AnchorProps): JSX.Element {
|
export function Link({href, children, onClick, ...props}: AnchorProps): JSX.Element {
|
||||||
|
const location = useLocation()
|
||||||
|
|
||||||
const onClickWrapped = React.useCallback(
|
const onClickWrapped = React.useCallback(
|
||||||
event => {
|
event => {
|
||||||
|
@ -22,10 +18,17 @@ export function Link({href, children, onClick, ...props}: AnchorProps): JSX.Elem
|
||||||
navigate(href)
|
navigate(href)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[href]
|
[href, onClick]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(location.pathname === href) {
|
||||||
|
return (
|
||||||
|
<B children={children} {...props}/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else {
|
||||||
return (
|
return (
|
||||||
<Anchor href={href} children={children} onClick={onClickWrapped} {...props}/>
|
<Anchor href={href} children={children} onClick={onClickWrapped} {...props}/>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,7 @@ import {useDRFManagedViewSet} from "../hooks/useDRF";
|
||||||
import {Loading} from "./Loading";
|
import {Loading} from "./Loading";
|
||||||
|
|
||||||
|
|
||||||
interface ResearchGroupListBoxProps {
|
export function ResearchGroupListBox(): JSX.Element {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export function ResearchGroupListBox({}: ResearchGroupListBoxProps): JSX.Element {
|
|
||||||
const {resources, refreshing} = useDRFManagedViewSet<ResearchGroup>("/api/core/groups/", "slug")
|
const {resources, refreshing} = useDRFManagedViewSet<ResearchGroup>("/api/core/groups/", "slug")
|
||||||
|
|
||||||
const groups = React.useMemo(
|
const groups = React.useMemo(
|
||||||
|
|
|
@ -20,17 +20,17 @@ export function UserLink({id}: UserLinkProps): JSX.Element {
|
||||||
React.useEffect(
|
React.useEffect(
|
||||||
() => {
|
() => {
|
||||||
const abort = new AbortController()
|
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 () => {
|
return () => {
|
||||||
abort.abort()
|
abort.abort()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[retrieve, setUser]
|
[retrieve, setUser, id]
|
||||||
)
|
)
|
||||||
|
|
||||||
// FIXME: use proper bluelib Anchors
|
|
||||||
|
|
||||||
if(error) return (
|
if(error) return (
|
||||||
<Link href={`/u/${id}`} title={id.toString()}>
|
<Link href={`/u/${id}`} title={id.toString()}>
|
||||||
<FontAwesomeIcon icon={faTimesCircle}/> {id}
|
<FontAwesomeIcon icon={faTimesCircle}/> {id}
|
||||||
|
|
Loading…
Reference in a new issue