Refactor large toolbox modules
All checks were successful
Deploy Sokko G / deploy (push) Successful in 16s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 16s
This commit is contained in:
parent
c2e37ad3f2
commit
6dd64f87c3
19 changed files with 2042 additions and 1659 deletions
|
|
@ -1,15 +1,11 @@
|
|||
// Rôle : fournit l'outil calendrier hebdomadaire/mensuel avec événements, récurrences et alertes.
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Icon } from "../../../components/Icon.jsx";
|
||||
import { CalendarEventForm } from "./CalendarEventForm.jsx";
|
||||
import { CalendarMonthView, CalendarWeekGrid } from "./CalendarViews.jsx";
|
||||
import { TextExchangeActions } from "./TextExchangeActions.jsx";
|
||||
import { CalendarContent } from "./CalendarContent.jsx";
|
||||
import {
|
||||
CALENDAR_ALERT_MODES,
|
||||
CALENDAR_COLORS,
|
||||
WEEK_SLOT_MINUTES,
|
||||
addDays,
|
||||
addMonths,
|
||||
formatLocalDateKey,
|
||||
getCalendarOccurrences,
|
||||
getLocalDayIndex,
|
||||
|
|
@ -391,88 +387,47 @@ export function CalendarModule({ toolboxId, moduleId, context, editing = false,
|
|||
);
|
||||
}
|
||||
|
||||
const selectedAlertOffsets = draft.alertMode === "off" ? [] : normalizeDraftAlertOffsets(draft.alertOffsetMinutes);
|
||||
|
||||
return (
|
||||
<div className="calendar-module" onKeyDown={handleKeyDown}>
|
||||
{formOpen && (
|
||||
<CalendarEventForm
|
||||
data={data}
|
||||
draft={draft}
|
||||
error={error}
|
||||
activeOccurrenceDate={activeOccurrenceDate}
|
||||
monthStart={monthStart}
|
||||
selectedAlertOffsets={selectedAlertOffsets}
|
||||
textContent={textContent}
|
||||
onSubmit={submitEvent}
|
||||
onDraftChange={updateDraft}
|
||||
onAlertModeChange={updateAlertMode}
|
||||
onAlertOffsetToggle={toggleAlertOffset}
|
||||
onDeleteEvent={deleteEvent}
|
||||
onDeleteOccurrence={deleteOccurrence}
|
||||
onClose={closeForm}
|
||||
onDisplayedMonthChange={setDisplayedMonth}
|
||||
/>
|
||||
)}
|
||||
{textExchangeOpen && (
|
||||
<div className="module-text-exchange-panel">
|
||||
<TextExchangeActions type="calendar" data={data} context={context} textContent={textContent} onImport={(nextData) => save(nextData)} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{data.viewMode === "week" && (
|
||||
<div className="calendar-week-options">
|
||||
<span>{textContent.hideEmptyHoursLabel || "Masquer les heures vides"}</span>
|
||||
<button
|
||||
className={`tool-split-scroll-toggle calendar-hide-hours-switch ${hideEmptyHours ? "active" : ""}`}
|
||||
type="button"
|
||||
onClick={() => setHideEmptyHours((current) => !current)}
|
||||
aria-pressed={hideEmptyHours}
|
||||
title={textContent.hideEmptyHoursLabel || "Masquer les heures vides"}
|
||||
>
|
||||
<Icon name={hideEmptyHours ? "eye-closed" : "eye-open"} />
|
||||
<i aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{data.viewMode === "month" ? (
|
||||
<CalendarMonthView
|
||||
monthStart={monthStart}
|
||||
monthGridDays={monthGridDays}
|
||||
occurrences={occurrences}
|
||||
textContent={textContent}
|
||||
activeEventId={activeEventId}
|
||||
selectedRange={formOpen ? { startDate: draft.startDate, endDate: draft.endDate || draft.startDate } : null}
|
||||
dragSelection={monthSelection}
|
||||
todayDate={formatLocalDateKey(now)}
|
||||
nowLabel={minutesToTimeValue(nowMinutes)}
|
||||
onPreviousMonth={() => setDisplayedMonth(getMonthStart(addMonths(monthStart, -1)))}
|
||||
onCurrentMonth={() => setDisplayedMonth(getMonthStart(new Date()))}
|
||||
onNextMonth={() => setDisplayedMonth(getMonthStart(addMonths(monthStart, 1)))}
|
||||
onPointerDown={handleMonthPointerDown}
|
||||
onPointerEnter={handleMonthPointerEnter}
|
||||
onPointerUp={() => setMonthSelection(null)}
|
||||
onEditEvent={editEvent}
|
||||
/>
|
||||
) : (
|
||||
<CalendarWeekGrid
|
||||
days={days}
|
||||
occurrences={occurrences}
|
||||
textContent={textContent}
|
||||
activeEventId={activeEventId}
|
||||
formOpen={formOpen}
|
||||
draftSelection={draftSelection}
|
||||
selection={selection}
|
||||
weekGridLayout={weekGridLayout}
|
||||
nowDayIndex={nowDayIndex}
|
||||
nowMinutes={nowMinutes}
|
||||
onSlotPointerDown={handleSlotPointerDown}
|
||||
onSlotPointerEnter={handleSlotPointerEnter}
|
||||
onSlotPointerUp={() => setSelection(null)}
|
||||
onEditEvent={editEvent}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<CalendarContent
|
||||
data={data}
|
||||
context={context}
|
||||
draft={{ ...draft, alertOffsetMinutes: draft.alertMode === "off" ? [] : normalizeDraftAlertOffsets(draft.alertOffsetMinutes) }}
|
||||
error={error}
|
||||
activeOccurrenceDate={activeOccurrenceDate}
|
||||
monthStart={monthStart}
|
||||
monthGridDays={monthGridDays}
|
||||
occurrences={occurrences}
|
||||
textContent={textContent}
|
||||
activeEventId={activeEventId}
|
||||
formOpen={formOpen}
|
||||
draftSelection={draftSelection}
|
||||
selection={selection}
|
||||
monthSelection={monthSelection}
|
||||
days={days}
|
||||
weekGridLayout={weekGridLayout}
|
||||
now={now}
|
||||
nowDayIndex={nowDayIndex}
|
||||
nowMinutes={nowMinutes}
|
||||
hideEmptyHours={hideEmptyHours}
|
||||
textExchangeOpen={textExchangeOpen}
|
||||
onKeyDown={handleKeyDown}
|
||||
onSubmit={submitEvent}
|
||||
onDraftChange={updateDraft}
|
||||
onAlertModeChange={updateAlertMode}
|
||||
onAlertOffsetToggle={toggleAlertOffset}
|
||||
onDeleteEvent={deleteEvent}
|
||||
onDeleteOccurrence={deleteOccurrence}
|
||||
onClose={closeForm}
|
||||
onDisplayedMonthChange={setDisplayedMonth}
|
||||
onImport={(nextData) => save(nextData)}
|
||||
onHideEmptyHoursToggle={() => setHideEmptyHours((current) => !current)}
|
||||
onMonthPointerDown={handleMonthPointerDown}
|
||||
onMonthPointerEnter={handleMonthPointerEnter}
|
||||
onMonthPointerUp={() => setMonthSelection(null)}
|
||||
onSlotPointerDown={handleSlotPointerDown}
|
||||
onSlotPointerEnter={handleSlotPointerEnter}
|
||||
onSlotPointerUp={() => setSelection(null)}
|
||||
onEditEvent={editEvent}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue