generated from dave/wails-template
Enable marking as paid
This commit is contained in:
@@ -1,14 +1,17 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { type PaymentBill } from "$lib/types";
|
import { type PaymentBill } from "$lib/types";
|
||||||
import { time } from "$wails/models";
|
import { SetPaid } from "$wails/main/App";
|
||||||
|
import { toast } from "svelte-sonner";
|
||||||
|
|
||||||
export let paymentBill: PaymentBill = {
|
export let paymentBill: PaymentBill = {
|
||||||
id: -1,
|
id: -1,
|
||||||
name: "none",
|
name: "none",
|
||||||
payment: null,
|
payment: null,
|
||||||
};
|
};
|
||||||
|
export let monthFor: Date = new Date();
|
||||||
|
|
||||||
let paymentDate: string = "";
|
let paymentDate: string = "";
|
||||||
|
$: {
|
||||||
if (!!paymentBill.payment?.paymentDate) {
|
if (!!paymentBill.payment?.paymentDate) {
|
||||||
// @ts-ignore Yes split exists... The type is time.Time but it's actually a string
|
// @ts-ignore Yes split exists... The type is time.Time but it's actually a string
|
||||||
// Because typescript is a worthless waste of bytes
|
// Because typescript is a worthless waste of bytes
|
||||||
@@ -16,11 +19,27 @@
|
|||||||
// So I'm doing this bullshit
|
// So I'm doing this bullshit
|
||||||
paymentDate = paymentBill.payment!.paymentDate.split("T")[0];
|
paymentDate = paymentBill.payment!.paymentDate.split("T")[0];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function doPaid(event: MouseEvent) {
|
||||||
|
const res = await SetPaid(paymentBill.id, monthFor);
|
||||||
|
if (!res.success) {
|
||||||
|
toast.error(`failed setting paid for ${paymentBill.id} and month ${monthFor} with error ${res.error}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
paymentBill.payment = res.data;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="grid grid-cols-2 w-full text-start px-3 text-xl">
|
<div class="grid grid-cols-2 w-full text-start px-3 text-xl">
|
||||||
<p class={paymentBill.payment == null ? "text-red-700" : ""}>{paymentBill.name}</p>
|
<p class={paymentBill.payment == null ? "text-red-700" : ""}>{paymentBill.name}</p>
|
||||||
<p class="h-[1.6em] cursor-pointer border-2 border-transparent hover:border-solid hover:border-sky-500">{paymentDate}</p>
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
|
<p
|
||||||
|
class="h-[1.6em] cursor-pointer border-2 border-transparent hover:border-solid hover:border-sky-500"
|
||||||
|
on:click={doPaid}
|
||||||
|
>
|
||||||
|
{paymentDate}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@@ -42,7 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="">
|
<div class="">
|
||||||
{#each Object.values(paymentsModel) as payment}
|
{#each Object.values(paymentsModel) as payment}
|
||||||
<PaymentBillComp paymentBill={payment} />
|
<PaymentBillComp paymentBill={payment} monthFor={date} />
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user