Skip to content

Commit

Permalink
common redirect update (#14)
Browse files Browse the repository at this point in the history
* common redirect update

Signed-off-by: Kial Jinnah <kialj876@gmail.com>

* cleanup

Signed-off-by: Kial Jinnah <kialj876@gmail.com>

---------

Signed-off-by: Kial Jinnah <kialj876@gmail.com>
  • Loading branch information
kialj876 authored Jul 3, 2024
1 parent 0b989ca commit d659b68
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/composables/useBcrosNavigate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ export const useBcrosNavigate = () => {
const account = useBcrosAccount()

/** Redirect to the given URL with necessary BCROS args */
function redirect (url: string) {
function redirect (url: string, params?: { [key: string]: string }, target = '_self') {
// get account id and set in params
const redirectURL = new URL(url)
const accountId = account.currentAccount.id
if (accountId) {
redirectURL.searchParams.append('accountid', accountId)
redirectURL.searchParams.append('accountid', accountId.toString())
}
for (const [key, value] of Object.entries(params ?? {})) {
redirectURL.searchParams.append(key, value)
}
// assume URL is always reachable
window.location.assign(redirectURL.href)
window.open(redirectURL, target)
}

// common redirects
Expand Down

0 comments on commit d659b68

Please sign in to comment.