m/cup
1
0
mirror of https://github.com/sergi0g/cup.git synced 2025-11-19 18:33:43 -05:00

refactor: better data fetching (#100)

This commit is contained in:
Raphaël Catarino
2025-05-02 18:12:19 +02:00
committed by GitHub
parent 2ac036d353
commit 5ea924c5ad
4 changed files with 76 additions and 14 deletions

View File

@@ -1,18 +1,8 @@
import { Data } from "../types";
import Logo from "./Logo";
import { theme } from "../theme";
import { LoaderCircle } from "lucide-react";
export default function Loading({ onLoad }: { onLoad: (data: Data) => void }) {
fetch(
process.env.NODE_ENV === "production"
? "./api/v3/json"
: `http://${window.location.hostname}:8000/api/v3/json`,
).then((response) =>
response.json().then((data) => {
onLoad(data as Data);
}),
);
export default function Loading() {
return (
<div
className={`flex min-h-screen justify-center bg-${theme}-50 dark:bg-${theme}-950`}