* fix: refactor * add `isMonthViewProp` to header * feat: init v1 for calendar view atom * test breaking toggle buttons * fix: make sure week start is always sunday for calendar view atom * fixup * fix: remove extra comments * fix: add calendar view page in examples app * chore: add changesets * fix: coderabbit feedback * fixup
18 lines
638 B
TypeScript
18 lines
638 B
TypeScript
import { useEffect } from "react";
|
|
|
|
import dayjs from "@calcom/dayjs";
|
|
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
|
|
|
|
export const useInitializeWeekStart = (isPlatform: boolean, isCalendarView: boolean) => {
|
|
const today = dayjs();
|
|
const weekStart = today.startOf("week").format("YYYY-MM-DD");
|
|
const setSelectedDate = useBookerStoreContext((state) => state.setSelectedDate);
|
|
|
|
useEffect(() => {
|
|
if (isPlatform && isCalendarView) {
|
|
setSelectedDate({ date: weekStart, omitUpdatingParams: true });
|
|
}
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, []);
|
|
};
|