diff --git a/apps/dashboard/src/app/api/lib/getAPIKeys.ts b/apps/dashboard/src/app/api/lib/getAPIKeys.ts index ad9eaeabebd..2c6abc73b57 100644 --- a/apps/dashboard/src/app/api/lib/getAPIKeys.ts +++ b/apps/dashboard/src/app/api/lib/getAPIKeys.ts @@ -37,9 +37,9 @@ export async function getAPIKey(apiKeyId: string) { export async function getApiKeys() { const authToken = getAuthToken(); + const res = await fetch(`${API_SERVER_URL}/v1/keys`, { method: "GET", - headers: { "Content-Type": "application/json", Authorization: `Bearer ${authToken}`, @@ -53,3 +53,11 @@ export async function getApiKeys() { return json.data as ApiKey[]; } + +export function getAPIKeyForProjectId(projectId: string) { + if (projectId.startsWith("prj_")) { + return getAPIKey(projectId.slice("prj_".length)); + } + + return getAPIKey(projectId); +} diff --git a/apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/account-abstraction/page.tsx b/apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/account-abstraction/page.tsx index 319285f6a7b..1e83b8e3cd1 100644 --- a/apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/account-abstraction/page.tsx +++ b/apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/account-abstraction/page.tsx @@ -1,7 +1,7 @@ import { getProject } from "@/api/projects"; import { ChakraProviderSetup } from "@/components/ChakraProviderSetup"; import { notFound } from "next/navigation"; -import { getAPIKey } from "../../../../../api/lib/getAPIKeys"; +import { getAPIKeyForProjectId } from "../../../../../api/lib/getAPIKeys"; import { AccountAbstractionPage } from "./AccountAbstractionPage"; export default async function Page(props: { @@ -14,8 +14,7 @@ export default async function Page(props: { notFound(); } - // THIS IS A WORKAROUND - project does not have `services` info - so we fetch APIKey object. - const apiKey = await getAPIKey(project.id); + const apiKey = await getAPIKeyForProjectId(project.id); if (!apiKey) { notFound(); diff --git a/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/account-abstraction/page.tsx b/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/account-abstraction/page.tsx index 267d03df6ea..60df47f5673 100644 --- a/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/account-abstraction/page.tsx +++ b/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/account-abstraction/page.tsx @@ -2,7 +2,7 @@ import { getProject } from "@/api/projects"; import { ChakraProviderSetup } from "@/components/ChakraProviderSetup"; import { notFound } from "next/navigation"; import { AccountAbstractionSettingsPage } from "../../../../../../components/smart-wallets/SponsorshipPolicies"; -import { getAPIKey } from "../../../../../api/lib/getAPIKeys"; +import { getAPIKeyForProjectId } from "../../../../../api/lib/getAPIKeys"; export default async function Page(props: { params: { team_slug: string; project_slug: string }; @@ -14,8 +14,7 @@ export default async function Page(props: { notFound(); } - // THIS IS A WORKAROUND - project does not have `services` info - so we fetch APIKey object. - const apiKey = await getAPIKey(project.id); + const apiKey = await getAPIKeyForProjectId(project.id); if (!apiKey) { notFound(); diff --git a/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/in-app-wallets/page.tsx b/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/in-app-wallets/page.tsx index 4b9a8c3386c..7c63058a78a 100644 --- a/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/in-app-wallets/page.tsx +++ b/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/in-app-wallets/page.tsx @@ -1,7 +1,7 @@ import { getProject } from "@/api/projects"; import { notFound } from "next/navigation"; import { InAppWalletSettingsPage } from "../../../../../../components/embedded-wallets/Configure"; -import { getAPIKey } from "../../../../../api/lib/getAPIKeys"; +import { getAPIKeyForProjectId } from "../../../../../api/lib/getAPIKeys"; export default async function Page(props: { params: { team_slug: string; project_slug: string }; @@ -13,8 +13,7 @@ export default async function Page(props: { notFound(); } - // THIS IS A WORKAROUND - project does not have `services` info - so we fetch APIKey object. - const apiKey = await getAPIKey(project.id); + const apiKey = await getAPIKeyForProjectId(project.id); if (!apiKey) { notFound(); diff --git a/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/page.tsx b/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/page.tsx index dbaf61ba43a..5f57a4509d5 100644 --- a/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/page.tsx +++ b/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/page.tsx @@ -1,6 +1,6 @@ import { getProject } from "@/api/projects"; import { notFound } from "next/navigation"; -import { getAPIKey } from "../../../../api/lib/getAPIKeys"; +import { getAPIKeyForProjectId } from "../../../../api/lib/getAPIKeys"; import { ProjectGeneralSettingsPageForTeams } from "./ProjectGeneralSettingsPageForTeams"; export default async function Page(props: { @@ -13,8 +13,7 @@ export default async function Page(props: { notFound(); } - // THIS IS A WORKAROUND - project does not have `services` info - so we fetch APIKey object. - const apiKey = await getAPIKey(project.id); + const apiKey = await getAPIKeyForProjectId(project.id); if (!apiKey) { notFound(); diff --git a/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/pay/page.tsx b/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/pay/page.tsx index e723243b453..baded5f7913 100644 --- a/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/pay/page.tsx +++ b/apps/dashboard/src/app/team/[team_slug]/[project_slug]/settings/pay/page.tsx @@ -1,7 +1,7 @@ import { getProject } from "@/api/projects"; import { notFound } from "next/navigation"; import { PayConfig } from "../../../../../../components/pay/PayConfig"; -import { getAPIKey } from "../../../../../api/lib/getAPIKeys"; +import { getAPIKeyForProjectId } from "../../../../../api/lib/getAPIKeys"; export default async function Page(props: { params: { @@ -16,8 +16,7 @@ export default async function Page(props: { notFound(); } - // THIS IS A WORKAROUND - project does not have `services` info - so we fetch APIKey object. - const apiKey = await getAPIKey(project.id); + const apiKey = await getAPIKeyForProjectId(project.id); if (!apiKey) { notFound();