Add debug component

This commit is contained in:
Arnaud 2024-08-30 11:57:06 +02:00
parent cdaf500c97
commit e7fb81bc70
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
4 changed files with 23 additions and 18 deletions

View File

@ -1,34 +1,30 @@
import { useQuery } from "@tanstack/react-query";
import Loader from "../../assets/loader.svg";
import { CodexSdk } from "../../sdk/codex";
import { Card } from "@codex/marketplace-ui-components";
import { Card, Spinner } from "@codex/marketplace-ui-components";
import { Promises } from "../../utils/promises";
export function Debug() {
const { data, isPending } = useQuery({
queryFn: () => CodexSdk.debug().then((debug) => debug.info()),
queryFn: () =>
CodexSdk.debug()
.then((debug) => debug.info())
.then((s) => Promises.rejectOnError(s)),
queryKey: ["debug"],
});
if (isPending) {
return (
<Card title="Debug">
<img src={Loader} width={24} height={24} alt="Loader" />
</Card>
);
}
if (data?.error) {
// TODO display error
return (
<Card title="Debug">
<p>{data?.data.message || ""}</p>
</Card>
<div className="settings-debug-loader">
<Spinner width="3rem" />
</div>
);
}
return (
<Card title="Debug">
<>
<h3>Debug</h3>
<pre>{JSON.stringify(data, null, 2)}</pre>
</Card>
</>
);
}

View File

@ -46,8 +46,6 @@ export class ErrorBoundary extends React.Component<Props, State> {
);
}
console.info("couc");
return this.props.children;
}
}

View File

@ -16,3 +16,7 @@
.settings-input {
margin-bottom: 0.75rem;
}
.settings-debug-loader {
margin: auto;
}

View File

@ -3,6 +3,7 @@ import { ErrorBoundary } from "../../components/ErrorBoundary/ErrorBoundary";
import "./settings.css";
import { LogLevel } from "../../components/LogLevel/LogLevel";
import { CodexUrlSettings } from "../../CodexUrllSettings/CodexUrlSettings";
import { Debug } from "../../components/Debug/Debug";
export const Route = createFileRoute("/dashboard/settings")({
component: () => (
@ -19,6 +20,12 @@ export const Route = createFileRoute("/dashboard/settings")({
</ErrorBoundary>
</div>
<div className="settings">
<ErrorBoundary card={true}>
<Debug />
</ErrorBoundary>
</div>
{/* <div className="input-floating">
<input
className="input input-floating-input"