refactor: use status field instead of expires_at for expired badge on listing cards
This commit is contained in:
@@ -7,7 +7,7 @@ let cachedRates = null
|
|||||||
|
|
||||||
class ListingCard extends HTMLElement {
|
class ListingCard extends HTMLElement {
|
||||||
static get observedAttributes() {
|
static get observedAttributes() {
|
||||||
return ['listing-id', 'title', 'price', 'currency', 'location', 'image', 'owner-id', 'payment-status', 'expires-at']
|
return ['listing-id', 'title', 'price', 'currency', 'location', 'image', 'owner-id', 'payment-status', 'status']
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -130,11 +130,10 @@ class ListingCard extends HTMLElement {
|
|||||||
` : ''
|
` : ''
|
||||||
|
|
||||||
const paymentStatus = this.getAttribute('payment-status')
|
const paymentStatus = this.getAttribute('payment-status')
|
||||||
const expiresAt = this.getAttribute('expires-at')
|
const status = this.getAttribute('status')
|
||||||
const isExpired = expiresAt && new Date(expiresAt) < new Date()
|
|
||||||
|
|
||||||
let paymentBadge = ''
|
let paymentBadge = ''
|
||||||
if (isExpired) {
|
if (status === 'archived') {
|
||||||
paymentBadge = /* html */`<span class="payment-badge payment-expired">${t('myListings.status.expired')}</span>`
|
paymentBadge = /* html */`<span class="payment-badge payment-expired">${t('myListings.status.expired')}</span>`
|
||||||
} else if (paymentStatus === 'processing' || paymentStatus === 'pending') {
|
} else if (paymentStatus === 'processing' || paymentStatus === 'pending') {
|
||||||
paymentBadge = /* html */`<span class="payment-badge payment-processing"><span class="pulse-dot"></span>${t('myListings.status.processing')}</span>`
|
paymentBadge = /* html */`<span class="payment-badge payment-processing"><span class="pulse-dot"></span>${t('myListings.status.processing')}</span>`
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ class PageMyListings extends HTMLElement {
|
|||||||
image="${imageUrl}"
|
image="${imageUrl}"
|
||||||
owner-id="${listing.user_created || ''}"
|
owner-id="${listing.user_created || ''}"
|
||||||
payment-status="${listing.payment_status || ''}"
|
payment-status="${listing.payment_status || ''}"
|
||||||
expires-at="${listing.expires_at || ''}"
|
status="${listing.status || ''}"
|
||||||
></listing-card>
|
></listing-card>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|||||||
Reference in New Issue
Block a user