diff --git a/code/frontend/src/components/interactive/BoxRepositoriesActive.js b/code/frontend/src/components/interactive/BoxRepositoriesActive.js index 5835dcf..7884c93 100644 --- a/code/frontend/src/components/interactive/BoxRepositoriesActive.js +++ b/code/frontend/src/components/interactive/BoxRepositoriesActive.js @@ -18,18 +18,15 @@ import useDataImmediately from "../../hooks/useDataImmediately" */ export default function BoxRepositoriesActive({ ...props }) { const {user, fetchDataAuth} = useContext(ContextUser) - const {data, started, loading, error} = useDataImmediately(fetchDataAuth, "GET", "/api/v1/repositories/", { + const {data, error, loading, fetchNow} = useDataImmediately(fetchDataAuth, "GET", "/api/v1/repositories/", { "onlyActive": true, }) let contents; - if(!started || loading) { - contents = - } - else if(error) { + if(error) { contents = {error.toString()} } - else { + else if(data) { let repositories = [...data["owner"], ...data["spectator"]] if(repositories.length > 0) { contents = repositories.map(repo => ( @@ -46,6 +43,9 @@ export default function BoxRepositoriesActive({ ...props }) { contents = There's nothing here. } } + else { + contents = + } return ( diff --git a/code/frontend/src/components/interactive/BoxRepositoriesArchived.js b/code/frontend/src/components/interactive/BoxRepositoriesArchived.js index f717f8c..545a1fa 100644 --- a/code/frontend/src/components/interactive/BoxRepositoriesArchived.js +++ b/code/frontend/src/components/interactive/BoxRepositoriesArchived.js @@ -22,13 +22,10 @@ export default function BoxRepositoriesArchived({ ...props }) { }) let contents; - if(!started || loading) { - contents = - } - else if(error) { + if(error) { contents = {error.toString()} } - else { + else if(data) { let repositories = [...data["owner"], ...data["spectator"]] if(repositories.length > 0) { contents = repositories.map(repo => ( @@ -45,6 +42,9 @@ export default function BoxRepositoriesArchived({ ...props }) { contents = There's nothing here. } } + else { + contents = + } return ( diff --git a/code/frontend/src/hooks/useData.js b/code/frontend/src/hooks/useData.js index 1ca1b46..304c6fa 100644 --- a/code/frontend/src/hooks/useData.js +++ b/code/frontend/src/hooks/useData.js @@ -20,16 +20,19 @@ export default function useData(fetchData, method, path, body, init) { */ const load = useCallback( async () => { - console.debug(`Trying to ${method} ${path}...`) - + console.debug(`Loading ${method} ${path}...`) setLoading(true) + console.debug(`Fetching ${method} ${path}...`) try { const _data = await fetchData(method, path, body, init) + console.debug(`Displaying data of ${method} ${path}: `, _data) setData(_data) } catch(e) { + console.debug(`Displaying error of ${method} ${path}: `, e) setError(e) } finally { + console.debug(`Stopping loading of ${method} ${path}...`) setLoading(false) } },