Update to svelte 5
This commit is contained in:
@@ -7,10 +7,10 @@ import { country_name, get_admin_invoices, type Invoice } from "lib/AdminAPI";
|
||||
import PayPalVat from "./PayPalVAT.svelte";
|
||||
import { loading_finish, loading_start } from "lib/Loading";
|
||||
|
||||
let invoices: Invoice[] = []
|
||||
let invoices: Invoice[] = $state([])
|
||||
|
||||
let year = 0
|
||||
let month = 0
|
||||
let year = $state(0)
|
||||
let month = $state(0)
|
||||
|
||||
type Total = {
|
||||
count: number
|
||||
@@ -18,8 +18,8 @@ type Total = {
|
||||
vat: number
|
||||
fee: number
|
||||
}
|
||||
let totals_provider: { [id: string]: Total } = {}
|
||||
let totals_country: { [id: string]: Total } = {}
|
||||
let totals_provider: { [id: string]: Total } = $state({})
|
||||
let totals_country: { [id: string]: Total } = $state({})
|
||||
const add_total = (i: Invoice) => {
|
||||
if (totals_provider[i.payment_method] === undefined) {
|
||||
totals_provider[i.payment_method] = {count: 0, amount: 0, vat: 0, fee: 0}
|
||||
@@ -119,14 +119,14 @@ onMount(() => {
|
||||
get_invoices()
|
||||
})
|
||||
|
||||
let status_filter = {
|
||||
let status_filter = $state({
|
||||
canceled: {checked: false},
|
||||
expired: {checked: false},
|
||||
open: {checked: false},
|
||||
paid: {checked: true},
|
||||
}
|
||||
let gateway_filter = {}
|
||||
let method_filter = {}
|
||||
})
|
||||
let gateway_filter = $state({})
|
||||
let method_filter = $state({})
|
||||
|
||||
const filter_invoices = () => {
|
||||
records_hidden = 0
|
||||
@@ -153,26 +153,28 @@ const filter_invoices = () => {
|
||||
return false
|
||||
})
|
||||
}
|
||||
let records_hidden = 0
|
||||
let invoices_filtered: Invoice[] = []
|
||||
let records_hidden = $state(0)
|
||||
let invoices_filtered: Invoice[] = $state([])
|
||||
</script>
|
||||
|
||||
<section>
|
||||
<h3>{year + "-" + ("00"+(month)).slice(-2)}</h3>
|
||||
<div class="toolbar">
|
||||
<button on:click={last_month}>
|
||||
<button onclick={last_month}>
|
||||
<i class="icon">chevron_left</i>
|
||||
Previous month
|
||||
</button>
|
||||
<div class="toolbar_spacer"></div>
|
||||
<button on:click={next_month}>
|
||||
<button onclick={next_month}>
|
||||
Next month
|
||||
<i class="icon">chevron_right</i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<Expandable click_expand>
|
||||
<div slot="header" class="header">Per payment processor</div>
|
||||
{#snippet header()}
|
||||
<div class="header">Per payment processor</div>
|
||||
{/snippet}
|
||||
<SortableTable
|
||||
index_field="id"
|
||||
rows={obj_to_list(totals_provider)}
|
||||
@@ -188,7 +190,9 @@ let invoices_filtered: Invoice[] = []
|
||||
</Expandable>
|
||||
|
||||
<Expandable click_expand>
|
||||
<div slot="header" class="header">Per country</div>
|
||||
{#snippet header()}
|
||||
<div class="header">Per country</div>
|
||||
{/snippet}
|
||||
<SortableTable
|
||||
index_field="id"
|
||||
rows={obj_to_list(totals_country)}
|
||||
@@ -204,7 +208,9 @@ let invoices_filtered: Invoice[] = []
|
||||
</Expandable>
|
||||
|
||||
<Expandable click_expand>
|
||||
<div slot="header" class="header">In European Union</div>
|
||||
{#snippet header()}
|
||||
<div class="header">In European Union</div>
|
||||
{/snippet}
|
||||
<SortableTable
|
||||
index_field="id"
|
||||
rows={obj_to_list_eu(totals_country)}
|
||||
@@ -220,7 +226,9 @@ let invoices_filtered: Invoice[] = []
|
||||
</Expandable>
|
||||
|
||||
<Expandable click_expand>
|
||||
<div slot="header" class="header">PayPal VAT</div>
|
||||
{#snippet header()}
|
||||
<div class="header">PayPal VAT</div>
|
||||
{/snippet}
|
||||
<PayPalVat invoices={invoices}/>
|
||||
</Expandable>
|
||||
|
||||
@@ -233,7 +241,7 @@ let invoices_filtered: Invoice[] = []
|
||||
type="checkbox"
|
||||
id="status_{filter}"
|
||||
bind:checked={status_filter[filter].checked}
|
||||
on:change={filter_invoices}>
|
||||
onchange={filter_invoices}>
|
||||
<label for="status_{filter}">{filter}</label>
|
||||
<br/>
|
||||
{/each}
|
||||
@@ -245,7 +253,7 @@ let invoices_filtered: Invoice[] = []
|
||||
type="checkbox"
|
||||
id="gateway_{filter}"
|
||||
bind:checked={gateway_filter[filter].checked}
|
||||
on:change={filter_invoices}>
|
||||
onchange={filter_invoices}>
|
||||
<label for="gateway_{filter}">{filter}</label>
|
||||
<br/>
|
||||
{/each}
|
||||
@@ -257,7 +265,7 @@ let invoices_filtered: Invoice[] = []
|
||||
type="checkbox"
|
||||
id="method_{filter}"
|
||||
bind:checked={method_filter[filter].checked}
|
||||
on:change={filter_invoices}>
|
||||
onchange={filter_invoices}>
|
||||
<label for="method_{filter}">{filter}</label>
|
||||
<br/>
|
||||
{/each}
|
||||
|
||||
Reference in New Issue
Block a user