Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions console/src/components/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { SidebarLink } from "@/types/sidebar"
import { useContext } from "react"
import { AdminContext, ProjectContext } from "@/contexts"
import { useResolver } from "@/hooks"
import api from "@/api"
import { oapiClient } from "@/oapi/client"
import { UserDropdown } from "./user-dropdown"
import type { Admin } from "@/types"
import { BookIcon } from "./icons"
Expand Down Expand Up @@ -50,7 +50,8 @@ export function AppSidebar({
const [allProjects] = useResolver(
React.useCallback(async () => {
try {
return (await api.projects.all()).results
const result = await oapiClient.GET("/api/admin/projects")
return result.data?.results ?? []
} catch (error) {
console.error("Failed to fetch projects:", error)
return []
Expand Down
15 changes: 12 additions & 3 deletions console/src/components/provider/select.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect, useContext } from "react"
import { ProjectContext } from "@/contexts"
import api from "@/api"
import { oapiClient } from "@/oapi/client"
import type { Provider, ProviderGroup } from "@/types"
import { useTranslation } from "react-i18next"

Expand Down Expand Up @@ -28,8 +28,17 @@
const fetchProviders = async () => {
setIsLoading(true)
try {
const result = await api.providers.all(project.id)
const filteredProviders = result.filter((provider) => provider.channel === channel)
const result = await oapiClient.GET("/api/admin/projects/{projectID}/providers", {
params: {
path: {
projectID: project.id,
},
},
})

const filteredProviders = (result.data?.results ?? []).filter(
(provider) => provider.channel === channel

Check warning on line 40 in console/src/components/provider/select.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
)
setProviders(filteredProviders)

if (filteredProviders.length > 0 && !value) {
Expand Down
64 changes: 32 additions & 32 deletions console/src/oapi/client.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
import createClient from "openapi-fetch"
import type { paths, components } from "./management.generated"
import createClient from "openapi-fetch";
import type { paths, components } from "./management.generated";

// Create the openapi-fetch client
// Note: OpenAPI paths already include /api prefix, so we use empty baseUrl
export const oapiClient = createClient<paths>({
baseUrl: "",
credentials: "include",
})
baseUrl: "",
credentials: "include",
});
Comment on lines +1 to +9
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console formatting is configured via Prettier with "semi": false and tabWidth 4 (console/.prettierrc). This file is now using semicolons and 2-space indentation, which will cause formatter/lint churn. Reformat this file to match the repo’s Prettier settings.

Copilot uses AI. Check for mistakes.

// Add response interceptor for 401 handling
oapiClient.use({
async onResponse({ response }) {
const isLoginPage = window.location.pathname.startsWith("/login")
if (response.status === 401 && !isLoginPage) {
window.location.href = `/login?r=${encodeURIComponent(window.location.href)}`
}
return response
},
})
async onResponse({ response }) {
const isLoginPage = window.location.pathname.startsWith("/login");
if (response.status === 401 && !isLoginPage) {
window.location.href = `/login?r=${encodeURIComponent(window.location.href)}`;
}
return response;
},
});

// Export schema types for convenience
export type Organization = components["schemas"]["Organization"]
export type OrganizationList = components["schemas"]["OrganizationList"]
export type UpsertOrganization = components["schemas"]["UpsertOrganization"]
export type UpdateOrganization = components["schemas"]["UpdateOrganization"]
export type OrganizationMember = components["schemas"]["OrganizationMember"]
export type OrganizationMemberList = components["schemas"]["OrganizationMemberList"]
export type AddOrganizationMember = components["schemas"]["AddOrganizationMember"]
export type User = components["schemas"]["User"]
export type UserList = components["schemas"]["UserList"]
export type Organization = components["schemas"]["Organization"];
export type OrganizationList = components["schemas"]["OrganizationList"];
export type UpsertOrganization = components["schemas"]["UpsertOrganization"];
export type UpdateOrganization = components["schemas"]["UpdateOrganization"];
export type OrganizationMember = components["schemas"]["OrganizationMember"];
export type OrganizationMemberList = components["schemas"]["OrganizationMemberList"];
export type AddOrganizationMember = components["schemas"]["AddOrganizationMember"];
export type User = components["schemas"]["User"];
export type UserList = components["schemas"]["UserList"];

export type Action = components["schemas"]["Action"]
export type CreateAction = components["schemas"]["CreateAction"]
export type UpdateAction = components["schemas"]["UpdateAction"]
export type ActionMeta = components["schemas"]["ActionMeta"]
export type ActionFunction = components["schemas"]["ActionFunction"]
export type TestActionRequest = components["schemas"]["TestActionRequest"]
export type TestActionResult = components["schemas"]["TestActionResult"]
export type TestActionFunctionRequest = components["schemas"]["TestActionFunctionRequest"]
export type TestActionFunctionResult = components["schemas"]["TestActionFunctionResult"]
export type Action = components["schemas"]["Action"];
export type CreateAction = components["schemas"]["CreateAction"];
export type UpdateAction = components["schemas"]["UpdateAction"];
export type ActionMeta = components["schemas"]["ActionMeta"];
export type ActionFunction = components["schemas"]["ActionFunction"];
export type TestActionRequest = components["schemas"]["TestActionRequest"];
export type TestActionResult = components["schemas"]["TestActionResult"];
export type TestActionFunctionRequest = components["schemas"]["TestActionFunctionRequest"];
export type TestActionFunctionResult = components["schemas"]["TestActionFunctionResult"];

export default oapiClient
export default oapiClient;
Loading
Loading