diff --git a/src/components/welcome/BackendChecker.tsx b/src/components/welcome/BackendChecker.tsx index 3dde22b..89c7253 100644 --- a/src/components/welcome/BackendChecker.tsx +++ b/src/components/welcome/BackendChecker.tsx @@ -2,8 +2,8 @@ import { FC, useState, useEffect } from "react"; import { getTestData, getBaseUrl, - TestDuckType, - cleanse + cleanse, + TestQuarticleType } from "../../services/instance"; import CleanseButton from "../debug/Cleanser"; import Spinner from "../debug/Spinner"; @@ -11,22 +11,22 @@ import { codeClass } from "./Welcome.css"; const BackendChecker: FC = () => { const [backendIsChecked, setBackendIsChecked] = useState(false); - const [persons, setPersons] = useState([]); + const [quarticles, setQuarticles] = useState([]); const url = getBaseUrl(); useEffect(() => { const initializer = async () => { - const persons = await getTestData(); + const quarticles = await getTestData(); - if (persons.length !== 0) { - setPersons(persons); + if (quarticles.length !== 0) { + setQuarticles(quarticles); setBackendIsChecked(true); return; } await cleanse(); const cleansed = await getTestData(); - setPersons(cleansed); + setQuarticles(cleansed); setBackendIsChecked(true); }; @@ -55,10 +55,11 @@ const BackendChecker: FC = () => {

Below is an iframe fetching stuff from your backend. If the iframe - contains a mysterious JSON blob of mysterious duck data, you are good to - go backend-wise. If not, reload the page and it should be ok. - If it does not want to work even after multiple reloads, it could be a - more mysterious issue and you should contact the teacher. + contains a mysterious JSON blob of mysterious quarticle data, you are + good to go backend-wise. If not, try to push the{" "} + CLEANSE button. If it does not want to work even after + multiple reloads, it could be a more mysterious issue and you should + contact the teacher.

@@ -66,21 +67,23 @@ const BackendChecker: FC = () => { stuff. Warnings and whatnot!

- {persons.length > 0 && ( - + {quarticles.length > 0 && ( + )}

- If you manage to mess up your ducks (it might happen) you can always - cleanse the flock with the pre-made CleanseButton component - from /src/components/debug/CleanseButton.tsx. Just render - the component and click the cleanse button and wait patiently and your - flock should be reset to a safe starting state. + If you manage to mess up your data (it might happen) you can always + cleanse everything with the pre-made CleanseButton{" "} + component from /src/components/debug/CleanseButton.tsx. + Just render the component and click the cleanse button and wait + patiently and your data should be reset to a safe starting state.

-

- -

+ ); }; diff --git a/src/services/instance.ts b/src/services/instance.ts index d37fab6..52b4813 100644 --- a/src/services/instance.ts +++ b/src/services/instance.ts @@ -1,4 +1,6 @@ -export type TestDuckType = { +import axios from "axios"; + +export type TestQuarticleType = { id: string; appId: string; }; @@ -16,11 +18,9 @@ export const getAppId = (): string => { export const getBaseUrl = (): string => `${process.env.NEXT_PUBLIC_API}/${getAppId()}`; -export const getTestData = async (): Promise => { - const response = await fetch(`${getBaseUrl()}/duck`); - const data = (await response.json()) as TestDuckType[]; - - return data; +export const getTestData = async (): Promise => { + const ret = await axios.get(`${getBaseUrl()}/quarticle`); + return ret.data; }; export const cleanse = async (): Promise => {