* Improvements * More stuff * Config stuff * Request interceptor * Swagger UI CSS shenanigans * Actually disable * Uncomment button * Some more css * Checks for failed to fetch and no authorized wallet * Remove log * Make network selector switch your chain * Copy update * Copy * remove unneeded import --------- Co-authored-by: Phillip Ho <[email protected]>
33 lines
1004 B
TypeScript
33 lines
1004 B
TypeScript
import { Box, DarkMode } from "@chakra-ui/react";
|
|
import { ClientOnly } from "components/ClientOnly/ClientOnly";
|
|
import "swagger-ui-react/swagger-ui.css";
|
|
import dynamic from "next/dynamic";
|
|
import { useApiAuthToken } from "@3rdweb-sdk/react/hooks/useApi";
|
|
|
|
const SwaggerUI = dynamic(() => import("swagger-ui-react"), { ssr: false });
|
|
|
|
interface EngineExplorerProps {
|
|
instance: string;
|
|
}
|
|
|
|
export const EngineExplorer: React.FC<EngineExplorerProps> = ({ instance }) => {
|
|
const { token } = useApiAuthToken();
|
|
return (
|
|
<ClientOnly ssr={null}>
|
|
<DarkMode>
|
|
<Box bg="backgroundDark" borderRadius="xl">
|
|
<SwaggerUI
|
|
url={`${instance}${instance.endsWith("/") ? "" : "/"}json`}
|
|
docExpansion="none"
|
|
persistAuthorization={true}
|
|
requestInterceptor={(req) => {
|
|
req.headers["Authorization"] = `Bearer ${token}`;
|
|
return req;
|
|
}}
|
|
/>
|
|
</Box>
|
|
</DarkMode>
|
|
</ClientOnly>
|
|
);
|
|
};
|