Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
fix: revert fix for groups and add fix for date range hook
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkamyshev committed Mar 6, 2019
1 parent 29c817a commit 02756da
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const createMonthGroups = ({ from, to }: DateRange): DateGroup[] => {
const groups = []

let now = startOfMonth(from)
while (now < subMonths(to, 1)) {
while (now < to) {
const next = addMonths(now, 1)
const nowYear = now.getFullYear()
groups.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const createWeekGroups = ({ from, to }: DateRange): DateGroup[] => {
const groups = []

let now = startOfWeek(from)
while (now < subWeeks(to, 1)) {
while (now < to) {
const next = addWeeks(now, 1)
const nowYear = now.getFullYear()
groups.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const createYearGroups = ({ from, to }: DateRange): DateGroup[] => {
const firstYear = from.getFullYear()
const lastYear = to.getFullYear()

const years = range(firstYear, lastYear)
const years = range(firstYear, lastYear + 1)

return years.map(year => ({
title: year.toString(),
Expand Down
4 changes: 2 additions & 2 deletions front/src/ui/hooks/useActualDateRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export const useActualDateRange = (
transfromFrom: (from: Date, to: Date) => Date,
transfromTo: (to: Date, from: Date) => Date,
) => {
const [from, setFrom] = useState(transfromFrom(initialFrom, initialTo))
const [to, setTo] = useState(transfromTo(initialTo, initialFrom))
const [from, setFrom] = useState(initialFrom)
const [to, setTo] = useState(initialTo)

const [actualFrom, actualTo] = useMemo(
() => [transfromFrom(from, to), transfromTo(to, from)],
Expand Down

0 comments on commit 02756da

Please sign in to comment.