fix: allow user navigate to profile settings after coming to org settings first
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Tabs, Tab, TabContent } from 'carbon-components-svelte';
|
||||
import Profile from './Profile.svelte';
|
||||
@@ -6,25 +6,32 @@
|
||||
// import Account from './Account.svelte';
|
||||
import OrgSettings from './OrgSettings.svelte';
|
||||
import Billing from './Billing.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { browser } from '$app/environment';
|
||||
import { goto } from '$app/navigation';
|
||||
import { isOrgAdmin } from '$lib/utils/store/org';
|
||||
import Integrations from './Integrations.svelte';
|
||||
import { t } from '$lib/utils/functions/translations';
|
||||
|
||||
interface TabItem {
|
||||
key: number;
|
||||
label: string;
|
||||
tabKey: string;
|
||||
href: string;
|
||||
disabled: boolean;
|
||||
}
|
||||
|
||||
let selected = 0;
|
||||
let query = new URLSearchParams($page.url.search);
|
||||
let tabKey = query.get('tab') || '';
|
||||
|
||||
let tabs = [];
|
||||
let tabs: TabItem[] = [];
|
||||
|
||||
function getSelectedByTab(tabKey = '') {
|
||||
const tab = tabs.find((t) => t.tabKey === tabKey);
|
||||
function getSelectedByTab(_tabs: TabItem[], tabKey = '') {
|
||||
const tab = _tabs.find((t) => t.tabKey === tabKey);
|
||||
return tab ? tab.key : 0;
|
||||
}
|
||||
|
||||
function onTabChange(e) {
|
||||
function onTabChange(e: CustomEvent<number>) {
|
||||
const key = e.detail;
|
||||
const tab = tabs.find((t) => t.key === key);
|
||||
if (tab) {
|
||||
@@ -35,7 +42,7 @@
|
||||
$: if (browser) {
|
||||
query = new URLSearchParams($page.url.search);
|
||||
tabKey = query.get('tab') || '';
|
||||
selected = getSelectedByTab(tabKey);
|
||||
selected = getSelectedByTab(tabs, tabKey);
|
||||
}
|
||||
|
||||
$: {
|
||||
|
||||
Reference in New Issue
Block a user