UNPKG

@zohodesk/hooks

Version:

Unified Component Library - Hooks

39 lines 820 B
import useCalendar from "./useCalendar"; import useTime from "./useTime"; import { dateTimeDecoder, dateTimeEncoder } from "./utils/dateTimeConverter"; export default function useDateTime(props, customReducer) { const { value } = props; const { calendarValue, timeValue } = dateTimeDecoder(value); const { value: cvalue, getMonthData, handleChange, handlePrevMonth, handleNextMonth, handlePrevYear, handleNextYear } = useCalendar({ value: calendarValue }, customReducer); const { time, setTime } = useTime({ time: timeValue }, customReducer); return { value: dateTimeEncoder(cvalue, time), getMonthData, handleChange, handlePrevMonth, handleNextMonth, handlePrevYear, handleNextYear, handleTime: setTime }; }