diff --git a/frontend/src/ts/ape/server-configuration.ts b/frontend/src/ts/ape/server-configuration.ts index 75a60cfd99cd..c63100950238 100644 --- a/frontend/src/ts/ape/server-configuration.ts +++ b/frontend/src/ts/ape/server-configuration.ts @@ -1,8 +1,7 @@ import { Configuration } from "@monkeytype/schemas/configuration"; -import Ape from "."; import { promiseWithResolvers } from "../utils/misc"; - -let config: Configuration | undefined = undefined; +import { queryClient } from "../queries"; +import { getServerConfigurationQueryOptions } from "../queries/server-configuration"; const { promise: configurationPromise, @@ -13,19 +12,16 @@ const { export { configurationPromise }; export function get(): Configuration | undefined { - return config; + return queryClient.getQueryData( + getServerConfigurationQueryOptions().queryKey, + ); } export async function sync(): Promise { - const response = await Ape.configuration.get(); - - if (response.status !== 200) { - const message = `Could not fetch configuration: ${response.body.message}`; - console.error(message); - reject(message); - return; - } else { - config = response.body.data ?? undefined; + try { + await queryClient.fetchQuery(getServerConfigurationQueryOptions()); resolve(true); + } catch (e) { + reject(e); } } diff --git a/frontend/src/ts/components/common/Button.tsx b/frontend/src/ts/components/common/Button.tsx index acd421c94a66..b786bfba842d 100644 --- a/frontend/src/ts/components/common/Button.tsx +++ b/frontend/src/ts/components/common/Button.tsx @@ -1,4 +1,4 @@ -import { JSXElement, Show } from "solid-js"; +import { JSX, JSXElement, Show } from "solid-js"; import { Conditional } from "./Conditional"; import { Fa, FaProps } from "./Fa"; @@ -7,7 +7,9 @@ type BaseProps = { text?: string; fa?: FaProps; class?: string; + classList?: JSX.HTMLAttributes["classList"]; type?: "text" | "button"; + active?: boolean; children?: JSXElement; }; @@ -15,11 +17,13 @@ type ButtonProps = BaseProps & { onClick: () => void; href?: never; sameTarget?: true; + disabled?: boolean; }; type AnchorProps = BaseProps & { href: string; onClick?: never; + disabled?: never; }; export function Button(props: ButtonProps | AnchorProps): JSXElement { @@ -36,10 +40,13 @@ export function Button(props: ButtonProps | AnchorProps): JSXElement { ); - const getClassList = (): Record => { + const getClassList = (): Record => { return { [(props.type ?? "button") === "text" ? "textButton" : buttonClass]: true, [props.class ?? ""]: props.class !== undefined, + "bg-main": props.active, + "text-bg": props.active, + ...props.classList, }; }; @@ -61,6 +68,7 @@ export function Button(props: ButtonProps | AnchorProps): JSXElement { type="button" classList={getClassList()} onClick={() => props.onClick?.()} + disabled={props.disabled ?? false} > {content} diff --git a/frontend/src/ts/components/common/Fa.tsx b/frontend/src/ts/components/common/Fa.tsx index 60604d84f930..aac4445f4134 100644 --- a/frontend/src/ts/components/common/Fa.tsx +++ b/frontend/src/ts/components/common/Fa.tsx @@ -12,13 +12,13 @@ export function Fa(props: FaProps): JSXElement { const variant = (): string => props.variant ?? "solid"; return ( + + + + {props.text} + + ); +} + +export function H2(props: { + class?: string; + text: string; + fa?: FaProps; +}): JSXElement { + return ( +

+ + + + {props.text} +

+ ); +} + +export function H3(props: { + class?: string; + text: string; + fa: FaProps; +}): JSXElement { + return ( +

+ + {props.text} +

+ ); +} diff --git a/frontend/src/ts/components/common/LoadingCircle.tsx b/frontend/src/ts/components/common/LoadingCircle.tsx new file mode 100644 index 000000000000..50469a57bcb8 --- /dev/null +++ b/frontend/src/ts/components/common/LoadingCircle.tsx @@ -0,0 +1,12 @@ +import { JSXElement } from "solid-js"; + +import { cn } from "../../utils/cn"; + +import { Fa } from "./Fa"; +export function LoadingCircle(props: { class?: string }): JSXElement { + return ( +
+ +
+ ); +} diff --git a/frontend/src/ts/components/mount.tsx b/frontend/src/ts/components/mount.tsx index a4dae541c9c4..e0976c33ed03 100644 --- a/frontend/src/ts/components/mount.tsx +++ b/frontend/src/ts/components/mount.tsx @@ -10,11 +10,11 @@ import { Theme } from "./core/Theme"; import { Footer } from "./layout/footer/Footer"; import { Overlays } from "./layout/overlays/Overlays"; import { Modals } from "./modals/Modals"; -import { AboutPage } from "./pages/AboutPage"; +import { LeaderboardPage } from "./pages/leaderboard/LeaderboardPage"; const components: Record JSXElement> = { footer: () =>