fix: auto-set expires_at to 30 days, add expiry display on listing page, add shipping_cost field

This commit is contained in:
2026-02-04 15:15:23 +01:00
parent 71d59f274c
commit 3a7413e59a
6 changed files with 72 additions and 6 deletions

View File

@@ -193,6 +193,7 @@ class PageListing extends HTMLElement {
${this.listing.condition ? `<span class="meta-item">${this.getConditionLabel(this.listing.condition)}</span>` : ''}
${this.listing.shipping ? `<span class="meta-item">📦 ${t('listing.shippingAvailable')}</span>` : ''}
<span class="meta-item views-item"><span class="views-icon">👁</span> ${this.formatViews(this.listing.views || 0)}</span>
${this.listing.expires_at ? `<span class="meta-item expires-item">${this.formatExpiresAt(this.listing.expires_at)}</span>` : ''}
<span class="meta-item meta-date">${t('listing.postedOn')} ${createdDate}</span>
</div>
</header>
@@ -527,6 +528,24 @@ class PageListing extends HTMLElement {
return labels[condition] || condition
}
formatExpiresAt(expiresAt) {
const expires = new Date(expiresAt)
const now = new Date()
const diffMs = expires - now
if (diffMs <= 0) {
return `${t('listing.expired')}`
}
const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24))
if (diffDays === 1) {
return `${t('listing.expiresIn1Day')}`
}
return `${t('listing.expiresInDays', { days: diffDays })}`
}
formatViews(count) {
if (count === 1) {
return `1 ${t('listing.viewSingular')}`