diff --git a/.vscode/i18n-ally-custom-framework.yml b/.vscode/i18n-ally-custom-framework.yml new file mode 100644 index 00000000..3fe77a20 --- /dev/null +++ b/.vscode/i18n-ally-custom-framework.yml @@ -0,0 +1,7 @@ +languageIds: + - javascript + - svelte + - html +monopoly: false +refactorTemplates: + - "{$_('$1')}" \ No newline at end of file diff --git a/env.sample.js b/env.sample.js index 56fde078..58b49e96 100644 --- a/env.sample.js +++ b/env.sample.js @@ -1,5 +1,6 @@ const config = { baseurl: 'https://dev.lauf-fuer-kaya.de', + documentserver_key: 'NqZSYTy5AFQ7MppbLW5moqpTk7u7YrNUHKYhKYuThnnya2WpCOIU694hIZT1FzYe', fallback_username: 'admin', fallback_password: '72fpTzsev4xUu78QPs2FCbwZ3', prefersHashRouting: true diff --git a/public/env.sample.js b/public/env.sample.js index 24c54fef..7e223d49 100644 --- a/public/env.sample.js +++ b/public/env.sample.js @@ -1,5 +1,6 @@ const config = { baseurl: 'http://localhost:4010', + documentserver_key: 'NqZSYTy5AFQ7MppbLW5moqpTk7u7YrNUHKYhKYuThnnya2WpCOIU694hIZT1FzYe' // optional prefersHashRouting: true }; diff --git a/src/App.svelte b/src/App.svelte index 0ec9b765..6257257b 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -27,12 +27,13 @@ storeName: "lfk_admin", description: "LfK! admin dashbaord", }); - window.onunhandledrejection = event => { - if(event.reason.toString() == "Error: Unauthorized"){ - console.log("Found 1") - localForage.clear(); - location.replace("/"); - }}; + window.onunhandledrejection = (event) => { + if (event.reason.toString() == "Error: Unauthorized") { + console.log("Found 1"); + localForage.clear(); + location.replace("/"); + } + }; // import Login from "./components/auth/Login.svelte"; import Dashboard from "./components/dashboard/Dashboard.svelte"; @@ -61,6 +62,10 @@ import ResetPassword from "./components/auth/ResetPassword.svelte"; import Contacts from "./components/contacts/Contacts.svelte"; import ContactDetail from "./components/contacts/ContactDetail.svelte"; + import Donors from "./components/donors/Donors.svelte"; + import DonorDetail from "./components/donors/DonorDetail.svelte"; + import Donations from "./components/donations/Donations.svelte"; + import DonationDetail from "./components/donations/DonationDetail.svelte"; store.init(); registerSW(); @@ -143,6 +148,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/components/contacts/AddContactModal.svelte b/src/components/contacts/AddContactModal.svelte index c1ab7cd2..d24dec4e 100644 --- a/src/components/contacts/AddContactModal.svelte +++ b/src/components/contacts/AddContactModal.svelte @@ -228,10 +228,10 @@
+ class="block text-sm font-medium text-gray-700">{$_('last-name')} + class="block text-sm font-medium text-gray-700">{$_('teams')} + class="block text-sm font-medium text-gray-700">{$_('city')} {$_('edit')} + class="text-indigo-600 hover:text-indigo-900">{$_('details')} {#if store.state.jwtinfo.userdetails.permissions.includes('TEAM:DELETE')} +
{ + navOpen = true; + }} + class="flex items-center justify-between w-full px-4 bg-white border-b h-14 md:hidden"> + +
diff --git a/src/components/donations/AddDonationModal.svelte b/src/components/donations/AddDonationModal.svelte new file mode 100644 index 00000000..f6858e6d --- /dev/null +++ b/src/components/donations/AddDonationModal.svelte @@ -0,0 +1,288 @@ + + + + +{#if modal_open} +
{ + modal_open = false; + }}> +
+ +
+{/if} diff --git a/src/components/donations/DonationDetail.svelte b/src/components/donations/DonationDetail.svelte new file mode 100644 index 00000000..3c770589 --- /dev/null +++ b/src/components/donations/DonationDetail.svelte @@ -0,0 +1,265 @@ + + +{#await donor_promise && runner_promise && promise} + {$_('loading-donation-details')} +{:then} +
+
+
+ +
+
+
+ {original_data.donor.firstname} + {original_data.donor.middlename || ''} + {original_data.donor.lastname} + > + {#if original_data.responseType == 'DISTANCEDONATION'} + {original_data.runner.firstname} + {original_data.runner.middlename || ''} + {original_data.runner.lastname} + {:else} + {$_('fixed-donation')}: + {amount_input.toFixed(2).toLocaleString('de-DE', { valute: 'EUR' })}€ + {/if} + + {#if store.state.jwtinfo.userdetails.permissions.includes('DONATION:DELETE')} + {#if delete_triggered} + + + {/if} + {#if !delete_triggered} + + {/if} + {/if} + {#if !delete_triggered} + + {/if} + +
+ +
+ {$_('total-donation-amount')}: + {(editable.amount / 100) + .toFixed(2) + .toLocaleString('de-DE', { valute: 'EUR' })}€ +
+
+ + +
+ {#if original_data.responseType == 'DISTANCEDONATION'} +
+ + +
+ {/if} +
+ +
+ + +
+ {#if !is_amount_valid} + + {$_('donation-amount-must-be-greater-that-0-00eur')} + + {/if} +
+
+{:catch error} + +{/await} diff --git a/src/components/donations/Donations.svelte b/src/components/donations/Donations.svelte new file mode 100644 index 00000000..629e65c1 --- /dev/null +++ b/src/components/donations/Donations.svelte @@ -0,0 +1,29 @@ + + +
+ + {$_('donations')} + {#if store.state.jwtinfo.userdetails.permissions.includes('DONATION:CREATE')} + + {/if} + + +
+ +{#if store.state.jwtinfo.userdetails.permissions.includes('DONATION:CREATE')} + +{/if} diff --git a/src/components/donations/DonationsEmptyState.svelte b/src/components/donations/DonationsEmptyState.svelte new file mode 100644 index 00000000..d19419bd --- /dev/null +++ b/src/components/donations/DonationsEmptyState.svelte @@ -0,0 +1,12 @@ + + +
+

+ + There are no donations yet
+ add your fist donation +

+
diff --git a/src/components/donations/DonationsOverview.svelte b/src/components/donations/DonationsOverview.svelte new file mode 100644 index 00000000..d067c1f6 --- /dev/null +++ b/src/components/donations/DonationsOverview.svelte @@ -0,0 +1,202 @@ + + +{#if store.state.jwtinfo.userdetails.permissions.includes('DONATION:GET')} + {#await donations_promise} + + {:then} + {#if current_donations.length === 0} + + {:else} + +
+ + + + + + + + + + + + {#each current_donations as donation} + {#if donation.donor.firstname + .toLowerCase() + .includes( + searchvalue.toLowerCase() + ) || donation.donor.middlename + .toLowerCase() + .includes( + searchvalue.toLowerCase() + ) || donation.donor.lastname + .toLowerCase() + .includes( + searchvalue.toLowerCase() + ) || donation.runner?.firstname + .toLowerCase() + .includes( + searchvalue.toLowerCase() + ) || donation.runner?.middlename + .toLowerCase() + .includes( + searchvalue.toLowerCase() + ) || donation.runner?.lastname + .toLowerCase() + .includes( + searchvalue.toLowerCase() + ) || should_display_based_on_id(donation.id)} + + + + + + {#if active_deletes[donation.id] === true} + + {:else} + + {/if} + + {/if} + {/each} + +
+ {$_('donor')} + + {$_('runner')} + + {$_('amount-per-kilometer')} + + {$_('donation-amount')} + + {$_('action')} +
+ + + {#if donation.runner} + + {:else} +
+ {$_('fixed-donation')} +
+ {/if} +
+ {#if donation.amountPerDistance} +
+ {(donation.amountPerDistance / 100) + .toFixed(2) + .toLocaleString('de-DE', { valute: 'EUR' })}€ +
+ {:else} +
+ {$_('fixed-donation')} +
+ {/if} +
+
+ {(donation.amount / 100) + .toFixed(2) + .toLocaleString('de-DE', { valute: 'EUR' })}€ +
+
+ + + + {$_('details')} + {#if store.state.jwtinfo.userdetails.permissions.includes('DONATION:DELETE')} + + {/if} +
+
+ {/if} + {:catch error} +
+ + {$_('general_promise_error')} + {error} + +
+ {/await} +{/if} diff --git a/src/components/donations/donations.svg b/src/components/donations/donations.svg new file mode 100644 index 00000000..13a97190 --- /dev/null +++ b/src/components/donations/donations.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/donors/AddDonorModal.svelte b/src/components/donors/AddDonorModal.svelte new file mode 100644 index 00000000..aa85749f --- /dev/null +++ b/src/components/donors/AddDonorModal.svelte @@ -0,0 +1,404 @@ + + +{#if modal_open} +
{ + modal_open = false; + }}> +
+ +
+{/if} diff --git a/src/components/donors/ConfirmDonorDeletion.svelte b/src/components/donors/ConfirmDonorDeletion.svelte new file mode 100644 index 00000000..01100045 --- /dev/null +++ b/src/components/donors/ConfirmDonorDeletion.svelte @@ -0,0 +1,92 @@ + + +{#if modal_open} +
+
+ +
+{/if} diff --git a/src/components/donors/DonorDetail.svelte b/src/components/donors/DonorDetail.svelte new file mode 100644 index 00000000..bb88f84a --- /dev/null +++ b/src/components/donors/DonorDetail.svelte @@ -0,0 +1,406 @@ + + + +{#await promise && donation_promise} + {$_('loading-donor-details')} +{:then} +
+
+
+ +
+
+
+ {original_data.firstname} + {original_data.middlename || ''} + {original_data.lastname} + + {#if store.state.jwtinfo.userdetails.permissions.includes('DONOR:DELETE')} + {#if delete_triggered} + + + {/if} + {#if !delete_triggered} + + {/if} + {/if} + {#if !delete_triggered} + + {/if} + +
+ +
+ {$_('total-donation-amount')}: + {(editable.donationAmount / 100) + .toFixed(2) + .toLocaleString('de-DE', { valute: 'EUR' })}€ +
+ {$_('donations')}: + {#if current_donations.filter((d) => d.donor.id == editable.id).length > 0} + {#each current_donations.filter((o) => o.donor.id == editable.id) as d} + {#if d.responseType === 'DISTANCEDONATION'} + {d.runner.firstname} + {d.runner.middlename} + {d.runner.lastname} + {:else} + {$_('fixed-donation')}: + {(d.amount / 100) + .toFixed(2) + .toLocaleString('de-DE', { valute: 'EUR' })}€ + {/if} + {/each} + {:else}{$_('donor-has-no-associated-donations')}{/if} +
+
+ + + {#if !isFirstnameValid} + + {$_('first-name-is-required')} + + {/if} +
+
+ + +
+
+ + + {#if !isLastnameValid} + + {$_('last-name-is-required')} + + {/if} +
+
+ + + {#if !isEmailValid} + + {$_('valid-email-is-required')} + + {/if} +
+
+ + + {#if !isPhoneValidOrEmpty} + + {$_('valid-international-phone-number-is-required')} + + {/if} +
+
+
+ +
+
+ +
+
+ {#if editable.address_checked === true} +
+ + + {#if !isAddress1Valid} + + {$_('address-is-required')} + + {/if} +
+
+ + +
+
+ + + {#if !iszipcodevalid} + + {$_('valid-zipcode-postal-code-is-required')} + + {/if} +
+
+ + + {#if !iscityvalid} + + {$_('valid-city-is-required')} + + {/if} +
+ {/if} +
+{:catch error} + +{/await} diff --git a/src/components/donors/Donors.svelte b/src/components/donors/Donors.svelte new file mode 100644 index 00000000..b879b8d0 --- /dev/null +++ b/src/components/donors/Donors.svelte @@ -0,0 +1,29 @@ + + +
+ + {$_('donors')} + {#if store.state.jwtinfo.userdetails.permissions.includes('DONOR:CREATE')} + + {/if} + + +
+ +{#if store.state.jwtinfo.userdetails.permissions.includes('DONOR:CREATE')} + +{/if} diff --git a/src/components/donors/DonorsEmptyState.svelte b/src/components/donors/DonorsEmptyState.svelte new file mode 100644 index 00000000..4cf520a3 --- /dev/null +++ b/src/components/donors/DonorsEmptyState.svelte @@ -0,0 +1,12 @@ + + +
+

+ + {$_('there-are-no-donors-yet')}
+ {$_('add-your-first-donor')} +

+
diff --git a/src/components/donors/DonorsOverview.svelte b/src/components/donors/DonorsOverview.svelte new file mode 100644 index 00000000..86ddf16a --- /dev/null +++ b/src/components/donors/DonorsOverview.svelte @@ -0,0 +1,212 @@ + + + { + modal_open = false; + active_deletes[event.detail.id] = false; + }} + bind:modal_open + bind:delete_donor /> +{#if store.state.jwtinfo.userdetails.permissions.includes('DONOR:GET')} + {#await donors_promise && donation_promise} + + {:then} + {#if current_donors.length === 0} + + {:else} + +
+ + + + + + + + + + + + {#each current_donors as donor} + {#if donor.firstname + .toLowerCase() + .includes( + searchvalue.toLowerCase() + ) || donor.middlename + .toLowerCase() + .includes( + searchvalue.toLowerCase() + ) || donor.lastname + .toLowerCase() + .includes( + searchvalue.toLowerCase() + ) || should_display_based_on_id(donor.id)} + + + + + + {#if active_deletes[donor.id] === true} + + {:else} + + {/if} + + {/if} + {/each} + +
+ {$_('name')} + + {$_('contact-information')} + + {$_('donations')} + + {$_('total-donation-amount')} + + {$_('action')} +
+
+
+
+ {donor.firstname} + {donor.middlename || ''} + {donor.lastname} +
+
+
+
+ {#if donor.email} +
{donor.email}
+ {/if} + {#if donor.phone} +
{donor.phone}
+ {/if} + {#if donor.address.address1 !== null} + {donor.address.address1}
+ {donor.address.address2 || ''}
+ {donor.address.postalcode} + {donor.address.city} + {donor.address.country} + {/if} +
+ {#if current_donations.filter((d) => d.donor.id == donor.id).length > 0} + {#each current_donations.filter((o) => o.donor.id == donor.id) as d} + {#if d.responseType === 'DISTANCEDONATION'} + {d.runner.firstname} + {d.runner.middlename} + {d.runner.lastname} + {:else} + {$_('fixed-donation')}: + {(d.amount / 100) + .toFixed(2) + .toLocaleString('de-DE', { valute: 'EUR' })}€ + {/if} + {/each} + {:else}{$_('donor-has-no-associated-donations')}{/if} + + {(donor.donationAmount / 100) + .toFixed(2) + .toLocaleString('de-DE', { valute: 'EUR' })}€ + + + + + {$_('details')} + {#if store.state.jwtinfo.userdetails.permissions.includes('DONOR:DELETE')} + + {/if} +
+
+ {/if} + {:catch error} +
+ + {$_('general_promise_error')} + {error} + +
+ {/await} +{/if} diff --git a/src/components/donors/donors_empty.svg b/src/components/donors/donors_empty.svg new file mode 100644 index 00000000..6602b11a --- /dev/null +++ b/src/components/donors/donors_empty.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/orgs/AddOrgModal.svelte b/src/components/orgs/AddOrgModal.svelte index 5ea70162..05e3e637 100644 --- a/src/components/orgs/AddOrgModal.svelte +++ b/src/components/orgs/AddOrgModal.svelte @@ -167,17 +167,17 @@
+ class="font-medium text-gray-700">{$_('address')}
{#if address_checked === true}
+ class="block text-sm font-medium text-gray-700">{$_('address')} - Address is required + {$_('address-is-required')} {/if}
+ class="block text-sm font-medium text-gray-700">{$_('apartment-suite-etc')} + class="block text-sm font-medium text-gray-700">{$_('zip-postal-code')} - Valid zipcode/ postal code is required + {$_('valid-zipcode-postal-code-is-required')} {/if}
+ class="block text-sm font-medium text-gray-700">{$_('city')} - Valid city is required + {$_('valid-city-is-required')} {/if}
diff --git a/src/components/orgs/OrgDetail.svelte b/src/components/orgs/OrgDetail.svelte index b98fa07a..3934110b 100644 --- a/src/components/orgs/OrgDetail.svelte +++ b/src/components/orgs/OrgDetail.svelte @@ -3,7 +3,7 @@ GroupContactService, RunnerOrganizationService, } from "@odit/lfk-client-js"; - import { _ } from "svelte-i18n"; + import { getLocaleFromNavigator, _ } from "svelte-i18n"; import Toastify from "toastify-js"; import store from "../../store"; import ConfirmOrgDeletion from "./ConfirmOrgDeletion.svelte"; @@ -35,14 +35,14 @@ } } value.address_checked = value.address.address1 !== null; - if(value.address_checked===false){ + if (value.address_checked === false) { value.address = { address1: "", address2: "", city: "", postalcode: "", - country: "" - } + country: "", + }; } editable = Object.assign(editable, value); editable = editable; @@ -82,7 +82,6 @@ if (postdata.address_checked === false) { postdata.address = null; } - console.log(postdata) postdata.contact = postdata.contact === "null" ? null : postdata.contact; RunnerOrganizationService.runnerOrganizationControllerPut( original_object.id, @@ -119,6 +118,57 @@
{original_object.name} + {#if store.state.jwtinfo.userdetails.permissions.includes('RUNNER:IMPORT')}