Skip to content

Commit

Permalink
Added route for stitcher API
Browse files Browse the repository at this point in the history
  • Loading branch information
matvp91 committed Oct 14, 2024
1 parent 0efbbf6 commit 8fb8f49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/dashboard/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const router = createBrowserRouter([
element: <JobPage />,
},
{
path: "/api",
path: "/api/:service?",
element: <ApiPage />,
},
{
Expand Down
28 changes: 10 additions & 18 deletions packages/dashboard/src/pages/ApiPage.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import { SelectObject } from "@/components/SelectObject";
import { useEffect, useState } from "react";
import { useSearchParams } from "react-router-dom";
import { useNavigate, useParams } from "react-router-dom";

export function ApiPage() {
const [searchParams, setSearchParams] = useSearchParams();
const [service, setService] = useState(
() => searchParams.get("service") ?? "api",
);

useEffect(() => {
setSearchParams({ service });
}, [service]);
const navigate = useNavigate();
const { service } = useParams() as {
service?: string;
};

const baseUrl =
{
api: window.__ENV__.PUBLIC_API_ENDPOINT,
stitcher: window.__ENV__.PUBLIC_STITCHER_ENDPOINT,
}[service] ?? "api";
const baseUrl = {
api: window.__ENV__.PUBLIC_API_ENDPOINT,
stitcher: window.__ENV__.PUBLIC_STITCHER_ENDPOINT,
}[service ?? "api"];

return (
<>
Expand All @@ -36,9 +30,7 @@ export function ApiPage() {
]}
value={service}
onChange={(value) => {
if (value) {
setService(value);
}
navigate(value === "api" ? "/api" : `/api/${value}`);
}}
/>
</div>
Expand Down

0 comments on commit 8fb8f49

Please sign in to comment.