Skip to content

Commit

Permalink
Add fallbacks for address card (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jade-GG authored Apr 30, 2024
1 parent d9edd83 commit efefc8d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions resources/js/components/AddressCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,37 @@
computed: {
company() {
return this.address.company ?? '';
return this.address?.company ?? '';
},
street() {
let street = this.address.street
let street = this.address?.street
if (!street) {
return ''
}
if (Array.isArray(street)) {
return street?.filter(Boolean).join(' ') ?? ''
return street.filter(Boolean).join(' ') ?? ''
} else {
return street.replace('\n', ' ')
}
},
name() {
return [this.address.firstname, this.address.middlename, this.address.lastname].filter(Boolean).join(' ');
return [this.address?.firstname, this.address?.middlename, this.address?.lastname].filter(Boolean).join(' ');
},
city() {
return [this.address.postcode, this.address.city].filter(Boolean).join(' ')
return [this.address?.postcode, this.address?.city].filter(Boolean).join(' ')
},
country() {
return this.address.country_id ?? this.address.country_code ?? ''
return this.address?.country_id ?? this.address?.country_code ?? ''
},
isEmpty() {
return [this.company, this.street, this.name, this.city].filter(Boolean).length == 0
}
}
}
</script>
</script>

0 comments on commit efefc8d

Please sign in to comment.