Skip to content

Commit 6b14a5a

Browse files
committed
Products
1 parent b74cf74 commit 6b14a5a

6 files changed

Lines changed: 1491 additions & 24 deletions

File tree

src/lib/config/navigation.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
Star,
2727
Plug,
2828
Package,
29+
CircleHelp,
2930
} from "@lucide/svelte";
3031
import { env } from "$env/dynamic/public";
3132

@@ -362,12 +363,13 @@ export function getActiveDynamicEndpointsMenuItem(pathname: string) {
362363
// Products navigation items
363364
function buildProductsItems(): NavigationItem[] {
364365
const items: NavigationItem[] = [
365-
{ href: "/products", label: "Products", iconComponent: Package },
366+
{ href: "/products", label: "API Products", iconComponent: Package },
366367
{
367368
href: "/products/collections",
368369
label: "Product Collections",
369370
iconComponent: FolderOpen,
370371
},
372+
{ href: "/products/help", label: "Help", iconComponent: CircleHelp },
371373
];
372374

373375
return items;

src/routes/(protected)/products/+page.svelte

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -90,41 +90,39 @@
9090
</script>
9191

9292
<svelte:head>
93-
<title>Products - API Manager</title>
93+
<title>API Products - API Manager</title>
9494
</svelte:head>
9595

9696
<div class="container mx-auto px-4 py-8">
9797
<!-- Header -->
9898
<div class="mb-6 flex items-center justify-between">
9999
<div>
100100
<h1 class="text-3xl font-bold text-gray-900 dark:text-gray-100">
101-
Products
101+
API Products
102102
</h1>
103103
<p class="mt-1 text-gray-600 dark:text-gray-400">
104-
Manage bank financial products that TPPs can subscribe to
104+
Manage API products that TPPs can subscribe to
105105
</p>
106106
</div>
107-
{#if selectedBankId}
108-
<a
109-
href="/products/create?bank_id={selectedBankId}"
110-
class="inline-flex items-center rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600"
107+
<a
108+
href="/products/create{selectedBankId ? `?bank_id=${selectedBankId}` : ''}"
109+
class="inline-flex items-center rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600"
110+
>
111+
<svg
112+
class="mr-2 h-4 w-4"
113+
fill="none"
114+
stroke="currentColor"
115+
viewBox="0 0 24 24"
111116
>
112-
<svg
113-
class="mr-2 h-4 w-4"
114-
fill="none"
115-
stroke="currentColor"
116-
viewBox="0 0 24 24"
117-
>
118-
<path
119-
stroke-linecap="round"
120-
stroke-linejoin="round"
121-
stroke-width="2"
122-
d="M12 4v16m8-8H4"
123-
/>
124-
</svg>
125-
Create Product
126-
</a>
127-
{/if}
117+
<path
118+
stroke-linecap="round"
119+
stroke-linejoin="round"
120+
stroke-width="2"
121+
d="M12 4v16m8-8H4"
122+
/>
123+
</svg>
124+
Create an API Product
125+
</a>
128126
</div>
129127

130128
<!-- Bank Selector -->
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import type { PageServerLoad } from "./$types";
2+
import { error } from "@sveltejs/kit";
3+
import { createLogger } from "$lib/utils/logger";
4+
import { obp_requests } from "$lib/obp/requests";
5+
import { SessionOAuthHelper } from "$lib/oauth/sessionHelper";
6+
7+
const logger = createLogger("CreateProductPageServer");
8+
9+
interface ApiCollection {
10+
api_collection_id: string;
11+
user_id: string;
12+
api_collection_name: string;
13+
is_sharable: boolean;
14+
description: string;
15+
}
16+
17+
interface ApiCollectionsResponse {
18+
api_collections: ApiCollection[];
19+
}
20+
21+
export const load: PageServerLoad = async ({ locals }) => {
22+
const session = locals.session;
23+
24+
if (!session?.data?.user) {
25+
throw error(401, "Unauthorized");
26+
}
27+
28+
// Get the OAuth session data
29+
const sessionOAuth = SessionOAuthHelper.getSessionOAuth(session);
30+
const accessToken = sessionOAuth?.accessToken;
31+
32+
if (!accessToken) {
33+
logger.warn("No access token available for create product page");
34+
return {
35+
collections: [],
36+
hasApiAccess: false,
37+
error: "No API access token available",
38+
};
39+
}
40+
41+
try {
42+
logger.info("=== FETCHING API COLLECTIONS FOR PRODUCT CREATE ===");
43+
const endpoint = `/obp/v6.0.0/my/api-collections`;
44+
logger.info(`Request: ${endpoint}`);
45+
46+
const response: ApiCollectionsResponse = await obp_requests.get(
47+
endpoint,
48+
accessToken,
49+
);
50+
51+
logger.info(
52+
`Response: ${response.api_collections?.length || 0} collections`,
53+
);
54+
55+
return {
56+
collections: response.api_collections || [],
57+
hasApiAccess: true,
58+
};
59+
} catch (err) {
60+
logger.error("Error loading API collections:", err);
61+
62+
return {
63+
collections: [],
64+
hasApiAccess: false,
65+
error:
66+
err instanceof Error ? err.message : "Failed to load API collections",
67+
};
68+
}
69+
};

0 commit comments

Comments
 (0)