diff --git a/backend/build/server.js b/backend/build/server.js index e0a6746..6196198 100644 --- a/backend/build/server.js +++ b/backend/build/server.js @@ -60,20 +60,28 @@ var _distance_in_words_to_now2 = _interopRequireDefault(_distance_in_words_to_now); + var _format = __webpack_require__(17); + + var _format2 = _interopRequireDefault(_format); + + var _moment = __webpack_require__(28); + + var _moment2 = _interopRequireDefault(_moment); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } - var hr = __webpack_require__(17); + var hr = __webpack_require__(29); - var MongoClient = __webpack_require__(20).MongoClient; - var ObjectID = __webpack_require__(20).ObjectID; + var MongoClient = __webpack_require__(32).MongoClient; + var ObjectID = __webpack_require__(32).ObjectID; var url = 'mongodb://localhost:27017/kivi'; - __webpack_require__(21); + __webpack_require__(33); var router = _express2.default.Router({ mergeParams: true }); @@ -377,6 +385,7 @@ }; })); } else { + res.json(all.map(function (_ref4) { var _id = _ref4._id, address = _ref4.address, @@ -392,7 +401,8 @@ price: price, rooms: rooms, size: size, - time: (0, _distance_in_words_to_now2.default)(new Date(time), { locale: hr }) + time: (0, _distance_in_words_to_now2.default)((0, _moment2.default)(time, 'DD.MM.YYYY'), { locale: hr }), + realTime: time }; })); } @@ -1626,8 +1636,737 @@ /* 17 */ /***/ function(module, exports, __webpack_require__) { - var buildDistanceInWordsLocale = __webpack_require__(18) - var buildFormatLocale = __webpack_require__(19) + var getDayOfYear = __webpack_require__(18) + var getISOWeek = __webpack_require__(22) + var getISOYear = __webpack_require__(26) + var parse = __webpack_require__(6) + var isValid = __webpack_require__(27) + var enLocale = __webpack_require__(13) + + /** + * @category Common Helpers + * @summary Format the date. + * + * @description + * Return the formatted date string in the given format. + * + * Accepted tokens: + * | Unit | Token | Result examples | + * |-------------------------|-------|----------------------------------| + * | Month | M | 1, 2, ..., 12 | + * | | Mo | 1st, 2nd, ..., 12th | + * | | MM | 01, 02, ..., 12 | + * | | MMM | Jan, Feb, ..., Dec | + * | | MMMM | January, February, ..., December | + * | Quarter | Q | 1, 2, 3, 4 | + * | | Qo | 1st, 2nd, 3rd, 4th | + * | Day of month | D | 1, 2, ..., 31 | + * | | Do | 1st, 2nd, ..., 31st | + * | | DD | 01, 02, ..., 31 | + * | Day of year | DDD | 1, 2, ..., 366 | + * | | DDDo | 1st, 2nd, ..., 366th | + * | | DDDD | 001, 002, ..., 366 | + * | Day of week | d | 0, 1, ..., 6 | + * | | do | 0th, 1st, ..., 6th | + * | | dd | Su, Mo, ..., Sa | + * | | ddd | Sun, Mon, ..., Sat | + * | | dddd | Sunday, Monday, ..., Saturday | + * | Day of ISO week | E | 1, 2, ..., 7 | + * | ISO week | W | 1, 2, ..., 53 | + * | | Wo | 1st, 2nd, ..., 53rd | + * | | WW | 01, 02, ..., 53 | + * | Year | YY | 00, 01, ..., 99 | + * | | YYYY | 1900, 1901, ..., 2099 | + * | ISO week-numbering year | GG | 00, 01, ..., 99 | + * | | GGGG | 1900, 1901, ..., 2099 | + * | AM/PM | A | AM, PM | + * | | a | am, pm | + * | | aa | a.m., p.m. | + * | Hour | H | 0, 1, ... 23 | + * | | HH | 00, 01, ... 23 | + * | | h | 1, 2, ..., 12 | + * | | hh | 01, 02, ..., 12 | + * | Minute | m | 0, 1, ..., 59 | + * | | mm | 00, 01, ..., 59 | + * | Second | s | 0, 1, ..., 59 | + * | | ss | 00, 01, ..., 59 | + * | 1/10 of second | S | 0, 1, ..., 9 | + * | 1/100 of second | SS | 00, 01, ..., 99 | + * | Millisecond | SSS | 000, 001, ..., 999 | + * | Timezone | Z | -01:00, +00:00, ... +12:00 | + * | | ZZ | -0100, +0000, ..., +1200 | + * | Seconds timestamp | X | 512969520 | + * | Milliseconds timestamp | x | 512969520900 | + * + * The characters wrapped in square brackets are escaped. + * + * The result may vary by locale. + * + * @param {Date|String|Number} date - the original date + * @param {String} [format='YYYY-MM-DDTHH:mm:ss.SSSZ'] - the string of tokens + * @param {Object} [options] - the object with options + * @param {Object} [options.locale=enLocale] - the locale object + * @returns {String} the formatted date string + * + * @example + * // Represent 11 February 2014 in middle-endian format: + * var result = format( + * new Date(2014, 1, 11), + * 'MM/DD/YYYY' + * ) + * //=> '02/11/2014' + * + * @example + * // Represent 2 July 2014 in Esperanto: + * var eoLocale = require('date-fns/locale/eo') + * var result = format( + * new Date(2014, 6, 2), + * 'Do [de] MMMM YYYY', + * {locale: eoLocale} + * ) + * //=> '2-a de julio 2014' + */ + function format (dirtyDate, dirtyFormatStr, dirtyOptions) { + var formatStr = dirtyFormatStr ? String(dirtyFormatStr) : 'YYYY-MM-DDTHH:mm:ss.SSSZ' + var options = dirtyOptions || {} + + var locale = options.locale + var localeFormatters = enLocale.format.formatters + var formattingTokensRegExp = enLocale.format.formattingTokensRegExp + if (locale && locale.format && locale.format.formatters) { + localeFormatters = locale.format.formatters + + if (locale.format.formattingTokensRegExp) { + formattingTokensRegExp = locale.format.formattingTokensRegExp + } + } + + var date = parse(dirtyDate) + + if (!isValid(date)) { + return 'Invalid Date' + } + + var formatFn = buildFormatFn(formatStr, localeFormatters, formattingTokensRegExp) + + return formatFn(date) + } + + var formatters = { + // Month: 1, 2, ..., 12 + 'M': function (date) { + return date.getMonth() + 1 + }, + + // Month: 01, 02, ..., 12 + 'MM': function (date) { + return addLeadingZeros(date.getMonth() + 1, 2) + }, + + // Quarter: 1, 2, 3, 4 + 'Q': function (date) { + return Math.ceil((date.getMonth() + 1) / 3) + }, + + // Day of month: 1, 2, ..., 31 + 'D': function (date) { + return date.getDate() + }, + + // Day of month: 01, 02, ..., 31 + 'DD': function (date) { + return addLeadingZeros(date.getDate(), 2) + }, + + // Day of year: 1, 2, ..., 366 + 'DDD': function (date) { + return getDayOfYear(date) + }, + + // Day of year: 001, 002, ..., 366 + 'DDDD': function (date) { + return addLeadingZeros(getDayOfYear(date), 3) + }, + + // Day of week: 0, 1, ..., 6 + 'd': function (date) { + return date.getDay() + }, + + // Day of ISO week: 1, 2, ..., 7 + 'E': function (date) { + return date.getDay() || 7 + }, + + // ISO week: 1, 2, ..., 53 + 'W': function (date) { + return getISOWeek(date) + }, + + // ISO week: 01, 02, ..., 53 + 'WW': function (date) { + return addLeadingZeros(getISOWeek(date), 2) + }, + + // Year: 00, 01, ..., 99 + 'YY': function (date) { + return addLeadingZeros(date.getFullYear(), 4).substr(2) + }, + + // Year: 1900, 1901, ..., 2099 + 'YYYY': function (date) { + return addLeadingZeros(date.getFullYear(), 4) + }, + + // ISO week-numbering year: 00, 01, ..., 99 + 'GG': function (date) { + return String(getISOYear(date)).substr(2) + }, + + // ISO week-numbering year: 1900, 1901, ..., 2099 + 'GGGG': function (date) { + return getISOYear(date) + }, + + // Hour: 0, 1, ... 23 + 'H': function (date) { + return date.getHours() + }, + + // Hour: 00, 01, ..., 23 + 'HH': function (date) { + return addLeadingZeros(date.getHours(), 2) + }, + + // Hour: 1, 2, ..., 12 + 'h': function (date) { + var hours = date.getHours() + if (hours === 0) { + return 12 + } else if (hours > 12) { + return hours % 12 + } else { + return hours + } + }, + + // Hour: 01, 02, ..., 12 + 'hh': function (date) { + return addLeadingZeros(formatters['h'](date), 2) + }, + + // Minute: 0, 1, ..., 59 + 'm': function (date) { + return date.getMinutes() + }, + + // Minute: 00, 01, ..., 59 + 'mm': function (date) { + return addLeadingZeros(date.getMinutes(), 2) + }, + + // Second: 0, 1, ..., 59 + 's': function (date) { + return date.getSeconds() + }, + + // Second: 00, 01, ..., 59 + 'ss': function (date) { + return addLeadingZeros(date.getSeconds(), 2) + }, + + // 1/10 of second: 0, 1, ..., 9 + 'S': function (date) { + return Math.floor(date.getMilliseconds() / 100) + }, + + // 1/100 of second: 00, 01, ..., 99 + 'SS': function (date) { + return addLeadingZeros(Math.floor(date.getMilliseconds() / 10), 2) + }, + + // Millisecond: 000, 001, ..., 999 + 'SSS': function (date) { + return addLeadingZeros(date.getMilliseconds(), 3) + }, + + // Timezone: -01:00, +00:00, ... +12:00 + 'Z': function (date) { + return formatTimezone(date.getTimezoneOffset(), ':') + }, + + // Timezone: -0100, +0000, ... +1200 + 'ZZ': function (date) { + return formatTimezone(date.getTimezoneOffset()) + }, + + // Seconds timestamp: 512969520 + 'X': function (date) { + return Math.floor(date.getTime() / 1000) + }, + + // Milliseconds timestamp: 512969520900 + 'x': function (date) { + return date.getTime() + } + } + + function buildFormatFn (formatStr, localeFormatters, formattingTokensRegExp) { + var array = formatStr.match(formattingTokensRegExp) + var length = array.length + + var i + var formatter + for (i = 0; i < length; i++) { + formatter = localeFormatters[array[i]] || formatters[array[i]] + if (formatter) { + array[i] = formatter + } else { + array[i] = removeFormattingTokens(array[i]) + } + } + + return function (date) { + var output = '' + for (var i = 0; i < length; i++) { + if (array[i] instanceof Function) { + output += array[i](date, formatters) + } else { + output += array[i] + } + } + return output + } + } + + function removeFormattingTokens (input) { + if (input.match(/\[[\s\S]/)) { + return input.replace(/^\[|]$/g, '') + } + return input.replace(/\\/g, '') + } + + function formatTimezone (offset, delimeter) { + delimeter = delimeter || '' + var sign = offset > 0 ? '-' : '+' + var absOffset = Math.abs(offset) + var hours = Math.floor(absOffset / 60) + var minutes = absOffset % 60 + return sign + addLeadingZeros(hours, 2) + delimeter + addLeadingZeros(minutes, 2) + } + + function addLeadingZeros (number, targetLength) { + var output = Math.abs(number).toString() + while (output.length < targetLength) { + output = '0' + output + } + return output + } + + module.exports = format + + +/***/ }, +/* 18 */ +/***/ function(module, exports, __webpack_require__) { + + var parse = __webpack_require__(6) + var startOfYear = __webpack_require__(19) + var differenceInCalendarDays = __webpack_require__(20) + + /** + * @category Day Helpers + * @summary Get the day of the year of the given date. + * + * @description + * Get the day of the year of the given date. + * + * @param {Date|String|Number} date - the given date + * @returns {Number} the day of year + * + * @example + * // Which day of the year is 2 July 2014? + * var result = getDayOfYear(new Date(2014, 6, 2)) + * //=> 183 + */ + function getDayOfYear (dirtyDate) { + var date = parse(dirtyDate) + var diff = differenceInCalendarDays(date, startOfYear(date)) + var dayOfYear = diff + 1 + return dayOfYear + } + + module.exports = getDayOfYear + + +/***/ }, +/* 19 */ +/***/ function(module, exports, __webpack_require__) { + + var parse = __webpack_require__(6) + + /** + * @category Year Helpers + * @summary Return the start of a year for the given date. + * + * @description + * Return the start of a year for the given date. + * The result will be in the local timezone. + * + * @param {Date|String|Number} date - the original date + * @returns {Date} the start of a year + * + * @example + * // The start of a year for 2 September 2014 11:55:00: + * var result = startOfYear(new Date(2014, 8, 2, 11, 55, 00)) + * //=> Wed Jan 01 2014 00:00:00 + */ + function startOfYear (dirtyDate) { + var cleanDate = parse(dirtyDate) + var date = new Date(0) + date.setFullYear(cleanDate.getFullYear(), 0, 1) + date.setHours(0, 0, 0, 0) + return date + } + + module.exports = startOfYear + + +/***/ }, +/* 20 */ +/***/ function(module, exports, __webpack_require__) { + + var startOfDay = __webpack_require__(21) + + var MILLISECONDS_IN_MINUTE = 60000 + var MILLISECONDS_IN_DAY = 86400000 + + /** + * @category Day Helpers + * @summary Get the number of calendar days between the given dates. + * + * @description + * Get the number of calendar days between the given dates. + * + * @param {Date|String|Number} dateLeft - the later date + * @param {Date|String|Number} dateRight - the earlier date + * @returns {Number} the number of calendar days + * + * @example + * // How many calendar days are between + * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00? + * var result = differenceInCalendarDays( + * new Date(2012, 6, 2, 0, 0), + * new Date(2011, 6, 2, 23, 0) + * ) + * //=> 366 + */ + function differenceInCalendarDays (dirtyDateLeft, dirtyDateRight) { + var startOfDayLeft = startOfDay(dirtyDateLeft) + var startOfDayRight = startOfDay(dirtyDateRight) + + var timestampLeft = startOfDayLeft.getTime() - + startOfDayLeft.getTimezoneOffset() * MILLISECONDS_IN_MINUTE + var timestampRight = startOfDayRight.getTime() - + startOfDayRight.getTimezoneOffset() * MILLISECONDS_IN_MINUTE + + // Round the number of days to the nearest integer + // because the number of milliseconds in a day is not constant + // (e.g. it's different in the day of the daylight saving time clock shift) + return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY) + } + + module.exports = differenceInCalendarDays + + +/***/ }, +/* 21 */ +/***/ function(module, exports, __webpack_require__) { + + var parse = __webpack_require__(6) + + /** + * @category Day Helpers + * @summary Return the start of a day for the given date. + * + * @description + * Return the start of a day for the given date. + * The result will be in the local timezone. + * + * @param {Date|String|Number} date - the original date + * @returns {Date} the start of a day + * + * @example + * // The start of a day for 2 September 2014 11:55:00: + * var result = startOfDay(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Tue Sep 02 2014 00:00:00 + */ + function startOfDay (dirtyDate) { + var date = parse(dirtyDate) + date.setHours(0, 0, 0, 0) + return date + } + + module.exports = startOfDay + + +/***/ }, +/* 22 */ +/***/ function(module, exports, __webpack_require__) { + + var parse = __webpack_require__(6) + var startOfISOWeek = __webpack_require__(23) + var startOfISOYear = __webpack_require__(25) + + var MILLISECONDS_IN_WEEK = 604800000 + + /** + * @category ISO Week Helpers + * @summary Get the ISO week of the given date. + * + * @description + * Get the ISO week of the given date. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @param {Date|String|Number} date - the given date + * @returns {Number} the ISO week + * + * @example + * // Which week of the ISO-week numbering year is 2 January 2005? + * var result = getISOWeek(new Date(2005, 0, 2)) + * //=> 53 + */ + function getISOWeek (dirtyDate) { + var date = parse(dirtyDate) + var diff = startOfISOWeek(date).getTime() - startOfISOYear(date).getTime() + + // Round the number of days to the nearest integer + // because the number of milliseconds in a week is not constant + // (e.g. it's different in the week of the daylight saving time clock shift) + return Math.round(diff / MILLISECONDS_IN_WEEK) + 1 + } + + module.exports = getISOWeek + + +/***/ }, +/* 23 */ +/***/ function(module, exports, __webpack_require__) { + + var startOfWeek = __webpack_require__(24) + + /** + * @category ISO Week Helpers + * @summary Return the start of an ISO week for the given date. + * + * @description + * Return the start of an ISO week for the given date. + * The result will be in the local timezone. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @param {Date|String|Number} date - the original date + * @returns {Date} the start of an ISO week + * + * @example + * // The start of an ISO week for 2 September 2014 11:55:00: + * var result = startOfISOWeek(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Mon Sep 01 2014 00:00:00 + */ + function startOfISOWeek (dirtyDate) { + return startOfWeek(dirtyDate, {weekStartsOn: 1}) + } + + module.exports = startOfISOWeek + + +/***/ }, +/* 24 */ +/***/ function(module, exports, __webpack_require__) { + + var parse = __webpack_require__(6) + + /** + * @category Week Helpers + * @summary Return the start of a week for the given date. + * + * @description + * Return the start of a week for the given date. + * The result will be in the local timezone. + * + * @param {Date|String|Number} date - the original date + * @param {Object} [options] - the object with options + * @param {Number} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) + * @returns {Date} the start of a week + * + * @example + * // The start of a week for 2 September 2014 11:55:00: + * var result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0)) + * //=> Sun Aug 31 2014 00:00:00 + * + * @example + * // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00: + * var result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), {weekStartsOn: 1}) + * //=> Mon Sep 01 2014 00:00:00 + */ + function startOfWeek (dirtyDate, dirtyOptions) { + var weekStartsOn = dirtyOptions ? (Number(dirtyOptions.weekStartsOn) || 0) : 0 + + var date = parse(dirtyDate) + var day = date.getDay() + var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn + + date.setDate(date.getDate() - diff) + date.setHours(0, 0, 0, 0) + return date + } + + module.exports = startOfWeek + + +/***/ }, +/* 25 */ +/***/ function(module, exports, __webpack_require__) { + + var getISOYear = __webpack_require__(26) + var startOfISOWeek = __webpack_require__(23) + + /** + * @category ISO Week-Numbering Year Helpers + * @summary Return the start of an ISO week-numbering year for the given date. + * + * @description + * Return the start of an ISO week-numbering year, + * which always starts 3 days before the year's first Thursday. + * The result will be in the local timezone. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @param {Date|String|Number} date - the original date + * @returns {Date} the start of an ISO year + * + * @example + * // The start of an ISO week-numbering year for 2 July 2005: + * var result = startOfISOYear(new Date(2005, 6, 2)) + * //=> Mon Jan 03 2005 00:00:00 + */ + function startOfISOYear (dirtyDate) { + var year = getISOYear(dirtyDate) + var fourthOfJanuary = new Date(0) + fourthOfJanuary.setFullYear(year, 0, 4) + fourthOfJanuary.setHours(0, 0, 0, 0) + var date = startOfISOWeek(fourthOfJanuary) + return date + } + + module.exports = startOfISOYear + + +/***/ }, +/* 26 */ +/***/ function(module, exports, __webpack_require__) { + + var parse = __webpack_require__(6) + var startOfISOWeek = __webpack_require__(23) + + /** + * @category ISO Week-Numbering Year Helpers + * @summary Get the ISO week-numbering year of the given date. + * + * @description + * Get the ISO week-numbering year of the given date, + * which always starts 3 days before the year's first Thursday. + * + * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date + * + * @param {Date|String|Number} date - the given date + * @returns {Number} the ISO week-numbering year + * + * @example + * // Which ISO-week numbering year is 2 January 2005? + * var result = getISOYear(new Date(2005, 0, 2)) + * //=> 2004 + */ + function getISOYear (dirtyDate) { + var date = parse(dirtyDate) + var year = date.getFullYear() + + var fourthOfJanuaryOfNextYear = new Date(0) + fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4) + fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0) + var startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear) + + var fourthOfJanuaryOfThisYear = new Date(0) + fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4) + fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0) + var startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear) + + if (date.getTime() >= startOfNextYear.getTime()) { + return year + 1 + } else if (date.getTime() >= startOfThisYear.getTime()) { + return year + } else { + return year - 1 + } + } + + module.exports = getISOYear + + +/***/ }, +/* 27 */ +/***/ function(module, exports, __webpack_require__) { + + var isDate = __webpack_require__(7) + + /** + * @category Common Helpers + * @summary Is the given date valid? + * + * @description + * Returns false if argument is Invalid Date and true otherwise. + * Invalid Date is a Date, whose time value is NaN. + * + * Time value of Date: http://es5.github.io/#x15.9.1.1 + * + * @param {Date} date - the date to check + * @returns {Boolean} the date is valid + * @throws {TypeError} argument must be an instance of Date + * + * @example + * // For the valid date: + * var result = isValid(new Date(2014, 1, 31)) + * //=> true + * + * @example + * // For the invalid date: + * var result = isValid(new Date('')) + * //=> false + */ + function isValid (dirtyDate) { + if (isDate(dirtyDate)) { + return !isNaN(dirtyDate) + } else { + throw new TypeError(toString.call(dirtyDate) + ' is not an instance of Date') + } + } + + module.exports = isValid + + +/***/ }, +/* 28 */ +/***/ function(module, exports) { + + module.exports = require("moment"); + +/***/ }, +/* 29 */ +/***/ function(module, exports, __webpack_require__) { + + var buildDistanceInWordsLocale = __webpack_require__(30) + var buildFormatLocale = __webpack_require__(31) /** * @category Locales @@ -1641,7 +2380,7 @@ /***/ }, -/* 18 */ +/* 30 */ /***/ function(module, exports) { function buildDistanceInWordsLocale () { @@ -1825,7 +2564,7 @@ /***/ }, -/* 19 */ +/* 31 */ /***/ function(module, exports, __webpack_require__) { var buildFormattingTokensRegExp = __webpack_require__(16) @@ -1914,13 +2653,13 @@ /***/ }, -/* 20 */ +/* 32 */ /***/ function(module, exports) { module.exports = require("mongodb"); /***/ }, -/* 21 */ +/* 33 */ /***/ function(module, exports) { module.exports = require("babel-polyfill"); diff --git a/backend/package.json b/backend/package.json index 2bd5285..e7c3dde 100644 --- a/backend/package.json +++ b/backend/package.json @@ -20,6 +20,7 @@ "date-fns": "^1.28.2", "express": "^4.15.2", "isomorphic-fetch": "^2.2.1", + "moment": "^2.18.1", "mongodb": "^2.2.25" } } diff --git a/backend/server.js b/backend/server.js index 330a44b..3b49ed3 100644 --- a/backend/server.js +++ b/backend/server.js @@ -1,6 +1,9 @@ import express from 'express' import bodyParser from 'body-parser'; import distanceInWordsToNow from 'date-fns/distance_in_words_to_now'; +import parseDate from 'date-fns/format'; +import moment from 'moment'; + var hr = require('date-fns/locale/hr'); var MongoClient = require('mongodb').MongoClient; @@ -218,6 +221,7 @@ router.get('/search/listings', async (req, res, next) => { } })); } else { + res.json(all.map(({_id, address, images, @@ -233,9 +237,10 @@ router.get('/search/listings', async (req, res, next) => { rooms, size, time: distanceInWordsToNow( - new Date(time), - {locale: hr} - ) + moment(time, 'DD.MM.YYYY'), + {locale: hr} + ), + realTime: time }))); } diff --git a/backend/yarn.lock b/backend/yarn.lock index 4d839d6..a71f927 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -840,6 +840,10 @@ mkdirp@^0.5.1: dependencies: minimist "0.0.8" +moment: + version "2.18.1" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" + mongodb: version "2.2.25" resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-2.2.25.tgz#d3b25dad00eda2bdfcbc996210ba082ac686a6b6" diff --git a/web/dist/main.css b/web/dist/main.css index b782df4..44224bc 100644 --- a/web/dist/main.css +++ b/web/dist/main.css @@ -386,6 +386,8 @@ html { .address { overflow: hidden; font-size: 12px; + height: 50px; + margin-bottom: 20px; } .street { @@ -467,6 +469,14 @@ html { } @media (max-width : 768px) { + .address { + margin-bottom: 0; + } + + .hours-ago { + display: none; + } + .filter-bottom { position: fixed; bottom: 0; @@ -480,6 +490,10 @@ html { align-items: baseline; } + .filter-bottom .confirm { + background-color: #b6d53b; + } + .listings-count { display: none; } diff --git a/web/src/components/Filters.js b/web/src/components/Filters.js index 55887f1..3f47286 100644 --- a/web/src/components/Filters.js +++ b/web/src/components/Filters.js @@ -263,7 +263,8 @@ export default class Filters extends React.Component {