11<script setup lang="ts">
22import { computed , ref , onUnmounted } from " vue" ;
33import { useCalendarStore } from " @/stores/calendar" ;
4+ import { useUiStore } from " @/stores/ui" ;
45import type { CalendarEvent } from " @/lib/types" ;
56import { dragCalendarEvent , isCalendarDragging } from " @/lib/calendar-drag-state" ;
67
@@ -17,6 +18,7 @@ const emit = defineEmits<{
1718}>();
1819
1920const calendarStore = useCalendarStore ();
21+ const uiStore = useUiStore ();
2022
2123const weeks = computed (() => {
2224 const d = new Date (calendarStore .currentDate );
@@ -25,9 +27,10 @@ const weeks = computed(() => {
2527 const firstDay = new Date (year , month , 1 );
2628 const lastDay = new Date (year , month + 1 , 0 );
2729
28- // Start from Sunday of the first week
30+ // Start from the configured week start day
2931 const start = new Date (firstDay );
30- start .setDate (start .getDate () - start .getDay ());
32+ const offset = (start .getDay () - uiStore .weekStartDay + 7 ) % 7 ;
33+ start .setDate (start .getDate () - offset );
3134
3235 const rows: Date [][] = [];
3336 const current = new Date (start );
@@ -72,7 +75,11 @@ function getEventColor(event: { calendar_id: string }): string {
7275 return cal ?.color || " #4285f4" ;
7376}
7477
75- const dayNames = [" Sun" , " Mon" , " Tue" , " Wed" , " Thu" , " Fri" , " Sat" ];
78+ const allDayNames = [" Sun" , " Mon" , " Tue" , " Wed" , " Thu" , " Fri" , " Sat" ];
79+ const dayNames = computed (() => {
80+ const s = uiStore .weekStartDay ;
81+ return [... allDayNames .slice (s ), ... allDayNames .slice (0 , s )];
82+ });
7683
7784// Drag-to-reschedule
7885const dragStartPos = ref <{ x: number ; y: number } | null >(null );
0 commit comments