Skip to content

Commit

Permalink
bencher_valid
Browse files Browse the repository at this point in the history
  • Loading branch information
epompeii committed Nov 25, 2024
1 parent 98d69b2 commit 5a511de
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions services/console/src/components/console/plots/PinnedPlot.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as Sentry from "@sentry/astro";
import type { Params } from "astro";
import bencher_valid_init, { type InitOutput } from "bencher_valid";
import { createMemo, createResource } from "solid-js";
import type { JsonPlot } from "../../../types/bencher";
import {
Expand All @@ -9,6 +10,7 @@ import {
} from "../../../util/auth";
import { httpGet } from "../../../util/http";
import { NotifyKind, navigateNotify } from "../../../util/notify";
import { validJwt } from "../../../util/valid";
import Pinned from "./Pinned";

export interface Props {
Expand All @@ -18,17 +20,30 @@ export interface Props {
}

const PinnedPlot = (props: Props) => {
const [bencher_valid] = createResource(
async () => await bencher_valid_init(),
);

const user = authUser();

const project_slug = createMemo(() => props.params?.project);
const plotFetcher = createMemo(() => {
return {
bencher_valid: bencher_valid(),
token: user?.token,
};
});
const getPlot = async (fetcher: {
bencher_valid: InitOutput;
token: string;
}) => {
const EMPTY_OBJECT = {};
if (!fetcher.bencher_valid) {
return EMPTY_OBJECT;
}
if (fetcher.token && !validJwt(fetcher.token)) {
return EMPTY_OBJECT;
}
const path = `/v0/projects/${props.params?.project}/plots/${props.params?.plot}`;
return await httpGet(props.apiUrl, path, fetcher.token)
.then((resp) => {
Expand Down

0 comments on commit 5a511de

Please sign in to comment.