You can now mark fixed donations as already paid on creation

ref #133
This commit is contained in:
Nicolai Ort 2021-04-15 14:31:24 +02:00
parent 000fc97beb
commit 3d3a10aafb
3 changed files with 36 additions and 6 deletions

View File

@ -9,6 +9,7 @@
} from "@odit/lfk-client-js"; } from "@odit/lfk-client-js";
import Select from "svelte-select"; import Select from "svelte-select";
import Toastify from "toastify-js"; import Toastify from "toastify-js";
import { is_promise } from "svelte/internal";
export let modal_open; export let modal_open;
export let current_donations; export let current_donations;
const getDonorLabel = (option) => const getDonorLabel = (option) =>
@ -24,6 +25,7 @@
$: donors = []; $: donors = [];
$: runners = []; $: runners = [];
$: is_fixed = false; $: is_fixed = false;
$: is_paid = false;
DonorService.donorControllerGetAll().then((val) => { DonorService.donorControllerGetAll().then((val) => {
donors = val.map((r) => { donors = val.map((r) => {
return { label: getDonorLabel(r), value: r }; return { label: getDonorLabel(r), value: r };
@ -64,7 +66,11 @@
let postdata = { let postdata = {
donor, donor,
amount: amount_cent, amount: amount_cent,
paidAmount: 0
}; };
if(is_paid){
postdata.paidAmount = amount_cent;
}
DonationService.donationControllerPostFixed(postdata) DonationService.donationControllerPostFixed(postdata)
.then((result) => { .then((result) => {
donor = donors[0].id || 0; donor = donors[0].id || 0;
@ -123,7 +129,7 @@
</script> </script>
<style> <style>
input:before { .toggle:before {
content: ""; content: "";
position: absolute; position: absolute;
width: 1.25rem; width: 1.25rem;
@ -137,12 +143,12 @@
transition: 0.2s ease-in-out; transition: 0.2s ease-in-out;
} }
input:checked { .toggle:checked {
/* @apply: bg-indigo-400; */ /* @apply: bg-indigo-400; */
background-color: #7f9cf5; background-color: #7f9cf5;
} }
input:checked:before { .toggle:checked:before {
left: 1.25rem; left: 1.25rem;
} }
</style> </style>
@ -195,7 +201,7 @@
class="ml-2 text-base" class="ml-2 text-base"
class:text-gray-300={is_fixed}>{$_('distance-donation')}</span> class:text-gray-300={is_fixed}>{$_('distance-donation')}</span>
<input <input
class="relative w-10 h-5 transition-all duration-200 ease-in-out bg-gray-400 rounded-full shadow-inner outline-none appearance-none align-middle" class="toggle relative w-10 h-5 transition-all duration-200 ease-in-out bg-gray-400 rounded-full shadow-inner outline-none appearance-none align-middle"
type="checkbox" type="checkbox"
bind:checked={is_fixed} /> bind:checked={is_fixed} />
<span <span
@ -267,6 +273,26 @@
</span> </span>
{/if} {/if}
</div> </div>
{#if is_fixed}
<div class="col-span-6">
<label
for="paid"
class="block text-sm font-medium text-gray-700">{$_('already-paid')}</label>
<p class="text-gray-500">
<input
id="paid"
bind:checked={is_paid}
name="paid"
type="checkbox"
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded" >
{#if is_paid}
{$_('paid')}
{:else}
{$_('open')}
{/if}
</p>
</div>
{/if}
</div> </div>
</div> </div>
</div> </div>

View File

@ -436,5 +436,7 @@
"total-paid-amount": "Gezahlter Gesamtbetrag", "total-paid-amount": "Gezahlter Gesamtbetrag",
"paid-amount": "Gezahlter Betrag", "paid-amount": "Gezahlter Betrag",
"paid": "BEZAHLT", "paid": "BEZAHLT",
"open": "OFFEN" "open": "OFFEN",
"already-paid": "Bereits bezahlt",
"unpaid": "Offen"
} }

View File

@ -436,5 +436,7 @@
"total-paid-amount": "Total paid amount", "total-paid-amount": "Total paid amount",
"paid-amount": "Paid amount", "paid-amount": "Paid amount",
"paid": "PAID", "paid": "PAID",
"open": "OPEN" "open": "OPEN",
"already-paid": "Already paid",
"unpaid": "Unpaid"
} }