@@ -19,7 +19,11 @@
 | 
			
		||||
  $: amount_input = 0;
 | 
			
		||||
  $: is_amount_valid = amount_input > 0;
 | 
			
		||||
  $: changes_performed =
 | 
			
		||||
    !(original_comparison_string === JSON.stringify(editable));
 | 
			
		||||
    !(original_comparison_string === JSON.stringify(editable)) ||
 | 
			
		||||
    (original_data.responseType == "DISTANCEDONATION" &&
 | 
			
		||||
      !(Math.floor(amount_input * 100) === original_data.amountPerDistance)) ||
 | 
			
		||||
    (original_data.responseType !== "DISTANCEDONATION" &&
 | 
			
		||||
      !(Math.floor(amount_input * 100) === original_data.amount));
 | 
			
		||||
  $: save_enabled = changes_performed && is_amount_valid;
 | 
			
		||||
  const donor_promise = DonorService.donorControllerGetAll().then((val) => {
 | 
			
		||||
    current_donors = val;
 | 
			
		||||
@@ -33,7 +37,7 @@
 | 
			
		||||
    data_loaded = true;
 | 
			
		||||
    original_data = Object.assign(original_data, data);
 | 
			
		||||
    editable = Object.assign(editable, original_data);
 | 
			
		||||
    editable.donor=data.donor.id;
 | 
			
		||||
    editable.donor = data.donor.id;
 | 
			
		||||
    if (data.responseType == "DISTANCEDONATION") {
 | 
			
		||||
      editable.runner = data.runner.id;
 | 
			
		||||
      amount_input = data.amountPerDistance / 100;
 | 
			
		||||
@@ -49,42 +53,41 @@
 | 
			
		||||
        text: "Donation is being updated",
 | 
			
		||||
        duration: 2500,
 | 
			
		||||
      }).showToast();
 | 
			
		||||
      if(original_data.responseType === "DISTANCEDONATION"){
 | 
			
		||||
      if (original_data.responseType === "DISTANCEDONATION") {
 | 
			
		||||
        editable.amountPerDistance = Math.floor(amount_input * 100);
 | 
			
		||||
        DonationService.donationControllerPutDistance(original_data.id, editable)
 | 
			
		||||
        .then((resp) => {
 | 
			
		||||
          Object.assign(original_data, editable);
 | 
			
		||||
          original_data=original_data;
 | 
			
		||||
          Toastify({
 | 
			
		||||
            text: "updated donation",
 | 
			
		||||
            duration: 2500,
 | 
			
		||||
            backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
 | 
			
		||||
          }).showToast();
 | 
			
		||||
        })
 | 
			
		||||
        .catch((err) => {});
 | 
			
		||||
      }
 | 
			
		||||
      else{
 | 
			
		||||
        DonationService.donationControllerPutDistance(
 | 
			
		||||
          original_data.id,
 | 
			
		||||
          editable
 | 
			
		||||
        )
 | 
			
		||||
          .then((resp) => {
 | 
			
		||||
            Object.assign(original_data, resp);
 | 
			
		||||
            original_data = original_data;
 | 
			
		||||
            Toastify({
 | 
			
		||||
              text: "updated donation",
 | 
			
		||||
              duration: 2500,
 | 
			
		||||
              backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
 | 
			
		||||
            }).showToast();
 | 
			
		||||
          })
 | 
			
		||||
          .catch((err) => {});
 | 
			
		||||
      } else {
 | 
			
		||||
        editable.amount = Math.floor(amount_input * 100);
 | 
			
		||||
        DonationService.donationControllerPutFixed(original_data.id, editable)
 | 
			
		||||
        .then((resp) => {
 | 
			
		||||
          Object.assign(original_data, editable);
 | 
			
		||||
          original_data=original_data;
 | 
			
		||||
          Toastify({
 | 
			
		||||
            text: "updated donation",
 | 
			
		||||
            duration: 2500,
 | 
			
		||||
            backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
 | 
			
		||||
          }).showToast();
 | 
			
		||||
        })
 | 
			
		||||
        .catch((err) => {});
 | 
			
		||||
          .then((resp) => {
 | 
			
		||||
            Object.assign(original_data, editable);
 | 
			
		||||
            original_data = original_data;
 | 
			
		||||
            Toastify({
 | 
			
		||||
              text: "updated donation",
 | 
			
		||||
              duration: 2500,
 | 
			
		||||
              backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
 | 
			
		||||
            }).showToast();
 | 
			
		||||
          })
 | 
			
		||||
          .catch((err) => {});
 | 
			
		||||
      }
 | 
			
		||||
    } else {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  function deleteDonation() {
 | 
			
		||||
    DonationService.donationControllerRemove(
 | 
			
		||||
      original_data.id,
 | 
			
		||||
      false
 | 
			
		||||
    )
 | 
			
		||||
    DonationService.donationControllerRemove(original_data.id, false)
 | 
			
		||||
      .then((resp) => {
 | 
			
		||||
        Toastify({
 | 
			
		||||
          text: "Donation delete",
 | 
			
		||||
@@ -154,9 +157,7 @@
 | 
			
		||||
        {original_data.runner.lastname}
 | 
			
		||||
      {:else}
 | 
			
		||||
        Fixed:
 | 
			
		||||
        {(amount_input)
 | 
			
		||||
          .toFixed(2)
 | 
			
		||||
          .toLocaleString('de-DE', { valute: 'EUR' })}€
 | 
			
		||||
        {amount_input.toFixed(2).toLocaleString('de-DE', { valute: 'EUR' })}€
 | 
			
		||||
      {/if}
 | 
			
		||||
      <span data-id="donation_actions_${original_data.id}">
 | 
			
		||||
        {#if store.state.jwtinfo.userdetails.permissions.includes('DONATION:DELETE')}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user