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:
@@ -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`}
|
||||
|
||||
Reference in New Issue
Block a user