e.preventDefault()}
+ >
{/* Current time vertical line */}
{showNowLine && nowLeftPx !== null && (
e.preventDefault()}
onDrop={(e) => handleDropOnTech(e, tech)}
onDoubleClick={(e) => {
- const timeline = timelineRef.current;
- if (!timeline) return;
- const rect = timeline.getBoundingClientRect();
- const x = e.clientX - rect.left;
- const minutesFromVisibleStart = Math.max(0, Math.round((x / 80) * 60));
- const absoluteMinutes = visibleStartHour * 60 + minutesFromVisibleStart;
+ const absoluteMinutes = getMinutesFromPointer(e.clientX);
const start = new Date(selectedDate);
start.setHours(0, 0, 0, 0);
start.setMinutes(Math.round(absoluteMinutes / 15) * 15);
@@ -401,22 +387,19 @@ export function GanttView({
setCreateOpen(true);
}}
>
- {/* Hour Grid Lines - Scaled to fit row height */}
-
- {visibleHours.map((hour, idx) => {
- // Scale hour positions to fit within technician row height
- const scaledTop = (idx / visibleHoursCount) * TECHNICIAN_ROW_HEIGHT;
- return (
-
- );
- })}
+ {/* Hour Grid Lines */}
+
+ {[...ALL_HOURS, ALL_HOURS.length].map((hour) => (
+
+ ))}
{/* Appointments */}
@@ -425,19 +408,8 @@ export function GanttView({
return null;
}
- // Check if appointment is in visible range
const startDt = parseLocalDateTime(appointment.scheduled_start_datetime);
const endDt = parseLocalDateTime(appointment.scheduled_finish_datetime);
- const appointmentStartHour = startDt.getHours();
- const appointmentEndHour = endDt.getHours();
-
- // Skip if appointment is completely outside visible range
- if (
- (appointmentEndHour < visibleStartHour) ||
- (appointmentStartHour > visibleEndHour)
- ) {
- return null;
- }
const statusColors: Record
= {
Open: "bg-primary/70",
@@ -462,14 +434,6 @@ export function GanttView({
const startMinutes = (appointmentStart.getTime() - dayStart.getTime()) / (1000 * 60);
const endMinutes = (appointmentEnd.getTime() - dayStart.getTime()) / (1000 * 60);
- // Adjust for visible hours offset - calculate position relative to visible start
- const visibleStartMinutes = visibleStartHour * 60;
-
- // Calculate position relative to visible start (can be negative if before visible range)
- const adjustedStartMinutes = startMinutes - visibleStartMinutes;
-
- const adjustedEndMinutes = endMinutes - visibleStartMinutes;
-
// Vertical position - center the appointment bar in the technician row
const top = (TECHNICIAN_ROW_HEIGHT - 40) / 2; // Center 40px bar in 60px row
@@ -480,16 +444,10 @@ export function GanttView({
// Calculate horizontal position and width using absolute pixel values
// Each hour is 80px wide, so we calculate based on that
- const hourColumnWidth = 80;
-
- // Calculate left position in pixels (relative to visible start)
- // If start is before visible range, left will be negative (will be clipped naturally)
- const leftPx = (adjustedStartMinutes / 60) * hourColumnWidth;
+ const leftPx = (startMinutes / 60) * HOUR_COLUMN_WIDTH;
- // Calculate width in pixels based on actual duration
- // This allows the bar to extend beyond visible range
- const durationHours = (adjustedEndMinutes - adjustedStartMinutes) / 60;
- const widthPx = Math.max(durationHours * hourColumnWidth, 80); // Min 80px
+ const durationHours = (endMinutes - startMinutes) / 60;
+ const widthPx = Math.max(durationHours * HOUR_COLUMN_WIDTH, 40); // Min width
const left = `${leftPx}px`;
const width = `${widthPx}px`;
diff --git a/schedule/src/components/schedule/schedule-right-panel.tsx b/schedule/src/components/schedule/schedule-right-panel.tsx
index 44aa43a..a8f3523 100644
--- a/schedule/src/components/schedule/schedule-right-panel.tsx
+++ b/schedule/src/components/schedule/schedule-right-panel.tsx
@@ -9,7 +9,7 @@ import {
PopoverTrigger,
} from "../ui/popover";
import { CalendarIcon, BarChart3, Map, Calendar as CalendarIcon2, Search, Sun, Moon } from "lucide-react";
-import { format, isToday, addMonths, subMonths, startOfWeek, endOfWeek, startOfMonth, endOfMonth, startOfDay, endOfDay } from "date-fns";
+import { format, isToday, addMonths, subMonths } from "date-fns";
import { cn } from "../../lib/utils";
import { Appointment } from "../../pages/schedule/types";
import { GanttView } from "./gantt-view";
@@ -111,11 +111,11 @@ export function ScheduleRightPanel({
const shouldShowDateControls = viewType !== "maps" || mapDurationFilter === "date";
return (
-
+
{/* Section 1: View Type Switcher (Top) */}
-
-
-
+
+
+
-
+
+
+
{/* Section 2: Date Selection and Options */}
-
-
+
+
{viewType === "maps" && (