The switch to class names is for accessibility. Class names are not translated by browser translation plugins and not read by screen readers.
121 lines
3.6 KiB
Svelte
121 lines
3.6 KiB
Svelte
<script lang="ts">
|
|
import { days_per_month, subscription_periods } from "lib/NovaAPI";
|
|
import { user } from "lib/UserStore";
|
|
import Euro from "util/Euro.svelte";
|
|
import { formatDataVolume, formatDate, formatEuros } from "util/Formatting";
|
|
|
|
// What the account costs per day at its current usage, the same sum the server
|
|
// charges every night. Data transfer above the plan is left out, it can't be
|
|
// predicted
|
|
let daily_cost = $derived.by(() => {
|
|
if ($user === null || $user.subscription.type !== "subscription") {
|
|
return 0
|
|
}
|
|
|
|
const sub = $user.subscription
|
|
const discount = subscription_periods.find(
|
|
p => p.months === $user.subscription_months,
|
|
)?.discount ?? 1
|
|
const extra_storage = $user.usage_based_billing ?
|
|
Math.max(0, $user.storage_space_used - sub.storage_limit) *
|
|
sub.price_per_tb_storage / 1e12 : 0
|
|
|
|
return (sub.monthly_fee * discount + extra_storage) / days_per_month
|
|
})
|
|
|
|
let credit_until = $derived.by(() => {
|
|
const date = new Date()
|
|
date.setDate(date.getDate() + Math.floor($user.balance_micro_eur / daily_cost))
|
|
return formatDate(date, false, false, false)
|
|
})
|
|
</script>
|
|
|
|
{#if $user !== null}
|
|
<ul>
|
|
<li>
|
|
Supporter level: {$user.subscription.name}<br/>
|
|
<i class="icon i_shopping_cart"></i>
|
|
<a href="/user/subscription">Manage subscriptions</a>
|
|
</li>
|
|
|
|
{#if $user.balance_micro_eur !== 0}
|
|
<li>
|
|
Current account balance: <Euro amount={$user.balance_micro_eur}></Euro><br/>
|
|
|
|
{#if daily_cost > 0}
|
|
Your plan costs {formatEuros(daily_cost, 4)} per day at your
|
|
current usage.
|
|
{#if $user.balance_micro_eur > 0}
|
|
Your credit lasts until about {credit_until}.
|
|
{/if}
|
|
{#if $user.usage_based_billing}
|
|
Data transfer above your plan is not included.
|
|
{/if}
|
|
<br/>
|
|
{/if}
|
|
|
|
<i class="icon i_account_balance_wallet"></i>
|
|
<a href="/user/subscription/manage">Deposit credit</a><br/>
|
|
|
|
<i class="icon i_receipt"></i>
|
|
<a href="/user/subscription/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}
|
|
No storage limit
|
|
{:else if $user.subscription.price_per_tb_storage > 0}
|
|
Storage included: {formatDataVolume($user.subscription.storage_limit, 3)}
|
|
({formatDataVolume($user.storage_space_used, 3)} used)
|
|
{:else}
|
|
Storage limit: {formatDataVolume($user.subscription.storage_limit, 3)}
|
|
{/if}
|
|
</li>
|
|
<li>
|
|
{#if $user.subscription.monthly_transfer_cap <= 0}
|
|
No data transfer limit
|
|
{:else if $user.subscription.price_per_tb_bandwidth > 0}
|
|
Data transfer included: {formatDataVolume($user.subscription.monthly_transfer_cap, 3)}
|
|
per month ({formatDataVolume($user.monthly_transfer_used, 3)} used)
|
|
{:else}
|
|
Data transfer limit: {formatDataVolume($user.subscription.monthly_transfer_cap, 3)}
|
|
{/if}
|
|
</li>
|
|
{#if $user.subscription_period_end}
|
|
<li>
|
|
Subscription period: {$user.subscription_months} month{$user.subscription_months === 1 ? "" : "s"},
|
|
renews on {new Date($user.subscription_period_end).toLocaleDateString()}
|
|
</li>
|
|
{/if}
|
|
<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>
|