Skip to content

Commit 79efcf9

Browse files
committed
Added default (active) method routings.
1 parent bf25e80 commit 79efcf9

File tree

3 files changed

+86
-18
lines changed

3 files changed

+86
-18
lines changed

src/routes/(protected)/integration/method-routings/+page.svelte

Lines changed: 82 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
let methodNames = $state<string[]>([]);
1515
let connectorNames = $state<string[]>([]);
1616
let bankIds = $state<string[]>([]);
17+
let viewMode = $state<"active" | "configured">("active");
1718
let isLoading = $state(false);
1819
let isLoadingMethodNames = $state(false);
1920
let isLoadingConnectors = $state(false);
@@ -38,7 +39,8 @@
3839
isLoading = true;
3940
error = null;
4041
41-
const response = await fetch("/api/integration/method-routings");
42+
const queryParams = viewMode === "active" ? "?active=true" : "";
43+
const response = await fetch(`/api/integration/method-routings${queryParams}`);
4244
4345
if (!response.ok) {
4446
const errorData = await response.json().catch(() => ({}));
@@ -249,6 +251,15 @@
249251
successMessage = null;
250252
}
251253
254+
function switchViewMode(mode: "active" | "configured") {
255+
viewMode = mode;
256+
fetchMethodRoutings();
257+
}
258+
259+
function isDefaultRouting(routing: MethodRouting): boolean {
260+
return !routing.method_routing_id || routing.method_routing_id === "";
261+
}
262+
252263
onMount(() => {
253264
fetchMethodRoutings();
254265
fetchMethodNames();
@@ -435,8 +446,24 @@
435446

436447
<!-- Method Routings List -->
437448
<div class="panel">
438-
<div class="panel-header">
449+
<div class="panel-header panel-header-with-actions">
439450
<h2 class="panel-title">Method Routings List</h2>
451+
<div class="view-toggle">
452+
<button
453+
onclick={() => switchViewMode("active")}
454+
class="btn {viewMode === 'active' ? 'btn-primary' : 'btn-secondary'}"
455+
disabled={isLoading}
456+
>
457+
Active
458+
</button>
459+
<button
460+
onclick={() => switchViewMode("configured")}
461+
class="btn {viewMode === 'configured' ? 'btn-primary' : 'btn-secondary'}"
462+
disabled={isLoading}
463+
>
464+
Configured
465+
</button>
466+
</div>
440467
</div>
441468
<div class="panel-content">
442469
{#if isLoading && methodRoutings.length === 0}
@@ -453,12 +480,15 @@
453480
<th>Connector Name</th>
454481
<th>Bank ID Pattern</th>
455482
<th>Exact Match</th>
483+
{#if viewMode === "active"}
484+
<th>Source</th>
485+
{/if}
456486
<th>Actions</th>
457487
</tr>
458488
</thead>
459489
<tbody>
460490
{#each methodRoutings as routing}
461-
<tr>
491+
<tr class={isDefaultRouting(routing) ? "row-default" : ""}>
462492
<td class="font-mono text-sm">{routing.method_name}</td>
463493
<td>{routing.connector_name}</td>
464494
<td class="font-mono text-sm">
@@ -473,26 +503,38 @@
473503
{routing.is_bank_id_exact_match ? "Yes" : "No"}
474504
</span>
475505
</td>
506+
{#if viewMode === "active"}
507+
<td>
508+
<span class="badge {isDefaultRouting(routing) ? 'badge-default' : 'badge-custom'}">
509+
{isDefaultRouting(routing) ? "Default" : "Custom"}
510+
</span>
511+
</td>
512+
{/if}
476513
<td>
477-
<button
478-
onclick={() => startEdit(routing)}
479-
class="btn-icon"
480-
title="Edit"
481-
disabled={isLoading}
482-
>
483-
Edit
484-
</button>
514+
{#if !isDefaultRouting(routing)}
515+
<button
516+
onclick={() => startEdit(routing)}
517+
class="btn-icon"
518+
title="Edit"
519+
disabled={isLoading}
520+
>
521+
Edit
522+
</button>
523+
{/if}
485524
</td>
486525
</tr>
487526
{/each}
488527
</tbody>
489528
</table>
490529
</div>
491530
<div class="table-footer">
492-
Showing {methodRoutings.length} method routing{methodRoutings.length !==
493-
1
494-
? "s"
495-
: ""}
531+
{#if viewMode === "active"}
532+
{@const customCount = methodRoutings.filter((r) => !isDefaultRouting(r)).length}
533+
{@const defaultCount = methodRoutings.filter((r) => isDefaultRouting(r)).length}
534+
Showing {methodRoutings.length} active method routing{methodRoutings.length !== 1 ? "s" : ""} ({customCount} custom, {defaultCount} default)
535+
{:else}
536+
Showing {methodRoutings.length} method routing{methodRoutings.length !== 1 ? "s" : ""}
537+
{/if}
496538
</div>
497539
{:else}
498540
<div class="empty-state">
@@ -534,10 +576,21 @@
534576
border-bottom: 1px solid #e5e7eb;
535577
}
536578
579+
.panel-header-with-actions {
580+
display: flex;
581+
justify-content: space-between;
582+
align-items: center;
583+
}
584+
537585
:global([data-mode="dark"]) .panel-header {
538586
border-bottom-color: rgb(var(--color-surface-700));
539587
}
540588
589+
.view-toggle {
590+
display: flex;
591+
gap: 0.5rem;
592+
}
593+
541594
.panel-title {
542595
font-size: 1.125rem;
543596
font-weight: 600;
@@ -816,6 +869,20 @@
816869
color: var(--color-surface-300);
817870
}
818871
872+
.badge-custom {
873+
background: #dbeafe;
874+
color: #1e40af;
875+
}
876+
877+
:global([data-mode="dark"]) .badge-custom {
878+
background: rgb(var(--color-primary-900));
879+
color: rgb(var(--color-primary-200));
880+
}
881+
882+
.row-default {
883+
opacity: 0.75;
884+
}
885+
819886
.alert {
820887
padding: 1rem;
821888
border-radius: 0.375rem;

src/routes/+layout.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
if (href.startsWith("http")) return label;
152152
const path = href.split("?")[0];
153153
const config = SITE_MAP[path];
154-
if (!config) return `${label}\n(Not in Site Map)`;
154+
if (!config) return `${label}\nNo Roles required`;
155155
const roles = config.required.map((r) => r.role);
156156
if (roles.length === 0) return `${label}\nRequired roles: (none)`;
157157
return `${label}\nRequired roles: ${roles.join(", ")}`;

src/routes/api/integration/method-routings/+server.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createLogger } from "$lib/utils/logger";
77
const logger = createLogger("MethodRoutingsAPI");
88

99
// GET - Fetch all method routings
10-
export const GET: RequestHandler = async ({ locals }) => {
10+
export const GET: RequestHandler = async ({ locals, url }) => {
1111
const session = locals.session;
1212

1313
logger.info("=== METHOD ROUTINGS GET API CALL ===");
@@ -31,7 +31,8 @@ export const GET: RequestHandler = async ({ locals }) => {
3131
}
3232

3333
try {
34-
const endpoint = `/obp/v3.1.0/management/method_routings`;
34+
const queryString = url.searchParams.toString();
35+
const endpoint = `/obp/v3.1.0/management/method_routings${queryString ? `?${queryString}` : ""}`;
3536
logger.info(`Request: ${endpoint}`);
3637

3738
const response = await obp_requests.get(endpoint, accessToken);

0 commit comments

Comments
 (0)