2828<script setup lang="ts">
2929import { ref , inject , watchEffect , onMounted , onUnmounted , computed } from ' vue'
3030import { useRoute , useRouter } from ' vue-router'
31- import { OBP_API_DEFAULT_RESOURCE_DOC_VERSION , getCurrentUser } from ' ../obp'
31+ import { OBP_API_DEFAULT_RESOURCE_DOC_VERSION , getCurrentUser , getOBPBanks } from ' ../obp'
3232import { getOBPAPIVersions } from ' ../obp/api-version'
3333import {
3434 LOGO_URL as logoSource ,
@@ -60,8 +60,28 @@ const combinedMessageDocs = computed(() => {
6060 return [... regularDocs , ... jsonSchemaDocs ]
6161})
6262
63- // Debug menu items
64- const debugMenuItems = ref ([' /debug/providers-status' , ' /debug/oidc' ])
63+ // Help menu items (includes debug pages)
64+ const helpMenuItems = ref ([' /help' , ' /debug/providers-status' , ' /debug/oidc' ])
65+
66+ // Banks state
67+ const banks = ref <Array <{ bank_id: string ; bank_code: string ; full_name: string }>>([])
68+ const bankItems = computed (() =>
69+ [... banks .value ]
70+ .sort ((a , b ) => (a .full_name || a .bank_id || ' ' ).localeCompare (b .full_name || b .bank_id || ' ' ))
71+ .map (b => {
72+ const name = b .full_name || b .bank_id || ' '
73+ const id = b .bank_id || ' '
74+ return name !== id ? ` ${name } | ${id } ` : id
75+ })
76+ )
77+ const selectedBankId = ref (localStorage .getItem (' obp-selected-bank-id' ) || ' ' )
78+ const banksDropdownLabel = computed (() => {
79+ if (selectedBankId .value ) {
80+ const bank = banks .value .find (b => b .bank_id === selectedBankId .value )
81+ return bank ? (bank .full_name || bank .bank_id ) : ' Banks'
82+ }
83+ return ' Banks'
84+ })
6585
6686// Split versions into main and other
6787const mainVersions = [' BGv1.3' , ' BGv2' , ' OBPv5.1.0' , ' OBPv6.0.0' , ' UKv3.1' , ' dynamic-endpoints' , ' dynamic-entities' , ' OBPdynamic-endpoint' , ' OBPdynamic-entity' ]
@@ -227,6 +247,9 @@ const handleMore = (command: string, source?: string) => {
227247 // Regular message docs (connector names contain underscores)
228248 console .log (' Navigating to message docs:' , command )
229249 router .push ({ name: ' message-docs' , params: { id: command } })
250+ } else if (command === ' /help' ) {
251+ console .log (' Navigating to help page' )
252+ router .push (' /help' )
230253 } else if (command .startsWith (' /debug/' )) {
231254 console .log (' Navigating to debug page:' , command )
232255 router .push (command )
@@ -238,7 +261,28 @@ const handleMore = (command: string, source?: string) => {
238261 }
239262}
240263
264+ const handleBankSelect = (item : string ) => {
265+ // Extract bank_id from display format "full_name | bank_id" or just "bank_id"
266+ const parts = item .split (' | ' )
267+ const bankId = parts [parts .length - 1 ]
268+ const bank = banks .value .find (b => b .bank_id === bankId )
269+ if (bank ) {
270+ selectedBankId .value = bank .bank_id
271+ localStorage .setItem (' obp-selected-bank-id' , bank .bank_id )
272+ window .dispatchEvent (new CustomEvent (' obp-bank-selected' , { detail: bank .bank_id }))
273+ }
274+ }
275+
241276onMounted (async () => {
277+ // Fetch banks
278+ getOBPBanks ().then ((data ) => {
279+ if (data && data .banks && Array .isArray (data .banks )) {
280+ banks .value = data .banks
281+ }
282+ }).catch ((error ) => {
283+ console .error (' Failed to fetch banks:' , error )
284+ })
285+
242286 // Fetch available providers
243287 await fetchAvailableProviders ()
244288
@@ -292,9 +336,24 @@ const getCurrentPath = () => {
292336 <RouterLink class =" router-link" id =" header-nav-glossary" to =" /glossary" >{{
293337 $t('header.glossary')
294338 }}</RouterLink >
295- <RouterLink class =" router-link" id =" header-nav-help" to =" /help" >{{
296- $t('header.help')
297- }}</RouterLink >
339+ <SvelteDropdown
340+ class =" menu-right"
341+ id =" header-nav-help"
342+ label =" Help"
343+ :items =" helpMenuItems"
344+ :hover-color =" headerLinksHoverColor"
345+ :background-color =" headerLinksBackgroundColor"
346+ @select =" handleMore"
347+ />
348+ <SvelteDropdown
349+ class =" menu-right"
350+ id =" header-nav-banks"
351+ :label =" banksDropdownLabel"
352+ :items =" bankItems"
353+ :hover-color =" headerLinksHoverColor"
354+ :background-color =" headerLinksBackgroundColor"
355+ @select =" handleBankSelect"
356+ />
298357 <a v-if =" showObpApiManagerButton && hasObpApiManagerHost" v-bind:href =" obpApiManagerHost" class =" router-link" id =" header-nav-api-manager" >
299358 {{ $t('header.api_manager') }}
300359 </a >
@@ -316,15 +375,6 @@ const getCurrentPath = () => {
316375 :background-color =" headerLinksBackgroundColor"
317376 @select =" handleMore"
318377 />
319- <SvelteDropdown
320- class =" menu-right"
321- id =" header-nav-debug"
322- label =" Debug"
323- :items =" debugMenuItems"
324- :hover-color =" headerLinksHoverColor"
325- :background-color =" headerLinksBackgroundColor"
326- @select =" handleMore"
327- />
328378 <!-- <span class="el-dropdown-link">
329379 <RouterLink class="router-link" id="header-nav-spaces" to="/spaces">{{
330380 $t('header.spaces')
@@ -529,7 +579,8 @@ button.login-button-disabled {
529579/* Custom dropdown containers */
530580#header-nav-versions ,
531581#header-nav-message-docs ,
532- #header-nav-debug {
582+ #header-nav-help ,
583+ #header-nav-banks {
533584 display : inline-block ;
534585 vertical-align : middle ;
535586}
0 commit comments