fix(DonorDetail): donor deletion
All checks were successful
Build Latest and dev images / build-container (push) Successful in 1m20s

This commit is contained in:
Philipp Dormann 2025-03-26 15:57:44 +01:00
parent bb2319a78d
commit 5147a20b3c
Signed by: philipp
GPG Key ID: 3BB9ADD52DCA4314

View File

@ -1,12 +1,10 @@
<script> <script>
import { DonorService } from "@odit/lfk-client-js";
import { _ } from "svelte-i18n"; import { _ } from "svelte-i18n";
import store from "../../store"; import store from "../../store";
import { DonorService, DonationService } from "@odit/lfk-client-js";
import PromiseError from "../base/PromiseError.svelte";
import isEmail from "validator/es/lib/isEmail";
import ConfirmDonorDeletion from "./ConfirmDonorDeletion.svelte";
import toast from "svelte-french-toast"; import toast from "svelte-french-toast";
import isEmail from "validator/es/lib/isEmail";
import PromiseError from "../base/PromiseError.svelte";
let data_loaded = false; let data_loaded = false;
export let params; export let params;
$: delete_triggered = false; $: delete_triggered = false;
@ -53,8 +51,6 @@
$: isAddress1Valid = editable.address?.address1?.trim().length !== 0; $: isAddress1Valid = editable.address?.address1?.trim().length !== 0;
$: iszipcodevalid = editable.address?.postalcode?.trim().length !== 0; $: iszipcodevalid = editable.address?.postalcode?.trim().length !== 0;
$: iscityvalid = editable.address?.city?.trim().length !== 0; $: iscityvalid = editable.address?.city?.trim().length !== 0;
let modal_open = false;
let delete_donor = {};
function submit() { function submit() {
if (data_loaded === true && save_enabled) { if (data_loaded === true && save_enabled) {
toast($_("donor-is-being-updated")); toast($_("donor-is-being-updated"));
@ -79,19 +75,17 @@
} }
} }
function deleteDonor() { function deleteDonor() {
DonorService.donorControllerRemove(original_data.id, false) DonorService.donorControllerRemove(original_data.id, true)
.then((resp) => { .then((resp) => {
toast($_("donor-deleted")); toast($_("donor-deleted"));
location.replace("./"); location.replace("./");
}) })
.catch((err) => { .catch((err) => {
modal_open = true; console.log(err);
delete_donor = original_data;
}); });
} }
</script> </script>
<ConfirmDonorDeletion bind:modal_open bind:delete_donor />
{#await promise} {#await promise}
{$_("loading-donor-details")} {$_("loading-donor-details")}
{:then} {:then}
@ -101,7 +95,22 @@
<nav class="w-full flex"> <nav class="w-full flex">
<ol class="list-none flex flex-row items-center justify-start"> <ol class="list-none flex flex-row items-center justify-start">
<li class="flex items-center"> <li class="flex items-center">
<a class="mr-2" href="./"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block"><path d="m12 19-7-7 7-7"/><path d="M19 12H5"/></svg> {$_("donors")}</a> <a class="mr-2" href="./"
><svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="inline-block"
><path d="m12 19-7-7 7-7" /><path d="M19 12H5" /></svg
>
{$_("donors")}</a
>
</li> </li>
</ol> </ol>
</nav> </nav>
@ -161,7 +170,8 @@
.toLocaleString("de-DE", { valute: "EUR" })}€</span .toLocaleString("de-DE", { valute: "EUR" })}€</span
> >
| |
<span class="font-semibold text-gray-700">{$_("total-paid-amount")}:</span> <span class="font-semibold text-gray-700">{$_("total-paid-amount")}:</span
>
<span <span
>{(editable.paidDonationAmount / 100) >{(editable.paidDonationAmount / 100)
.toFixed(2) .toFixed(2)
@ -275,7 +285,9 @@
{/if} {/if}
</div> </div>
<div class="mt-2 w-full"> <div class="mt-2 w-full">
<label for="phone" class="font-semibold text-gray-700">{$_("phone")}</label> <label for="phone" class="font-semibold text-gray-700"
>{$_("phone")}</label
>
<input <input
autocomplete="off" autocomplete="off"
placeholder={$_("phone")} placeholder={$_("phone")}