Skip to content

Commit

Permalink
improving type naming
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavweber committed Sep 6, 2024
1 parent 75d14ae commit 1728cb7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/WeeklyCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ export function WeeklyCalendar<T extends GenericEvent>({
onEventClick,
onSelectDate,
weekends = false,
value,
currentDate,
}: CalendarContainerProps<T>) {
const [startWeek, setStartWeek] = useState(startOfWeek(value || new Date(), { weekStartsOn: 0 }));
const [startWeek, setStartWeek] = useState(startOfWeek(currentDate || new Date(), { weekStartsOn: 0 }));
const weekPeriod = {
startDate: startWeek,
endDate: endOfWeek(startWeek),
};

useEffect(() => {
if (value && startOfWeek(value).getTime() !== startWeek.getTime()) {
setStartWeek(value);
if (currentDate && startOfWeek(currentDate).getTime() !== startWeek.getTime()) {
setStartWeek(currentDate);
}
}, [value]);
}, [currentDate]);

useEffect(() => {
onSelectDate && onSelectDate(startWeek);
Expand Down
2 changes: 1 addition & 1 deletion src/components/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface BaseCalendarProps<T extends GenericEvent = GenericEvent> {
export interface CalendarContainerProps<T extends GenericEvent = GenericEvent>
extends BaseCalendarProps<T> {
events: T[];
value?: Date;
currentDate?: Date;
}

export interface CalendarBodyProps<T extends GenericEvent = GenericEvent>
Expand Down

0 comments on commit 1728cb7

Please sign in to comment.