1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-24 14:04:19 +00:00

🧹 Reformat code

This commit is contained in:
Stefano Pigozzi 2021-05-11 16:37:15 +02:00
parent 70fe072b5e
commit 809d86758c
Signed by untrusted user who does not match committer: steffo
GPG key ID: 6965406171929D01
50 changed files with 207 additions and 194 deletions

View file

@ -22,7 +22,7 @@ export default function ButtonSidebar({ icon, children, to, className, ...props
path: to,
strict: true,
exact: true,
});
})
if(match) {
className = classNames(Style.Active, className)

View file

@ -1,7 +1,7 @@
import React from "react"
import Style from "./ButtonSmallX.module.css"
import classNames from "classnames"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faTimes } from "@fortawesome/free-solid-svg-icons"

View file

@ -1,4 +1,4 @@
import React, {useState} from "react"
import React, { useState } from "react"
import Style from "./InputWithIcon.module.css"
import classNames from "classnames"
import make_icon from "../../utils/make_icon"
@ -17,7 +17,7 @@ import make_icon from "../../utils/make_icon"
* @constructor
*/
export default function InputWithIcon({ icon, className, ...props }) {
const [isFocused, setFocused] = useState(false);
const [isFocused, setFocused] = useState(false)
return (
<div className={classNames(Style.InputWithIcon, isFocused ? Style.Focused : null, className)}>

View file

@ -1,6 +1,6 @@
import React from "react"
import { faSpinner } from "@fortawesome/free-solid-svg-icons"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
/**

View file

@ -2,6 +2,7 @@ import React from "react"
import Style from "./Radio.module.css"
import classNames from "classnames"
/**
* A radio button.
*

View file

@ -15,7 +15,10 @@ import classNames from "classnames"
*/
export default function TextArea({ resize, children, className, ...props }) {
return (
<textarea className={classNames(Style.TextArea, resize ? Style.TextAreaResizable : Style.TextAreaNoResize, className)} {...props}>
<textarea
className={classNames(Style.TextArea, resize
? Style.TextAreaResizable
: Style.TextAreaNoResize, className)} {...props}>
{children}
</textarea>
)

View file

@ -16,7 +16,7 @@ import Style from "./FormLabel.module.css"
export default function FormLabel({ children, text, htmlFor }) {
return (
<Fragment>
<label htmlFor={htmlFor} className={Style.LabelText} >
<label htmlFor={htmlFor} className={Style.LabelText}>
{text}
</label>
<div className={Style.LabelContent}>

View file

@ -1,7 +1,7 @@
import React, { useState } from "react"
import BoxFull from "../base/BoxFull"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
import { faAt, faClock, faPlus } from "@fortawesome/free-solid-svg-icons"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faClock, faPlus } from "@fortawesome/free-solid-svg-icons"
import InputWithIcon from "../base/InputWithIcon"
import FormInline from "../base/FormInline"
import Style from "./BoxConditionDatetime.module.css"
@ -26,7 +26,7 @@ const INVALID_USER_CHARACTERS = /[^0-9TZ:+-]/g
export default function BoxConditionDatetime({ ...props }) {
const [datetime, setDatetime] = useState("")
const [ba, setBa] = useState(false)
const {addCondition} = useRepositoryEditor()
const { addCondition } = useRepositoryEditor()
const onInputChange = event => {
let text = event.target.value
@ -38,7 +38,7 @@ export default function BoxConditionDatetime({ ...props }) {
const onButtonClick = e => {
const naive = new Date(datetime)
if(naive.toString() === "Invalid Date") {
console.debug("Refusing to add condition: ", naive , " is an Invalid Date.")
console.debug("Refusing to add condition: ", naive, " is an Invalid Date.")
return
}
const aware = convertToLocalISODate(naive)

View file

@ -1,6 +1,6 @@
import React, { useState } from "react"
import BoxFull from "../base/BoxFull"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faHashtag, faPlus } from "@fortawesome/free-solid-svg-icons"
import InputWithIcon from "../base/InputWithIcon"
import FormInline from "../base/FormInline"
@ -24,7 +24,7 @@ const INVALID_HASHTAG_CHARACTERS = /([^a-z0-9_\u00c0-\u00d6\u00d8-\u00f6\u00f8-\
*/
export default function BoxConditionHashtag({ ...props }) {
const [hashtag, setHashtag] = useState("")
const {addCondition} = useRepositoryEditor()
const { addCondition } = useRepositoryEditor()
const onInputChange = event => {
let text = event.target.value

View file

@ -1,16 +1,15 @@
import React, { useCallback, useState, useRef, useMemo, useEffect } from "react"
import React, { useCallback, useEffect, useState } from "react"
import BoxFull from "../base/BoxFull"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faMapPin, faPlus } from "@fortawesome/free-solid-svg-icons"
import FormInline from "../base/FormInline"
import Style from "./BoxConditionMap.module.css"
import ButtonIconOnly from "../base/ButtonIconOnly"
import { MapContainer, Marker, TileLayer } from "react-leaflet"
import { MapContainer, TileLayer } from "react-leaflet"
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
import Condition from "../../utils/Condition"
const STARTING_POSITION = {lat: 41.89309, lng: 12.48289}
const STARTING_POSITION = { lat: 41.89309, lng: 12.48289 }
const STARTING_ZOOM = 3
// FIXME: this only works correctly at the equator!
@ -53,25 +52,27 @@ export default function BoxConditionMap({ ...props }) {
const [position, setPosition] = useState(STARTING_POSITION)
const [zoom, setZoom] = useState(STARTING_ZOOM)
const [map, setMap] = useState(null)
const {addCondition} = useRepositoryEditor()
const { addCondition } = useRepositoryEditor()
const onMove = useCallback(
() => {
setPosition(map.getCenter())
},
[map]
[map],
)
const onZoom = useCallback(
() => {
setZoom(map.getZoom())
},
[map]
[map],
)
useEffect(
() => {
if(map === null) return
if(map === null) {
return
}
map.on("move", onMove)
map.on("zoom", onZoom)
@ -80,7 +81,7 @@ export default function BoxConditionMap({ ...props }) {
map.off("zoom", onZoom)
}
},
[map]
[map],
)
const onButtonClick = () => {
@ -90,7 +91,7 @@ export default function BoxConditionMap({ ...props }) {
addCondition(new Condition(
"COORDINATES",
`< ${radius} ${position.lat} ${position.lng}`
`< ${radius} ${position.lat} ${position.lng}`,
))
setPosition(STARTING_POSITION)
}

View file

@ -1,6 +1,6 @@
import React, { useState } from "react"
import BoxFull from "../base/BoxFull"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faAt, faPlus } from "@fortawesome/free-solid-svg-icons"
import InputWithIcon from "../base/InputWithIcon"
import FormInline from "../base/FormInline"
@ -23,7 +23,7 @@ const INVALID_USER_CHARACTERS = /[^a-zA-Z0-9]/g
*/
export default function BoxConditionUser({ ...props }) {
const [user, setUser] = useState("")
const {addCondition} = useRepositoryEditor()
const { addCondition } = useRepositoryEditor()
const onInputChange = event => {
let text = event.target.value

View file

@ -12,7 +12,7 @@ import useRepositoryEditor from "../../hooks/useRepositoryEditor"
* @constructor
*/
export default function BoxConditions({ ...props }) {
const {conditions} = useRepositoryEditor()
const { conditions } = useRepositoryEditor()
const badges = conditions.map((cond, pos) => <ConditionBadge key={pos} {...cond}/>)

View file

@ -17,7 +17,7 @@ import CurrentServer from "./CurrentServer"
* @constructor
*/
export default function BoxLoggedIn({ ...props }) {
const {logout} = useContext(ContextUser)
const { logout } = useContext(ContextUser)
const history = useHistory()
return (
@ -27,10 +27,12 @@ export default function BoxLoggedIn({ ...props }) {
You are currently logged in at <CurrentServer/> as <LoggedInUser/>.
</div>
<div>
<Button color={"Red"} onClick={() => {
<Button
color={"Red"} onClick={() => {
logout()
history.push("/login")
}} icon={faSignOutAlt}>Logout</Button>
}} icon={faSignOutAlt}
>Logout</Button>
</div>
</div>
</BoxFull>

View file

@ -22,12 +22,12 @@ export default function BoxLogin({ ...props }) {
const [password, setPassword] = useState("password")
const [working, setWorking] = useState(false)
const [error, setError] = useState(null)
const {login} = useContext(ContextUser)
const { login } = useContext(ContextUser)
const history = useHistory()
const doLogin = async () => {
if(working) {
return;
return
}
setWorking(true)

View file

@ -15,9 +15,9 @@ import ContextUser from "../../contexts/ContextUser"
* @constructor
*/
export default function BoxRepositoriesActive({ repositories, refresh, ...props }) {
const {user} = useContext(ContextUser)
const { user } = useContext(ContextUser)
let contents;
let contents
if(repositories.length > 0) {
contents = repositories.map(repo => (
<RepositorySummaryBase

View file

@ -15,9 +15,9 @@ import { faSearch } from "@fortawesome/free-solid-svg-icons"
* @constructor
*/
export default function BoxRepositoriesArchived({ repositories, refresh, ...props }) {
const {user} = useContext(ContextUser)
const { user } = useContext(ContextUser)
let contents;
let contents
if(repositories.length > 0) {
contents = repositories.map(repo => (
<RepositorySummaryBase

View file

@ -34,7 +34,12 @@ export default function BoxRepositoryCreate({ ...props }) {
return (
<BoxFull header={"Create repository"} {...props}>
<FormLabelled onSubmit={e => {e.preventDefault(); save()}}>
<FormLabelled
onSubmit={e => {
e.preventDefault()
save()
}}
>
<FormLabel htmlFor={"repo-name"} text={"Repository name"}>
<InputWithIcon
id={"repo-name"}
@ -69,7 +74,7 @@ export default function BoxRepositoryCreate({ ...props }) {
: null}
{id ?
<Button
style={{"gridColumn": "1 / 3"}}
style={{ "gridColumn": "1 / 3" }}
icon={faPencilAlt}
color={"Green"}
onClick={e => goToOnSuccess(save, history, "/repositories")}
@ -78,7 +83,7 @@ export default function BoxRepositoryCreate({ ...props }) {
</Button>
:
<Button
style={{"gridColumn": "1 / 3"}}
style={{ "gridColumn": "1 / 3" }}
icon={faPlus}
color={"Green"}
onClick={e => goToOnSuccess(save, history, "/repositories")}

View file

@ -15,7 +15,7 @@ import ContextServer from "../../contexts/ContextServer"
* @constructor
*/
export default function BoxSetServer({ ...props }) {
const {server, setServer} = useContext(ContextServer);
const { server, setServer } = useContext(ContextServer)
return (
<BoxFull header={"Choose server"} {...props}>

View file

@ -1,7 +1,7 @@
import React, { useContext } from "react"
import Style from "./ConditionBadge.module.css"
import classNames from "classnames"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import ButtonSmallX from "../base/ButtonSmallX"
import { faAt, faClock, faGlobe, faHashtag, faMapPin } from "@fortawesome/free-solid-svg-icons"
import ContextRepositoryEditor from "../../contexts/ContextRepositoryEditor"
@ -36,7 +36,7 @@ export default function ConditionBadge({ ...condition }) {
const { id, type, content } = condition
const color = CONDITION_COLORS[type]
const icon = CONDITION_ICONS[type]
const {removeRawCondition} = useContext(ContextRepositoryEditor)
const { removeRawCondition } = useContext(ContextRepositoryEditor)
let displayedContent = content
if(type === 3) {
@ -65,10 +65,12 @@ export default function ConditionBadge({ ...condition }) {
{displayedContent}
</div>
<div>
<ButtonSmallX onClick={() => {
<ButtonSmallX
onClick={() => {
console.debug(`Removing Condition: `, condition)
removeRawCondition(condition)
}}/>
}}
/>
</div>
</div>
)

View file

@ -1,5 +1,5 @@
import React, { useContext } from "react"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faGlobe } from "@fortawesome/free-solid-svg-icons"
import ContextServer from "../../contexts/ContextServer"
@ -12,7 +12,7 @@ import ContextServer from "../../contexts/ContextServer"
* @constructor
*/
export default function CurrentServer({ ...props }) {
const {server} = useContext(ContextServer);
const { server } = useContext(ContextServer)
return (
<b {...props}>

View file

@ -8,8 +8,7 @@
display: grid;
grid-template-areas:
"a b"
;
"a b";
grid-template-columns: 250px 1fr;
grid-gap: 10px;

View file

@ -12,7 +12,7 @@ import ContextUser from "../../contexts/ContextUser"
* @constructor
*/
export default function LoggedInUser({ ...props }) {
const {user} = useContext(ContextUser);
const { user } = useContext(ContextUser)
if(!user) {
return (

View file

@ -1,4 +1,4 @@
import React, {useContext} from "react"
import React, { useContext } from "react"
import Style from "./Logo.module.css"
import LogoDark from "../../media/LogoDark.png"
import LogoLight from "../../media/LogoLight.png"
@ -19,9 +19,9 @@ import classNames from "classnames"
export default function Logo({ className, ...props }) {
// I have no idea why IntelliJ is complaining about this line
// It's perfectly fine!
const {theme} = useContext(ContextTheme)
const { theme } = useContext(ContextTheme)
let logo;
let logo
if(theme === "ThemeDark") {
logo = LogoDark
}

View file

@ -1,7 +1,7 @@
import React, { useContext } from "react"
import Style from "./RepositorySummaryBase.module.css"
import classNames from "classnames"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import Button from "../base/Button"
import { faArchive, faPencilAlt, faTrash } from "@fortawesome/free-solid-svg-icons"
import { useHistory } from "react-router"
@ -29,13 +29,13 @@ import ContextUser from "../../contexts/ContextUser"
* @constructor
*/
export default function RepositorySummaryBase(
{ id, refresh, owner, icon, name, start, end, is_active, canDelete, canEdit, canArchive, className, ...props }
{ id, refresh, owner, icon, name, start, end, is_active, canDelete, canEdit, canArchive, className, ...props },
) {
const {fetchDataAuth} = useContext(ContextUser)
const { fetchDataAuth } = useContext(ContextUser)
const history = useHistory()
const {fetchNow: archiveThis} = useData(fetchDataAuth, "PATCH", `/api/v1/repositories/${id}`, {"close": true})
const {fetchNow: unarchiveThis} = useData(fetchDataAuth, "PATCH", `/api/v1/repositories/${id}`, {"open": true})
const {fetchNow: deletThis} = useData(fetchDataAuth, "DELETE", `/api/v1/repositories/${id}`)
const { fetchNow: archiveThis } = useData(fetchDataAuth, "PATCH", `/api/v1/repositories/${id}`, { "close": true })
const { fetchNow: unarchiveThis } = useData(fetchDataAuth, "PATCH", `/api/v1/repositories/${id}`, { "open": true })
const { fetchNow: deletThis } = useData(fetchDataAuth, "DELETE", `/api/v1/repositories/${id}`)
const onEditClick = event => {
history.push(`/repositories/${id}/edit`)

View file

@ -17,8 +17,7 @@
"a b"
"a c"
"a d"
"a e"
;
"a e";
grid-template-columns: auto 1fr;
grid-template-rows: 5px 1fr 1fr 5px;

View file

@ -1,4 +1,4 @@
import React, {useContext} from "react"
import React, { useContext } from "react"
import Select from "../base/Select"
import ContextTheme from "../../contexts/ContextTheme"
@ -12,7 +12,7 @@ import ContextTheme from "../../contexts/ContextTheme"
* @constructor
*/
export default function SelectTheme({ ...props }) {
const {theme, setTheme} = useContext(ContextTheme);
const { theme, setTheme } = useContext(ContextTheme)
return (
<Select value={theme} onChange={e => setTheme(e.target.value)} {...props}>

View file

@ -17,7 +17,7 @@ import ContextUser from "../../contexts/ContextUser"
* @constructor
*/
export default function Sidebar({ className, ...props }) {
const {user} = useContext(ContextUser)
const { user } = useContext(ContextUser)
return (
<aside className={classNames(Style.Sidebar, className)} {...props}>

View file

@ -75,7 +75,7 @@ export default function GlobalServer({ children }) {
}, [server])
return (
<ContextServer.Provider value={{server, setServer, fetchData}}>
<ContextServer.Provider value={{ server, setServer, fetchData }}>
{children}
</ContextServer.Provider>
)

View file

@ -14,7 +14,7 @@ export default function GlobalTheme({ children }) {
const [theme, setTheme] = useLocalStorageState("theme", "ThemeDark")
return (
<ContextTheme.Provider value={{theme, setTheme}}>
<ContextTheme.Provider value={{ theme, setTheme }}>
{children}
</ContextTheme.Provider>
)

View file

@ -12,7 +12,7 @@ import ContextUser from "../../contexts/ContextUser"
* @constructor
*/
export default function GlobalUser({ children }) {
const {fetchData} = useContext(ContextServer)
const { fetchData } = useContext(ContextServer)
const [user, setUser] = useLocalStorageState("login", null)
/**
@ -79,7 +79,7 @@ export default function GlobalUser({ children }) {
}, [setUser])
return (
<ContextUser.Provider value={{user, login, logout, fetchDataAuth}}>
<ContextUser.Provider value={{ user, login, logout, fetchDataAuth }}>
{children}
</ContextUser.Provider>
)

View file

@ -22,7 +22,7 @@ export default function RepositoryEditor({
conditions,
evaluation_mode: evaluationMode,
className,
}) {
}) {
/** The repository name. */
const [_name, setName] = useState(name ?? "")
@ -47,7 +47,7 @@ export default function RepositoryEditor({
/** The operator the conditions should be evaluated with. */
const [_evaluationMode, setEvaluationMode] = useState(evaluationMode ?? 0)
const {user, fetchDataAuth} = useContext(ContextUser)
const { user, fetchDataAuth } = useContext(ContextUser)
const method = id ? "PUT" : "POST"
const path = id ? `/api/v1/repositories/${id}` : `/api/v1/repositories/`
@ -61,7 +61,7 @@ export default function RepositoryEditor({
"owner": user,
"start": _start,
}
const {error, loading, fetchNow} = useData(fetchDataAuth, method, path, body)
const { error, loading, fetchNow } = useData(fetchDataAuth, method, path, body)
const save = useCallback(
() => {
@ -73,7 +73,7 @@ export default function RepositoryEditor({
}
fetchNow()
},
[id, body, fetchNow]
[id, body, fetchNow],
)
@ -89,7 +89,7 @@ export default function RepositoryEditor({
setRawConditions(conditions)
setEvaluationMode(evaluationMode)
},
[name, isActive, start, end, conditions, evaluationMode]
[name, isActive, start, end, conditions, evaluationMode],
)
/**
@ -104,7 +104,7 @@ export default function RepositoryEditor({
}
// Check for duplicates
let duplicate = null;
let duplicate = null
for(const oldCond of _conditions) {
if(newCond.type === oldCond.type && newCond.content === oldCond.content) {
duplicate = oldCond
@ -119,11 +119,12 @@ export default function RepositoryEditor({
console.debug("Adding ", newCond, " to the Repository Conditions")
appendRawCondition(newCond)
},
[_conditions]
[_conditions],
)
return (
<ContextRepositoryEditor.Provider value={{
<ContextRepositoryEditor.Provider
value={{
id,
name: _name, setName,
isActive: _isActive, setActive,
@ -133,7 +134,8 @@ export default function RepositoryEditor({
evaluationMode: _evaluationMode, setEvaluationMode,
error, loading,
revert, save,
}}>
}}
>
<div className={classNames(Style.RepositoryEditor, className)}>
<BoxConditionMap className={Style.SearchByZone}/>
<BoxConditionHashtag className={Style.SearchByHashtags}/>

View file

@ -6,8 +6,7 @@
"b d"
"b e"
"b f"
"b g"
;
"b g";
grid-template-columns: 400px 1fr;
grid-template-rows: auto auto auto 1fr auto;

View file

@ -1,4 +1,4 @@
import {createContext} from "react";
import { createContext } from "react"
/**

View file

@ -1,4 +1,4 @@
import {createContext} from "react";
import { createContext } from "react"
/**

View file

@ -1,4 +1,4 @@
import {createContext} from "react";
import { createContext } from "react"
/**
@ -14,6 +14,6 @@ import {createContext} from "react";
const ContextTheme = createContext({
isSet: false,
theme: "ThemeDark",
setTheme: () => console.error("Trying to setTheme while outside a ContextTheme.Provider!")
setTheme: () => console.error("Trying to setTheme while outside a ContextTheme.Provider!"),
})
export default ContextTheme

View file

@ -1,4 +1,4 @@
import {createContext} from "react";
import { createContext } from "react"
/**

View file

@ -14,10 +14,10 @@ export default function useArrayState(def) {
newSingle => {
console.debug("Appending ", newSingle, " to ArrayState")
setValue(
oldArray => [...oldArray, newSingle]
oldArray => [...oldArray, newSingle],
)
},
[]
[],
)
const spliceValue = useCallback(
@ -28,21 +28,21 @@ export default function useArrayState(def) {
// TODO: Hope this doesn't break anything...
oldArray.splice(position, 1)
return oldArray
}
},
)
},
[]
[],
)
const removeValue = useCallback(
remValue => {
console.debug("Removing ", remValue, " from ArrayState")
setValue(
oldArray => oldArray.filter(item => JSON.stringify(item) !== JSON.stringify(remValue))
oldArray => oldArray.filter(item => JSON.stringify(item) !== JSON.stringify(remValue)),
)
},
[]
[],
)
return {value, setValue, appendValue, spliceValue, removeValue}
return { value, setValue, appendValue, spliceValue, removeValue }
}

View file

@ -1,4 +1,4 @@
import { useCallback, useEffect, useState } from "react"
import { useCallback, useState } from "react"
/**
@ -28,15 +28,17 @@ export default function useData(fetchData, method, path, body, init) {
const _data = await fetchData(method, path, body, init)
console.debug(`Displaying data of ${method} ${path}: `, _data)
setData(_data)
} catch(e) {
}
catch(e) {
console.debug(`Displaying error of ${method} ${path}: `, e)
setError(e)
} finally {
}
finally {
console.debug(`Stopping loading of ${method} ${path}...`)
setLoading(false)
}
},
[fetchData, method, path, body, init]
[fetchData, method, path, body, init],
)
/**
@ -52,8 +54,8 @@ export default function useData(fetchData, method, path, body, init) {
await load()
},
[load]
[load],
)
return {data, error, loading, fetchNow}
return { data, error, loading, fetchNow }
}

View file

@ -12,16 +12,18 @@ import { useEffect } from "react"
* @param init - Additional `init` parameters to pass to `fetch`.
*/
export default function useDataImmediately(fetchData, method, path, body, init) {
const {data, error, loading, fetchNow} = useData(fetchData, method, path, body, init)
const { data, error, loading, fetchNow } = useData(fetchData, method, path, body, init)
useEffect(
() => {
if(!(loading || data || error)) {
if(!(
loading || data || error
)) {
fetchNow()
}
},
[data, error, loading, fetchNow]
[data, error, loading, fetchNow],
)
return {data, error, loading, fetchNow}
return { data, error, loading, fetchNow }
}

View file

@ -28,7 +28,7 @@ export default function useLocalStorageState(key, def) {
}
}
const [value, setValue] = useState(load());
const [value, setValue] = useState(load())
/**
* Save a value to the {@link localStorage}.
@ -43,7 +43,7 @@ export default function useLocalStorageState(key, def) {
console.warn(`Can't save ${key}; localStorage doesn't seem to be available...`)
}
},
[key]
[key],
)
/**
@ -54,7 +54,7 @@ export default function useLocalStorageState(key, def) {
setValue(value)
save(value)
},
[save]
[save],
)
return [value, setAndSave]

View file

@ -3,8 +3,7 @@
grid-template-areas:
"a"
"b"
;
"b";
grid-gap: 10px;

View file

@ -3,8 +3,7 @@
grid-template-areas:
"a"
"b"
;
"b";
grid-template-rows: auto 1fr;
grid-gap: 10px;

View file

@ -6,17 +6,14 @@ import RepositoryEditor from "../components/providers/RepositoryEditor"
import useDataImmediately from "../hooks/useDataImmediately"
import ContextUser from "../contexts/ContextUser"
import BoxAlert from "../components/base/BoxAlert"
import RepositorySummaryBase from "../components/interactive/RepositorySummaryBase"
import { faSearch } from "@fortawesome/free-solid-svg-icons"
import Loading from "../components/base/Loading"
import BoxFull from "../components/base/BoxFull"
export default function PageEdit({ id, className, ...props }) {
const {fetchDataAuth} = useContext(ContextUser)
const {data, error} = useDataImmediately(fetchDataAuth, "GET", `/api/v1/repositories/${id}`)
const { fetchDataAuth } = useContext(ContextUser)
const { data, error } = useDataImmediately(fetchDataAuth, "GET", `/api/v1/repositories/${id}`)
let contents;
let contents
if(error) {
contents = <BoxAlert color={"Red"}>{error.toString()}</BoxAlert>
}

View file

@ -10,10 +10,10 @@ import Loading from "../components/base/Loading"
export default function PageRepositories({ children, className, ...props }) {
const {fetchDataAuth} = useContext(ContextUser)
const {data, error, fetchNow: refresh} = useDataImmediately(fetchDataAuth, "GET", "/api/v1/repositories/")
const { fetchDataAuth } = useContext(ContextUser)
const { data, error, fetchNow: refresh } = useDataImmediately(fetchDataAuth, "GET", "/api/v1/repositories/")
let contents;
let contents
if(error) {
contents = <BoxAlert color={"Red"}>{error}</BoxAlert>
}

View file

@ -3,8 +3,7 @@
grid-template-areas:
"a"
"b"
;
"b";
grid-gap: 10px;

View file

@ -4,7 +4,7 @@ import { Redirect } from "react-router"
export default function PageRoot() {
const {state} = useContext(ContextUser)
const { state } = useContext(ContextUser)
if(!state) {
return <Redirect to={"/login"}/>

View file

@ -17,13 +17,15 @@ export default function convertToLocalISODate(date) {
const naive = date.toISOString()
// Find the local timezone
const tz = - new Date().getTimezoneOffset()
const tz = -new Date().getTimezoneOffset()
// Convert the timezone to hours
const tzHours = Math.abs(Math.floor(tz / 60)).toString().padStart(2, "0")
// Find the minutes
const tzMinutes = (tz % 60).toString().padStart(2, "0")
const tzMinutes = (
tz % 60
).toString().padStart(2, "0")
// Replace the naive part with the aware part
return naive.replace("Z", `${tz < 0 ? "-" : "+"}${tzHours}${tzMinutes}`)

View file

@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
export default function make_icon(icon, className) {
if(isValidElement(icon)) {
return <span className={className}>icon</span>;
return <span className={className}>icon</span>
}
else if(icon) {
return (
@ -12,6 +12,6 @@ export default function make_icon(icon, className) {
)
}
else {
return null;
return null
}
}