Skip to content
Merged
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
10 changes: 9 additions & 1 deletion apps/dashboard/src/app/api/lib/getAPIKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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 };
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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();
Expand Down
Loading