<script lang="ts">
import AccountSettings from "./AccountSettings.svelte";
import APIKeys from "./APIKeys.svelte";
import Transactions from "./Transactions.svelte";
import Subscription from "./Subscription.svelte";
import ConnectApp from "./ConnectApp.svelte";
import ActivityLog from "./ActivityLog.svelte";
import DepositCredit from "./DepositCredit.svelte";
import TabMenu, { type Tab } from "util/TabMenu.svelte";
import Dashboard from "./dashboard/Dashboard.svelte";
import AffiliatePrompt from "./AffiliatePrompt.svelte";
import { onMount } from "svelte";
import { get_user, type User } from "lib/NovaAPI";
import SharingSettings from "./SharingSettings.svelte";

let pages: Tab[] = [
	{
		path: "/user",
		title: "Dashboard",
		icon: "dashboard",
		component: Dashboard,
		hide_background: true,
	}, {
		path: "/user/settings",
		title: "Settings",
		icon: "settings",
		component: AccountSettings,
	}, {
		path: "/user/subscription",
		title: "Subscription",
		icon: "shopping_cart",
		subpages: [
			{
				path: "/user/subscription",
				title: "Manage",
				icon: "shopping_cart",
				component: Subscription,
			}, {
				path: "/user/prepaid/deposit",
				title: "Deposit Credit",
				icon: "account_balance_wallet",
				component: DepositCredit,
			}, {
				path: "/user/prepaid/transactions",
				title: "Transactions",
				icon: "receipt",
				component: Transactions,
			},
		],
	}, {
		path: "/user/sharing",
		title: "Sharing settings",
		icon: "share",
		component: SharingSettings,
	}, {
		path: "/user/connect_app",
		title: "Apps",
		icon: "app_registration",
		component: ConnectApp,
	}, {
		path: "/user/api_keys",
		title: "API Keys",
		icon: "vpn_key",
		component: APIKeys,
	}, {
		path: "/user/activity",
		title: "Activity Log",
		icon: "list",
		component: ActivityLog,
	},
]

let user = $state({} as User)
onMount(async () => {
	user = await get_user()
})
</script>

<TabMenu pages={pages} title="Welcome, {user.username}!"/>

<AffiliatePrompt always/>
