fix prettier

This commit is contained in:
lenhanphung
2025-09-25 17:16:12 +07:00
parent ca0fe4a4a8
commit 7b8a2e74a5
3 changed files with 27 additions and 22 deletions
+22 -13
View File
@@ -42,28 +42,29 @@ import Button from "@mui/material/Button";
const updateSlotLabelVisibility = (currentTime: Date) => { const updateSlotLabelVisibility = (currentTime: Date) => {
const slotLabels = document.querySelectorAll(".fc-timegrid-slot-label"); const slotLabels = document.querySelectorAll(".fc-timegrid-slot-label");
const currentMinutes = currentTime.getHours() * 60 + currentTime.getMinutes(); const currentMinutes = currentTime.getHours() * 60 + currentTime.getMinutes();
slotLabels.forEach((label) => { slotLabels.forEach((label) => {
const labelElement = label as HTMLElement; const labelElement = label as HTMLElement;
const timeText = labelElement.textContent?.trim(); const timeText = labelElement.textContent?.trim();
if (timeText && timeText.match(/^\d{1,2}:\d{2}$/)) { if (timeText && timeText.match(/^\d{1,2}:\d{2}$/)) {
const [hours, minutes] = timeText.split(':').map(Number); const [hours, minutes] = timeText.split(":").map(Number);
const labelMinutes = hours * 60 + minutes; const labelMinutes = hours * 60 + minutes;
// Calculate time difference in minutes // Calculate time difference in minutes
let timeDiff = Math.abs(currentMinutes - labelMinutes); let timeDiff = Math.abs(currentMinutes - labelMinutes);
// Handle edge case around midnight (00:00) // Handle edge case around midnight (00:00)
if (timeDiff > 12 * 60) { // More than 12 hours difference if (timeDiff > 12 * 60) {
// More than 12 hours difference
timeDiff = 24 * 60 - timeDiff; // Wrap around timeDiff = 24 * 60 - timeDiff; // Wrap around
} }
// Dim if within 15 minutes (before or after) // Dim if within 15 minutes (before or after)
if (timeDiff <= 15) { if (timeDiff <= 15) {
labelElement.style.opacity = '0.2'; labelElement.style.opacity = "0.2";
} else { } else {
labelElement.style.opacity = '1'; labelElement.style.opacity = "1";
} }
} }
}); });
@@ -455,7 +456,7 @@ export default function CalendarApp({
calendarRef.current?.changeView("timeGridDay", arg.date); calendarRef.current?.changeView("timeGridDay", arg.date);
setSelectedDate(new Date(arg.date)); setSelectedDate(new Date(arg.date));
setSelectedMiniDate(new Date(arg.date)); setSelectedMiniDate(new Date(arg.date));
// Notify parent about view change // Notify parent about view change
if (onViewChange) { if (onViewChange) {
onViewChange("timeGridDay"); onViewChange("timeGridDay");
@@ -493,7 +494,7 @@ export default function CalendarApp({
hour12: false, hour12: false,
}); });
nowIndicatorArrow.setAttribute("data-time", timeString); nowIndicatorArrow.setAttribute("data-time", timeString);
// Hide slot labels that are too close to current time // Hide slot labels that are too close to current time
updateSlotLabelVisibility(now); updateSlotLabelVisibility(now);
} }
@@ -700,7 +701,11 @@ export default function CalendarApp({
return true; return true;
}} }}
eventDrop={(arg) => { eventDrop={(arg) => {
if (!arg.event || !arg.event._def || !arg.event._def.extendedProps) { if (
!arg.event ||
!arg.event._def ||
!arg.event._def.extendedProps
) {
return; return;
} }
@@ -732,7 +737,11 @@ export default function CalendarApp({
); );
}} }}
eventResize={(arg) => { eventResize={(arg) => {
if (!arg.event || !arg.event._def || !arg.event._def.extendedProps) { if (
!arg.event ||
!arg.event._def ||
!arg.event._def.extendedProps
) {
return; return;
} }
+3 -3
View File
@@ -66,9 +66,9 @@ export default function CalendarLayout() {
return ( return (
<div className="App"> <div className="App">
<Menubar {...menubarProps} /> <Menubar {...menubarProps} />
<CalendarApp <CalendarApp
calendarRef={calendarRef} calendarRef={calendarRef}
onDateChange={handleDateChange} onDateChange={handleDateChange}
onViewChange={handleViewChange} onViewChange={handleViewChange}
/> />
</div> </div>
+2 -6
View File
@@ -70,12 +70,8 @@ function EventPopover({
const [description, setDescription] = useState(event?.description ?? ""); const [description, setDescription] = useState(event?.description ?? "");
const [location, setLocation] = useState(event?.location ?? ""); const [location, setLocation] = useState(event?.location ?? "");
const [start, setStart] = useState( const [start, setStart] = useState(event?.start ? event.start : "");
event?.start ? event.start : "" const [end, setEnd] = useState(event?.end ? event.end : "");
);
const [end, setEnd] = useState(
event?.end ? event.end : ""
);
const [calendarid, setCalendarid] = useState( const [calendarid, setCalendarid] = useState(
event?.calId event?.calId
? userPersonnalCalendars.findIndex((e) => e.id === event?.calId) ? userPersonnalCalendars.findIndex((e) => e.id === event?.calId)