From f700b29b3d7b9198888269985a6d666bdc480d48 Mon Sep 17 00:00:00 2001 From: Liordino Neto Date: Mon, 17 Aug 2020 23:41:53 -0300 Subject: [PATCH] fix: added last month last days on the popup calendar, and fix it's day of week organization chore: removed debug logging --- .../src/components/date-range-picker/Calendar.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/new-lamassu-admin/src/components/date-range-picker/Calendar.js b/new-lamassu-admin/src/components/date-range-picker/Calendar.js index dd347fe1..b871836e 100644 --- a/new-lamassu-admin/src/components/date-range-picker/Calendar.js +++ b/new-lamassu-admin/src/components/date-range-picker/Calendar.js @@ -3,9 +3,9 @@ import moment from 'moment' import * as R from 'ramda' import React, { useState } from 'react' +import typographyStyles from 'src/components/typography/styles' import { ReactComponent as Arrow } from 'src/styling/icons/arrow/month_change.svg' import { primaryColor, zircon } from 'src/styling/variables' -import typographyStyles from 'src/components/typography/styles' import Tile from './Tile' @@ -73,12 +73,6 @@ const Calendar = ({ minDate, maxDate, handleSelect, ...props }) => { const classes = useStyles() const weekdays = moment.weekdaysMin().map(day => day.slice(0, 1)) - const firstDayOfMonth = month => - Number.parseInt( - moment(month) - .startOf('month') - .format('d') - ) const monthLength = month => Number.parseInt( moment(month) @@ -88,7 +82,12 @@ const Calendar = ({ minDate, maxDate, handleSelect, ...props }) => { const monthdays = month => { const lastMonth = moment(month).subtract(1, 'month') - const lastMonthRange = R.range(firstDayOfMonth(month) - 1, -1) + const lastMonthRange = R.range( + 0, + moment(month) + .startOf('month') + .weekday() + ).reverse() const lastMonthDays = R.map(i => moment(lastMonth) .endOf('month')