🐞 fixed null addresses in ContactsOverview

ref #50
This commit is contained in:
Philipp Dormann 2021-02-15 17:52:20 +01:00
parent 0f013304ef
commit 6a91bd53e2

View File

@ -2,9 +2,11 @@
import { _ } from "svelte-i18n"; import { _ } from "svelte-i18n";
import Toastify from "toastify-js"; import Toastify from "toastify-js";
import { GroupContactService } from "@odit/lfk-client-js"; import { GroupContactService } from "@odit/lfk-client-js";
const promise = GroupContactService.groupContactControllerGetAll().then(result=>{ const promise = GroupContactService.groupContactControllerGetAll().then(
(result) => {
current_contacts = result; current_contacts = result;
}) }
);
import store from "../store"; import store from "../store";
import ContactsEmptyState from "./ContactsEmptyState.svelte"; import ContactsEmptyState from "./ContactsEmptyState.svelte";
$: searchvalue = ""; $: searchvalue = "";
@ -79,7 +81,7 @@
<div class="text-sm font-medium text-gray-900"> <div class="text-sm font-medium text-gray-900">
{#if t.groups.length > 0} {#if t.groups.length > 0}
{#each t.groups as g} {#each t.groups as g}
{#if g.responseType==="RUNNERORGANIZATION"} {#if g.responseType === 'RUNNERORGANIZATION'}
<a <a
href="../orgs/{g.id}" href="../orgs/{g.id}"
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">{g.name}</a> class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">{g.name}</a>
@ -98,11 +100,13 @@
<div class="flex items-center"> <div class="flex items-center">
<div class="ml-4"> <div class="ml-4">
<div class="text-sm font-medium text-gray-900"> <div class="text-sm font-medium text-gray-900">
{t.address.address1}<br> {#if t.address.address1 !== null}
{t.address.address2 || ''}<br> {t.address.address1}<br />
{t.address.address2 || ''}<br />
{t.address.postalcode} {t.address.postalcode}
{t.address.city} {t.address.city}
{t.address.country} {t.address.country}
{/if}
</div> </div>
</div> </div>
</div> </div>
@ -119,16 +123,19 @@
Delete</button> Delete</button>
<button <button
on:click={() => { on:click={() => {
GroupContactService.groupContactControllerRemove(t.id, false) GroupContactService.groupContactControllerRemove(t.id, false).then(
.then((resp) => { (resp) => {
current_contacts = current_contacts.filter((obj) => obj.id !== t.id); current_contacts = current_contacts.filter(
(obj) => obj.id !== t.id
);
Toastify({ Toastify({
text: 'Contact deleted', text: 'Contact deleted',
duration: 500, duration: 500,
backgroundColor: backgroundColor:
'linear-gradient(to right, #00b09b, #96c93d)', 'linear-gradient(to right, #00b09b, #96c93d)',
}).showToast(); }).showToast();
}) }
);
}} }}
tabindex="0" tabindex="0"
class="ml-4 text-red-600 hover:text-red-900 cursor-pointer">Confirm class="ml-4 text-red-600 hover:text-red-900 cursor-pointer">Confirm