This commit is contained in:
Louis Mazin 2026-09-25 16:25:50 +02:00
parent 8ef1bed6b1
commit df648c2b70

View File

@ -23,12 +23,8 @@ const DEFAULT_START_HOUR = 8;
const DEFAULT_END_HOUR = 18; const DEFAULT_END_HOUR = 18;
const SCHEDULE_HEADER_HEIGHT = 58; const SCHEDULE_HEADER_HEIGHT = 58;
const MIN_SCHEDULE_HEIGHT = 180;
const MOBILE_MIN_HOUR_HEIGHT = 52;
const MOBILE_TIME_COLUMN_WIDTH = 64; const MOBILE_TIME_COLUMN_WIDTH = 64;
const MOBILE_USER_COLUMN_WIDTH = 40;
const MOBILE_DEFAULT_CONTENT_WIDTH = 236; const MOBILE_DEFAULT_CONTENT_WIDTH = 236;
const expandOvernightAttendances = (entries) => { const expandOvernightAttendances = (entries) => {
@ -443,17 +439,9 @@ const WeeklySummaryPage = ({ userId }) => {
} }
setMobileContainerWidth( setMobileContainerWidth(
scheduleTable.clientWidth, Math.max(0, scheduleTable.clientWidth - 2),
); );
if (window.innerWidth < 768) {
setMobileContainerHeight(
scheduleTable.clientHeight,
);
return;
}
const cardContent = const cardContent =
scheduleTable.closest( scheduleTable.closest(
'[data-slot="card-content"]', '[data-slot="card-content"]',
@ -476,11 +464,10 @@ const WeeklySummaryPage = ({ userId }) => {
? footer.getBoundingClientRect().top ? footer.getBoundingClientRect().top
: window.innerHeight; : window.innerHeight;
const availableBottom = const availableBottom = Math.min(
Math.min(
contentRect.bottom,
footerTop, footerTop,
window.innerHeight, window.innerHeight,
contentRect.bottom,
); );
const SAFETY_MARGIN = 4; const SAFETY_MARGIN = 4;
@ -490,23 +477,16 @@ const WeeklySummaryPage = ({ userId }) => {
tableTop - tableTop -
SAFETY_MARGIN; SAFETY_MARGIN;
const nextTotalHeight = const nextScheduleHeight = Math.max(
Math.max( 0,
SCHEDULE_HEADER_HEIGHT + totalAvailableHeight - SCHEDULE_HEADER_HEIGHT,
MIN_SCHEDULE_HEIGHT,
totalAvailableHeight,
); );
const nextScheduleHeight = if (window.innerWidth < 768) {
Math.max( setMobileContainerHeight(Math.max(0, totalAvailableHeight));
MIN_SCHEDULE_HEIGHT, } else {
nextTotalHeight - setAvailableScheduleHeight(nextScheduleHeight);
SCHEDULE_HEADER_HEIGHT, }
);
setAvailableScheduleHeight(
nextScheduleHeight,
);
}; };
updateScheduleDimensions(); updateScheduleDimensions();
@ -1066,27 +1046,9 @@ const WeeklySummaryPage = ({ userId }) => {
SCHEDULE_HEADER_HEIGHT, SCHEDULE_HEADER_HEIGHT,
); );
const mobileNaturalScheduleHeight =
hourCount *
MOBILE_MIN_HOUR_HEIGHT;
const mobileScheduleHeight =
mobileAvailableBodyHeight > 0
? Math.max(
mobileAvailableBodyHeight,
mobileNaturalScheduleHeight,
)
: Math.max(
MIN_SCHEDULE_HEIGHT,
mobileNaturalScheduleHeight,
);
const scheduleHeight = isMobile const scheduleHeight = isMobile
? mobileScheduleHeight ? mobileAvailableBodyHeight
: Math.max( : availableScheduleHeight;
MIN_SCHEDULE_HEIGHT,
availableScheduleHeight,
);
const totalPlanningHeight = const totalPlanningHeight =
SCHEDULE_HEADER_HEIGHT + SCHEDULE_HEADER_HEIGHT +
@ -1148,7 +1110,7 @@ const WeeklySummaryPage = ({ userId }) => {
mobileContainerWidth > 0 mobileContainerWidth > 0
? mobileContainerWidth ? mobileContainerWidth
: typeof window !== 'undefined' : typeof window !== 'undefined'
? window.innerWidth ? window.innerWidth - 48
: MOBILE_DEFAULT_CONTENT_WIDTH + : MOBILE_DEFAULT_CONTENT_WIDTH +
MOBILE_TIME_COLUMN_WIDTH; MOBILE_TIME_COLUMN_WIDTH;
@ -1160,17 +1122,7 @@ const WeeklySummaryPage = ({ userId }) => {
); );
const mobileUsersWidth = const mobileUsersWidth =
isAdmin && showAllUsers availableMobileUsersWidth;
? Math.max(
mobileUserCount *
MOBILE_USER_COLUMN_WIDTH,
MOBILE_DEFAULT_CONTENT_WIDTH,
availableMobileUsersWidth,
)
: Math.max(
MOBILE_DEFAULT_CONTENT_WIDTH,
availableMobileUsersWidth,
);
const mobilePlanningWidth = const mobilePlanningWidth =
MOBILE_TIME_COLUMN_WIDTH + MOBILE_TIME_COLUMN_WIDTH +
@ -1199,7 +1151,7 @@ const WeeklySummaryPage = ({ userId }) => {
icon={CalendarDays} icon={CalendarDays}
className={ className={
isMobile isMobile
? 'overflow-visible' ? 'overflow-hidden'
: 'overflow-hidden' : 'overflow-hidden'
} }
title={ title={
@ -1408,22 +1360,9 @@ const WeeklySummaryPage = ({ userId }) => {
<div <div
ref={scheduleTableRef} ref={scheduleTableRef}
className={`relative min-h-0 rounded-lg border ${ className="relative min-h-0 w-full shrink-0 overflow-hidden rounded-lg border"
isMobile
? 'flex-1 overflow-auto'
: 'overflow-x-auto overflow-y-hidden'
}`}
style={{ style={{
...(isMobile
? {}
: {
height: `${totalPlanningHeight}px`, height: `${totalPlanningHeight}px`,
maxHeight: `${totalPlanningHeight}px`,
}),
WebkitOverflowScrolling:
'touch',
touchAction:
'pan-x pan-y',
}} }}
> >
{/* ==================================================== {/* ====================================================
@ -1526,7 +1465,7 @@ const WeeklySummaryPage = ({ userId }) => {
<div <div
className="absolute inset-0 grid" className="absolute inset-0 grid"
style={{ style={{
gridTemplateColumns: `repeat(${mobileUserCount}, minmax(${MOBILE_USER_COLUMN_WIDTH}px, 1fr))`, gridTemplateColumns: `repeat(${mobileUserCount}, minmax(0, 1fr))`,
}} }}
> >
{mobileActiveUsers.map( {mobileActiveUsers.map(
@ -1732,10 +1671,10 @@ const WeeklySummaryPage = ({ userId }) => {
==================================================== */ ==================================================== */
<div <div
className="grid min-w-[900px]" className="grid w-full"
style={{ style={{
gridTemplateColumns: gridTemplateColumns:
'64px repeat(7, minmax(120px, 1fr))', '64px repeat(7, minmax(0, 1fr))',
gridTemplateRows: gridTemplateRows:
`${SCHEDULE_HEADER_HEIGHT}px ${scheduleHeight}px`, `${SCHEDULE_HEADER_HEIGHT}px ${scheduleHeight}px`,
height: `${totalPlanningHeight}px`, height: `${totalPlanningHeight}px`,