|
14 | 14 | let methodNames = $state<string[]>([]); |
15 | 15 | let connectorNames = $state<string[]>([]); |
16 | 16 | let bankIds = $state<string[]>([]); |
| 17 | + let viewMode = $state<"active" | "configured">("active"); |
17 | 18 | let isLoading = $state(false); |
18 | 19 | let isLoadingMethodNames = $state(false); |
19 | 20 | let isLoadingConnectors = $state(false); |
|
38 | 39 | isLoading = true; |
39 | 40 | error = null; |
40 | 41 |
|
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}`); |
42 | 44 |
|
43 | 45 | if (!response.ok) { |
44 | 46 | const errorData = await response.json().catch(() => ({})); |
|
249 | 251 | successMessage = null; |
250 | 252 | } |
251 | 253 |
|
| 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 | +
|
252 | 263 | onMount(() => { |
253 | 264 | fetchMethodRoutings(); |
254 | 265 | fetchMethodNames(); |
|
435 | 446 |
|
436 | 447 | <!-- Method Routings List --> |
437 | 448 | <div class="panel"> |
438 | | - <div class="panel-header"> |
| 449 | + <div class="panel-header panel-header-with-actions"> |
439 | 450 | <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> |
440 | 467 | </div> |
441 | 468 | <div class="panel-content"> |
442 | 469 | {#if isLoading && methodRoutings.length === 0} |
|
453 | 480 | <th>Connector Name</th> |
454 | 481 | <th>Bank ID Pattern</th> |
455 | 482 | <th>Exact Match</th> |
| 483 | + {#if viewMode === "active"} |
| 484 | + <th>Source</th> |
| 485 | + {/if} |
456 | 486 | <th>Actions</th> |
457 | 487 | </tr> |
458 | 488 | </thead> |
459 | 489 | <tbody> |
460 | 490 | {#each methodRoutings as routing} |
461 | | - <tr> |
| 491 | + <tr class={isDefaultRouting(routing) ? "row-default" : ""}> |
462 | 492 | <td class="font-mono text-sm">{routing.method_name}</td> |
463 | 493 | <td>{routing.connector_name}</td> |
464 | 494 | <td class="font-mono text-sm"> |
|
473 | 503 | {routing.is_bank_id_exact_match ? "Yes" : "No"} |
474 | 504 | </span> |
475 | 505 | </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} |
476 | 513 | <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} |
485 | 524 | </td> |
486 | 525 | </tr> |
487 | 526 | {/each} |
488 | 527 | </tbody> |
489 | 528 | </table> |
490 | 529 | </div> |
491 | 530 | <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} |
496 | 538 | </div> |
497 | 539 | {:else} |
498 | 540 | <div class="empty-state"> |
|
534 | 576 | border-bottom: 1px solid #e5e7eb; |
535 | 577 | } |
536 | 578 |
|
| 579 | + .panel-header-with-actions { |
| 580 | + display: flex; |
| 581 | + justify-content: space-between; |
| 582 | + align-items: center; |
| 583 | + } |
| 584 | +
|
537 | 585 | :global([data-mode="dark"]) .panel-header { |
538 | 586 | border-bottom-color: rgb(var(--color-surface-700)); |
539 | 587 | } |
540 | 588 |
|
| 589 | + .view-toggle { |
| 590 | + display: flex; |
| 591 | + gap: 0.5rem; |
| 592 | + } |
| 593 | +
|
541 | 594 | .panel-title { |
542 | 595 | font-size: 1.125rem; |
543 | 596 | font-weight: 600; |
|
816 | 869 | color: var(--color-surface-300); |
817 | 870 | } |
818 | 871 |
|
| 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 | +
|
819 | 886 | .alert { |
820 | 887 | padding: 1rem; |
821 | 888 | border-radius: 0.375rem; |
|
0 commit comments