Ditched component mockups. I'd like to build them myself.

This commit is contained in:
2026-10-22 21:48:16 +02:00
parent a34fd7b7fd
commit cf68405c44
23 changed files with 0 additions and 1243 deletions
@@ -1,150 +1,6 @@
<script lang="ts">
import Amount from '#lib/components/Amount.svelte';
import Button from '#lib/components/Button.svelte';
import Card from '#lib/components/Card.svelte';
import DataTable, { type Column } from '#lib/components/DataTable.svelte';
import EmptyState from '#lib/components/EmptyState.svelte';
import Notice from '#lib/components/Notice.svelte';
import PageHeader from '#lib/components/PageHeader.svelte';
import SearchInput from '#lib/components/SearchInput.svelte';
import SegmentedControl from '#lib/components/SegmentedControl.svelte';
import StatusDot from '#lib/components/StatusDot.svelte';
import {
formatDate,
formatRecurrence,
formatWeekendAdjustment,
monthlyCents,
signedCents
} from '#lib/format.ts';
import { accounts, scheduledTransactions } from '#lib/mock/data.ts';
import type { ScheduledTransaction, ScheduleStatus } from '#lib/types.ts';
const columns: Column[] = [
{ key: 'name', label: 'Name' },
{ key: 'account', label: 'Account' },
{ key: 'recurrence', label: 'Recurrence' },
{ key: 'nextDue', label: 'Next due' },
{ key: 'status', label: 'Status' },
{ key: 'amount', label: 'Amount / EUR', align: 'right' }
];
const statuses: Record<
ScheduleStatus,
{ kind: 'solid' | 'hollow' | 'dash' | 'alert'; label: string }
> = {
active: { kind: 'solid', label: 'Active' },
'due-soon': { kind: 'alert', label: 'Due soon' },
paused: { kind: 'hollow', label: 'Paused' },
ended: { kind: 'dash', label: 'Ended' }
};
let direction = $state('all');
let query = $state('');
const accountName = (id: string) => accounts.find((account) => account.id === id)?.name ?? '';
const rows = $derived(
scheduledTransactions.filter(
(item) =>
(direction === 'all' || item.direction === direction) &&
item.name.toLowerCase().includes(query.trim().toLowerCase())
)
);
const monthlyNet = $derived(
rows
.filter((item) => item.status === 'active' || item.status === 'due-soon')
.reduce((sum, item) => sum + signedCents(monthlyCents(item), item.direction), 0)
);
const upcoming = scheduledTransactions
.filter((item) => item.status === 'due-soon' && item.nextDue)
.toSorted((a, b) => a.nextDue!.localeCompare(b.nextDue!))[0];
function recurrenceNotes(item: ScheduledTransaction) {
return [
formatWeekendAdjustment(item.weekendAdjustment),
item.endsAt && `Until ${formatDate(item.endsAt)}`
].filter((note): note is string => Boolean(note));
}
</script>
<svelte:head>
<title>Scheduled transactions | Expenses</title>
</svelte:head>
<PageHeader
title="Scheduled transactions"
description="Recurring income and expenses, booked automatically."
>
{#snippet actions()}
<Button variant="primary" icon="plus">New schedule</Button>
{/snippet}
</PageHeader>
{#if upcoming}
<div class="mb-8">
<Notice variant="warning">
{upcoming.name} is due on {formatDate(upcoming.nextDue!)}.
{#snippet action()}
<span class="text-neutral-400">{formatWeekendAdjustment(upcoming.weekendAdjustment)}</span>
{/snippet}
</Notice>
</div>
{/if}
<div class="mb-6 flex flex-wrap items-center gap-4">
<SearchInput
bind:value={query}
label="Search scheduled transactions"
placeholder="Search schedules..."
class="w-full sm:w-auto sm:min-w-64 sm:flex-1"
/>
<SegmentedControl
bind:value={direction}
label="Direction"
options={[
{ value: 'all', label: 'All' },
{ value: 'in', label: 'Income' },
{ value: 'out', label: 'Expenses' }
]}
/>
</div>
<Card>
<DataTable caption="Scheduled transactions" {columns} {rows} rowId={(item) => item.id}>
{#snippet cell(item, column)}
{#if column.key === 'name'}
{item.name}
{:else if column.key === 'account'}
<span class="text-neutral-400">{accountName(item.accountId)}</span>
{:else if column.key === 'recurrence'}
{formatRecurrence(item.every, item.unit)}
{#each recurrenceNotes(item) as note (note)}
<span class="block text-sm text-neutral-500">{note}</span>
{/each}
{:else if column.key === 'nextDue'}
<span class="text-neutral-400 tabular-nums">
{item.nextDue ? formatDate(item.nextDue) : '-'}
</span>
{:else if column.key === 'status'}
<StatusDot {...statuses[item.status]} muted={item.status !== 'due-soon'} />
{:else}
<Amount cents={item.amountCents} direction={item.direction} />
{/if}
{/snippet}
{#snippet empty()}
<EmptyState
title="No scheduled transactions"
description="Try a different search or filter."
/>
{/snippet}
{#snippet footer()}
<span class="text-neutral-400">{rows.length} schedules</span>
<span>
Monthly net
<Amount cents={monthlyNet} direction={monthlyNet < 0 ? 'out' : 'in'} showCurrency />
</span>
{/snippet}
</DataTable>
</Card>