mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-02 20:08:17 +03:00
28 lines
589 B
TypeScript
28 lines
589 B
TypeScript
import Loading from "components/util/Loading";
|
|
import React, { CSSProperties } from "react";
|
|
import { UnsuccessfulAPIResponse } from "tachi-common";
|
|
|
|
export default function LoadingWrapper({
|
|
dataset,
|
|
isLoading,
|
|
error,
|
|
children,
|
|
style,
|
|
}: {
|
|
dataset: unknown | null | undefined;
|
|
isLoading: boolean;
|
|
error: UnsuccessfulAPIResponse | null;
|
|
children: JSX.Element | JSX.Element[];
|
|
style?: CSSProperties;
|
|
}) {
|
|
if (error) {
|
|
return <h3>An error has occured. {error.description}</h3>;
|
|
}
|
|
|
|
if (isLoading || !dataset) {
|
|
return <Loading style={style} />;
|
|
}
|
|
|
|
return <>{children}</>;
|
|
}
|