70 lines
1.2 KiB
JavaScript
70 lines
1.2 KiB
JavaScript
import {BASE_URL} from '../../../common/config'
|
|
|
|
export const formatPrice = p => {
|
|
if (isNaN(p)) {
|
|
return 'Po dogovoru'
|
|
}
|
|
|
|
return p.toLocaleString('bs') + ' KM'
|
|
}
|
|
|
|
export const formatFilterNumber = num => {
|
|
if (isNaN(num) || num == null) {
|
|
return ''
|
|
}
|
|
return num
|
|
}
|
|
|
|
export const galleryImageUrl = img =>
|
|
img && img.replace('upload/', 'upload/w_500/')
|
|
|
|
export const listingImageUrl = img =>
|
|
img && img.replace('upload/', 'upload/w_205/')
|
|
|
|
export const defaultContactMessage = (url) => {
|
|
return `Pozdrav,
|
|
|
|
Našao/Našla sam vaš oglas na portalu Kivi za sljedeću nekretninu:
|
|
|
|
${url}
|
|
|
|
Želim da me kontaktirate kako bih dobio/dobila više informacija.
|
|
|
|
S poštovanjem
|
|
`
|
|
}
|
|
|
|
export const listingUrl = (id) => {
|
|
return `http://${BASE_URL}/?listingId=${id}`
|
|
}
|
|
|
|
export const isMobile = () => window.matchMedia("(max-width: 768px)").matches
|
|
|
|
export const formatRooms = (rooms) => {
|
|
const val = parseInt(rooms)
|
|
|
|
if (isNaN(val)) {
|
|
return '--'
|
|
}
|
|
|
|
if (val === 0) {
|
|
return "Garsonjera"
|
|
}
|
|
|
|
if ([2, 3, 4].includes(val)) {
|
|
return `${val} sobe`
|
|
}
|
|
|
|
return `${val} soba`
|
|
}
|
|
|
|
export const formatFloor = (floor) => {
|
|
|
|
const val = parseInt(floor)
|
|
if (isNaN(val)) {
|
|
return '--'
|
|
}
|
|
|
|
return `${val}. sprat`
|
|
}
|