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