Files
classroomio/apps/dashboard/src/lib/components/Org/Settings/index.svelte
T

104 lines
2.7 KiB
Svelte
Raw Normal View History

<script lang="ts">
2025-11-01 15:49:29 +01:00
import { page } from '$app/state';
2023-05-02 23:55:26 +00:00
import { Tabs, Tab, TabContent } from 'carbon-components-svelte';
import Profile from './Profile.svelte';
import LandingpageSettings from './LandingpageSettings.svelte';
2023-05-02 23:55:26 +00:00
// import Account from './Account.svelte';
import OrgSettings from './OrgSettings.svelte';
2024-04-07 06:08:34 +01:00
import Billing from './Billing.svelte';
import { goto } from '$app/navigation';
2023-09-15 09:22:51 +01:00
import { isOrgAdmin } from '$lib/utils/store/org';
2023-09-26 09:01:53 +00:00
import Integrations from './Integrations.svelte';
2024-04-19 05:45:48 +01:00
import { t } from '$lib/utils/functions/translations';
interface TabItem {
key: number;
label: string;
tabKey: string;
href: string;
disabled: boolean;
}
2025-11-01 15:49:29 +01:00
let query = $derived(new URLSearchParams(page.url.search));
let tabKey = $derived(query.get('tab') || '');
2025-11-01 15:49:29 +01:00
let tabs: TabItem[] = $derived([
{
key: 0,
label: $t('settings.tabs.profile_tab'),
tabKey: '',
href: page.url.pathname,
disabled: false
},
{
key: 1,
label: $t('settings.tabs.organization_tab'),
tabKey: 'org',
href: `${page.url.pathname}?tab=org`,
disabled: !$isOrgAdmin
},
{
key: 2,
label: $t('settings.tabs.landing_page_tab'),
tabKey: 'landingpage',
href: `${page.url.pathname}?tab=landingpage`,
disabled: !$isOrgAdmin
},
{
key: 3,
label: $t('settings.tabs.billing_tab'),
tabKey: 'billing',
href: `${page.url.pathname}?tab=billing`,
disabled: !$isOrgAdmin
},
{
key: 4,
label: $t('settings.tabs.integrations_tab'),
tabKey: 'integrations',
href: `${page.url.pathname}?tab=integrations`,
disabled: false
}
]);
let selected = $derived(getSelectedByTab(tabs, tabKey));
function getSelectedByTab(_tabs: TabItem[], tabKey = '') {
const tab = _tabs.find((t) => t.tabKey === tabKey);
return tab ? tab.key : 0;
}
2024-09-30 01:36:12 +01:00
function onTabChange(e: CustomEvent<number>) {
2024-09-30 01:36:12 +01:00
const key = e.detail;
const tab = tabs.find((t) => t.key === key);
if (tab) {
2024-09-30 01:36:12 +01:00
goto(tab.href);
}
}
2023-05-02 23:55:26 +00:00
</script>
2024-09-30 01:36:12 +01:00
<Tabs autoWidth bind:selected on:change={onTabChange}>
{#each tabs as tab}
2023-09-15 09:22:51 +01:00
<Tab label={tab.label} href={tab.href} disabled={tab.disabled} />
{/each}
2023-05-02 23:55:26 +00:00
<!-- <Tab label="Account" /> -->
<svelte:fragment slot="content">
<TabContent class="w-full p-0">
2023-05-02 23:55:26 +00:00
<Profile />
</TabContent>
<!-- <TabContent>
2025-11-01 15:49:29 +01:00
<Account />
</TabContent> -->
<TabContent class="w-full p-0">
2023-05-02 23:55:26 +00:00
<OrgSettings />
</TabContent>
<TabContent class="w-full p-0">
<LandingpageSettings />
</TabContent>
2024-04-07 06:08:34 +01:00
<TabContent class="w-full p-0">
<Billing />
</TabContent>
2023-09-26 09:01:53 +00:00
<TabContent class="w-full p-0">
<Integrations />
</TabContent>
2023-05-02 23:55:26 +00:00
</svelte:fragment>
</Tabs>