<script lang="ts">
import { user } from "lib/UserStore";
import Euro from "util/Euro.svelte";
import { formatDataVolume } from "util/Formatting";
</script>

{#if $user !== null}
	<ul>
		<li>
			Supporter level: {$user.subscription.name}<br/>
			<i class="icon">shopping_cart</i>
			<a href="/user/subscription">Manage subscriptions</a><br/>
			<i class="icon">add_link</i>
			<a href="/api/patreon_auth/start">Link Patreon subscription</a>
		</li>

		{#if $user.balance_micro_eur !== 0}
			<li>
				Current account balance: <Euro amount={$user.balance_micro_eur}></Euro><br/>

				<i class="icon">account_balance_wallet</i>
				<a href="/user/prepaid/deposit">Deposit credit</a><br/>

				<i class="icon">receipt</i>
				<a href="/user/prepaid/transactions">Transaction log</a>

				{#if $user.balance_micro_eur > 0 && $user.subscription.id === ""}
					<br/>
					You have account credit but no active subscription. Activate
					a subscription on the <a href="/user/subscription">subscriptions page</a>
				{/if}
			</li>
		{/if}

		<li>
			Max file size: {formatDataVolume($user.subscription.file_size_limit, 3)}
		</li>
		<li>
			{#if $user.subscription.storage_limit > 0}
				Storage limit: {formatDataVolume($user.subscription.storage_limit, 3)}
			{:else}
				No storage limit
			{/if}
		</li>
		<li>
			{#if $user.subscription.monthly_transfer_cap > 0}
				Data transfer limit: {formatDataVolume($user.subscription.monthly_transfer_cap, 3)}
			{:else}
				No data transfer limit
			{/if}
		</li>
		<li>
			{#if $user.subscription.file_sharing === true}
				File sharing enabled
			{:else}
				File sharing not allowed
			{/if}
		</li>
		{#if $user.subscription.id !== ""}
			<li>
				Support: For questions related to your account you can send a
				message to support@nova.storage
			</li>
		{/if}
	</ul>
{/if}

<style>
ul {
	margin: 0;
}
</style>
