diff --git a/web/dist/static/map.jpg b/web/dist/static/map.jpg new file mode 100644 index 0000000..b051574 Binary files /dev/null and b/web/dist/static/map.jpg differ diff --git a/web/src/components/ListingDetails.js b/web/src/components/ListingDetails.js index 3a3d13d..48839bc 100644 --- a/web/src/components/ListingDetails.js +++ b/web/src/components/ListingDetails.js @@ -1,6 +1,6 @@ import React from 'react' import Gallery from './gallery' -import {formatPrice} from '../lib/helpers' +import {formatPrice, formatRooms, formatFloor} from '../lib/helpers' import ContactModal from './ContactModal'; export default class ListingDetails extends React.Component { @@ -79,7 +79,7 @@ export default class ListingDetails extends React.Component {
- {listing.rooms} sobe + {formatRooms(listing.rooms)}
@@ -87,7 +87,7 @@ export default class ListingDetails extends React.Component {
- {listing.floor}. sprat + {formatFloor(listing.floor)}
diff --git a/web/src/lib/helpers.js b/web/src/lib/helpers.js index 6325287..1ec6706 100644 --- a/web/src/lib/helpers.js +++ b/web/src/lib/helpers.js @@ -38,3 +38,31 @@ export const listingUrl = (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` +}