refactor: date utils and all calls
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { useState, useEffect, useCallback, useTransition } from 'react';
|
||||
import { dailyClient, DailyHistoryFilters, DailySearchFilters, ReorderCheckboxesData } from '@/clients/daily-client';
|
||||
import { DailyView, DailyCheckbox, UpdateDailyCheckboxData, DailyCheckboxType } from '@/lib/types';
|
||||
import { addDays, subtractDays, getToday } from '@/lib/date-utils';
|
||||
import {
|
||||
toggleCheckbox as toggleCheckboxAction,
|
||||
addTodayCheckbox as addTodayCheckboxAction,
|
||||
@@ -341,19 +342,17 @@ export function useDaily(initialDate?: Date, initialDailyView?: DailyView): UseD
|
||||
}, []);
|
||||
|
||||
const goToPreviousDay = useCallback(async (): Promise<void> => {
|
||||
const previousDay = new Date(currentDate);
|
||||
previousDay.setDate(previousDay.getDate() - 1);
|
||||
const previousDay = subtractDays(currentDate, 1);
|
||||
setCurrentDate(previousDay);
|
||||
}, [currentDate]);
|
||||
|
||||
const goToNextDay = useCallback(async (): Promise<void> => {
|
||||
const nextDay = new Date(currentDate);
|
||||
nextDay.setDate(nextDay.getDate() + 1);
|
||||
const nextDay = addDays(currentDate, 1);
|
||||
setCurrentDate(nextDay);
|
||||
}, [currentDate]);
|
||||
|
||||
const goToToday = useCallback(async (): Promise<void> => {
|
||||
setCurrentDate(new Date());
|
||||
setCurrentDate(getToday());
|
||||
}, []);
|
||||
|
||||
const setDate = useCallback(async (date: Date): Promise<void> => {
|
||||
|
||||
Reference in New Issue
Block a user