Skip to content

Commit

Permalink
feat(DH): Remove logic for address parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Angi-Kinas committed Jan 11, 2024
1 parent cb35be1 commit 8777914
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
>
</gn-ui-metadata-info>
</div>
<div class="grid col-auto gap-8">
<div>
<div *ngIf="metadataQualityDisplay">
<p class="text text-gray-700 text-xs uppercase" translate>
<p class="text text-gray-700 text-xs mb-3 uppercase" translate>
record.metadata.quality
</p>
<gn-ui-metadata-quality
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div class="py-4 px-5 rounded bg-gray-100 text-black">
<div *ngIf="shownOrganization" class="mb-6 sm:mb-12">
<div class="py-4 px-5 rounded bg-gray-100 text-black mb-6 sm:mb-12">
<div *ngIf="shownOrganization" class="mb-6">
<p class="text-sm mb-3 font-medium" translate>record.metadata.contact</p>
<div
*ngIf="contacts[0].organization?.logoUrl?.href"
class="mb-3 flex items-center justify-center border-solid border border-gray-300 rounded-md bg-white h-32"
*ngIf="shownOrganization?.logoUrl?.href"
class="mb-3 flex items-center justify-center border-solid border border-gray-300 rounded-md bg-white h-32 overflow-hidden"
>
<gn-ui-thumbnail
class="relative h-full w-full"
[thumbnailUrl]="contacts[0].organization.logoUrl.href"
[thumbnailUrl]="shownOrganization.logoUrl.href"
fit="contain"
></gn-ui-thumbnail>
</div>
Expand All @@ -20,7 +20,7 @@
{{ shownOrganization.name }}
</div>
</div>
<div *ngIf="shownOrganization.website" class="mb-6">
<div *ngIf="shownOrganization?.website" class="mb-6">
<a
[href]="shownOrganization.website"
target="_blank"
Expand All @@ -33,7 +33,7 @@
</a>
</div>
</div>
<div *ngIf="contacts[0].phone" class="mb-5">
<div *ngIf="contacts[0]?.phone" class="mb-5">
<div class="flex">
<mat-icon
class="material-symbols-outlined !w-5 !h-5 !text-[20px] opacity-75 shrink-0"
Expand All @@ -44,7 +44,7 @@
</div>
</div>
</div>
<div *ngIf="contacts[0].email" class="mb-5">
<div *ngIf="contacts[0]?.email" class="mb-5">
<div class="flex">
<mat-icon
class="material-symbols-outlined !w-5 !h-5 !text-[20px] opacity-75 shrink-0"
Expand All @@ -61,31 +61,28 @@
>
</div>
</div>
<div *ngIf="contacts[0].firstName || contacts[0].lastName" class="mb-5">
<div *ngIf="contacts[0]?.firstName || contacts[0]?.lastName" class="mb-5">
<div class="flex">
<mat-icon
class="material-symbols-outlined !w-5 !h-5 !text-[20px] opacity-75 shrink-0"
>person_outline</mat-icon
>
<div class="flex flex-col ml-2">
<p class="text-sm">
{{ contacts[0].firstName }} {{ contacts[0].lastName }}
{{ contacts[0]?.firstName || '' }} {{ contacts[0]?.lastName || '' }}
</p>
</div>
</div>
</div>
<div *ngIf="contacts[0].address" class="mb-2">
<div *ngIf="contacts[0]?.address" class="mb-2">
<div class="flex">
<mat-icon
class="material-symbols-outlined !w-5 !h-5 !text-[20px] opacity-75 shrink-0"
>
location_on</mat-icon
>
<div class="flex flex-col ml-2">
<p class="text-sm">
{{ address[0] }}
</p>
<p *ngFor="let addressPart of address.slice(1)" class="text-sm">
<p *ngFor="let addressPart of address" class="text-sm">
{{ addressPart }}
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,11 @@ export class MetadataContactComponent {
)
}

parseAddress(inputAddress) {
const addressParts = inputAddress.split(',').map((part) => part.trim())

const addressArray = []

for (let i = 0; i < addressParts.length; i++) {
const part = addressParts[i]
if (part.toLowerCase().includes('cs')) {
// Handle "CS Number" in a single line
addressArray.push(part)
} else if (part.match(/^\d{5}$/)) {
// Combine postcode and city in a single line
const postcodeCity = `${part} ${addressParts[i - 1]}`
// delete duplicate city
if (postcodeCity.includes(addressParts[i - 1])) {
addressArray.pop()
}
addressArray.push(postcodeCity)
} else {
// Treat as a separate line
addressArray.push(part)
}
}

return addressArray
}

get address() {
return this.parseAddress(this.contacts[0].address)
const addressParts = this.contacts[0].address
.split(',')
.map((part) => part.trim())
return addressParts
}

onOrganizationClick() {
Expand Down

0 comments on commit 8777914

Please sign in to comment.