fix: guard non-published listings for non-owners, locale-aware number format, accept all currencies as default
This commit is contained in:
@@ -32,7 +32,7 @@ class PageCreate extends HTMLElement {
|
||||
// Use user's preferred currency from settings as default
|
||||
const defaultCurrency = getDisplayCurrency()
|
||||
// Map display currencies to listing currencies (XMR not for fiat listings)
|
||||
const currency = ['EUR', 'USD', 'CHF'].includes(defaultCurrency) ? defaultCurrency : 'EUR'
|
||||
const currency = (SUPPORTED_CURRENCIES.includes(defaultCurrency) && defaultCurrency !== 'XMR') ? defaultCurrency : 'EUR'
|
||||
|
||||
return {
|
||||
title: '',
|
||||
|
||||
@@ -199,11 +199,11 @@ class PageListing extends HTMLElement {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.listing.status === 'deleted' && !this.isOwner) {
|
||||
if (this.listing.status !== 'published' && !this.isOwner) {
|
||||
this.innerHTML = /* html */`
|
||||
<div class="empty-state">
|
||||
<div class="empty-state-icon">🗑️</div>
|
||||
<p>${t('messages.listingRemoved')}</p>
|
||||
<div class="empty-state-icon">😕</div>
|
||||
<p>${t('listing.notFound')}</p>
|
||||
<a href="#/" class="btn btn-primary">${t('listing.backHome')}</a>
|
||||
</div>
|
||||
`
|
||||
|
||||
@@ -266,12 +266,20 @@ export function formatXmr(amount) {
|
||||
export function formatFiat(amount, currency) {
|
||||
const symbol = CURRENCY_SYMBOLS[currency] || currency
|
||||
|
||||
const formatted = new Intl.NumberFormat('de-DE', {
|
||||
let locale = 'en-US'
|
||||
try {
|
||||
const stored = localStorage.getItem('locale')
|
||||
const localeMap = { de: 'de-DE', en: 'en-US', fr: 'fr-FR', it: 'it-IT', es: 'es-ES', pt: 'pt-BR', ru: 'ru-RU' }
|
||||
locale = localeMap[stored] || 'en-US'
|
||||
} catch (e) {
|
||||
// Fallback
|
||||
}
|
||||
|
||||
const formatted = new Intl.NumberFormat(locale, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2
|
||||
}).format(amount)
|
||||
|
||||
// Symbol before or after amount
|
||||
if (['EUR', 'GBP', 'USD', 'BRL'].includes(currency)) {
|
||||
return `${symbol} ${formatted}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user