@jsb188/calendar 1.1.11 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,388 @@
1
+ import type {
2
+ ScheduleOccurrenceGQL,
3
+ ScheduleResourceGQL,
4
+ ScheduleTimeOffGQL,
5
+ ScheduleViolationGQL,
6
+ ScheduleSlotGQL,
7
+ } from '@jsb188/graphql/schedule.d';
8
+ import { DateTime } from 'luxon';
9
+ import type { CalendarDayObj } from '../types/calendar.d.ts';
10
+
11
+ type Breach = 'BLOCK' | 'WARN' | null;
12
+ type RosterPersonResource = Pick<
13
+ ScheduleResourceGQL,
14
+ 'id' | 'accountId' | 'name' | 'kind' | 'ordinal' | 'retiredAt'
15
+ >;
16
+ export interface RosterChipObj {
17
+ occurrenceId: string;
18
+ assignmentId: string | null;
19
+ slotKey: string | null;
20
+ title: string;
21
+ roomId: string | null;
22
+ roomName: string | null;
23
+ startLabel: string;
24
+ endLabel: string;
25
+ status: string;
26
+ overnight: boolean;
27
+ breach: Breach;
28
+ isMine: boolean;
29
+ version: string;
30
+ }
31
+ export interface RosterCellObj {
32
+ dateKey: string;
33
+ chips: RosterChipObj[];
34
+ timeOff: ScheduleTimeOffGQL | null;
35
+ minutes: number;
36
+ openCount: number;
37
+ breach: Breach;
38
+ }
39
+ export interface RosterRowObj {
40
+ key: string;
41
+ kind: 'GROUP' | 'OPEN' | 'PERSON';
42
+ roomId: string | null;
43
+ resourceId: string | null;
44
+ accountId: string | null;
45
+ name: string;
46
+ cells: RosterCellObj[];
47
+ weekMinutes: number;
48
+ breach: Breach;
49
+ }
50
+ export interface RosterLayoutObj {
51
+ rows: RosterRowObj[];
52
+ days: {
53
+ dateKey: string;
54
+ label: string;
55
+ staffCount: number;
56
+ openCount: number;
57
+ breach: Breach;
58
+ }[];
59
+ openTotal: number;
60
+ breachTotal: number;
61
+ }
62
+
63
+ /* Keep the most severe issue when several independent rules touch one cell. */
64
+ function worst(a: Breach, b: Breach): Breach {
65
+ return a === 'BLOCK' || b === 'BLOCK' ? 'BLOCK' : a || b;
66
+ }
67
+
68
+ /* Build one people-by-day roster with stable primary-room grouping and start-date overnight chips. */
69
+ export function buildRosterLayout(p: {
70
+ days: CalendarDayObj[];
71
+ timeZone: string;
72
+ locale: string | null;
73
+ resources: ScheduleResourceGQL[];
74
+ rooms: ScheduleResourceGQL[];
75
+ occurrences: ScheduleOccurrenceGQL[];
76
+ timeOff: ScheduleTimeOffGQL[];
77
+ violations: ScheduleViolationGQL[];
78
+ groupByRoom: boolean;
79
+ roomFilterId: string | null;
80
+ mineOnly: boolean;
81
+ viewerAccountId: string | null;
82
+ viewerResourceId: string | null;
83
+ formatTime: (at: Date, timeZone: string) => string;
84
+ }): RosterLayoutObj {
85
+ const resourceById = new Map<string, RosterPersonResource>(
86
+ p.resources.map((resource) => [resource.id, resource]),
87
+ );
88
+ // Shared-calendar assignments carry display identity without exposing another organization's resource catalog.
89
+ for (const occurrence of p.occurrences)
90
+ for (const assignment of occurrence.assignments)
91
+ if (
92
+ assignment.status === 'ASSIGNED' &&
93
+ !resourceById.has(assignment.resourceId)
94
+ )
95
+ resourceById.set(assignment.resourceId, {
96
+ id: assignment.resourceId,
97
+ accountId: assignment.accountId,
98
+ name: assignment.resourceName || assignment.resourceId,
99
+ kind: 'LABOR',
100
+ ordinal: Number.MAX_SAFE_INTEGER,
101
+ retiredAt: null,
102
+ });
103
+ const dayIndex = new Map(p.days.map((day, index) => [day.dateKey, index]));
104
+ const rooms = [...p.rooms].sort(
105
+ (a, b) => a.ordinal - b.ordinal || a.name.localeCompare(b.name),
106
+ );
107
+ const roomById = new Map(rooms.map((room) => [room.id, room]));
108
+ const dayStaff = p.days.map(() => new Set<string>());
109
+ const result: RosterLayoutObj = {
110
+ rows: [],
111
+ days: p.days.map((day) => ({
112
+ dateKey: day.dateKey,
113
+ label: DateTime.fromJSDate(day.startAt, { zone: p.timeZone })
114
+ .setLocale(p.locale || 'en')
115
+ .toFormat('ccc d'),
116
+ staffCount: 0,
117
+ openCount: 0,
118
+ breach: null,
119
+ })),
120
+ openTotal: 0,
121
+ breachTotal: p.violations.length,
122
+ };
123
+ /* Create one row with independent cells, so mutations never alias another person's day. */
124
+ const row = (
125
+ kind: RosterRowObj['kind'],
126
+ key: string,
127
+ roomId: string | null,
128
+ resource?: RosterPersonResource,
129
+ ): RosterRowObj => ({
130
+ key,
131
+ kind,
132
+ roomId,
133
+ resourceId: resource?.id || null,
134
+ accountId: resource?.accountId || null,
135
+ name: resource?.name || '',
136
+ cells: p.days.map((day) => ({
137
+ dateKey: day.dateKey,
138
+ chips: [],
139
+ timeOff: null,
140
+ minutes: 0,
141
+ openCount: 0,
142
+ breach: null,
143
+ })),
144
+ weekMinutes: 0,
145
+ breach: null,
146
+ });
147
+ const people = new Map(
148
+ [...resourceById.values()]
149
+ .filter((resource) => resource.kind === 'LABOR')
150
+ .map((resource) => [
151
+ resource.id,
152
+ row('PERSON', resource.id, null, resource),
153
+ ]),
154
+ );
155
+ const roomMinutes = new Map<string, Map<string, number>>();
156
+ const openRows = new Map<string, RosterRowObj>();
157
+ const byOccurrence = new Map<string, Breach>();
158
+ const byResource = new Map<string, Breach>();
159
+ for (const violation of p.violations) {
160
+ if (violation.occurrenceId)
161
+ byOccurrence.set(
162
+ violation.occurrenceId,
163
+ worst(
164
+ byOccurrence.get(violation.occurrenceId) || null,
165
+ violation.severity,
166
+ ),
167
+ );
168
+ if (violation.resourceId)
169
+ byResource.set(
170
+ violation.resourceId,
171
+ worst(byResource.get(violation.resourceId) || null, violation.severity),
172
+ );
173
+ for (let i = 0; i < p.days.length; i++)
174
+ if (
175
+ +new Date(violation.startAt) < +p.days[i].endAt &&
176
+ +new Date(violation.endAt) > +p.days[i].startAt
177
+ )
178
+ result.days[i].breach = worst(
179
+ result.days[i].breach,
180
+ violation.severity,
181
+ );
182
+ }
183
+ for (const occurrence of p.occurrences) {
184
+ if (p.roomFilterId && occurrence.resourceId !== p.roomFilterId) continue;
185
+ const start = new Date(occurrence.startAt),
186
+ end = new Date(occurrence.endAt);
187
+ const dateKey = DateTime.fromJSDate(start, {
188
+ zone: p.timeZone,
189
+ }).toISODate()!;
190
+ const index = dayIndex.get(dateKey);
191
+ if (index === undefined) continue;
192
+ const roomId = occurrence.resourceId,
193
+ groupKey = p.groupByRoom ? roomId || '' : '';
194
+ const active = occurrence.status !== 'CANCELED';
195
+ const assignments = occurrence.assignments.filter(
196
+ (assignment) => assignment.status === 'ASSIGNED',
197
+ );
198
+ /* Share immutable chip fields while keeping assignment identities distinct. */
199
+ const chip = (
200
+ assignmentId: string | null,
201
+ slotKey: string | null,
202
+ isMine: boolean,
203
+ ): RosterChipObj => ({
204
+ occurrenceId: occurrence.id,
205
+ assignmentId,
206
+ slotKey,
207
+ title: occurrence.title,
208
+ roomId,
209
+ roomName: roomById.get(roomId || '')?.name || null,
210
+ startLabel: p.formatTime(start, p.timeZone),
211
+ endLabel: p.formatTime(end, p.timeZone),
212
+ status: occurrence.status,
213
+ overnight:
214
+ DateTime.fromJSDate(end, { zone: p.timeZone }).toISODate() !== dateKey,
215
+ breach: byOccurrence.get(occurrence.id) || null,
216
+ isMine,
217
+ version: occurrence.version,
218
+ });
219
+ for (const assignment of assignments) {
220
+ const person = people.get(assignment.resourceId);
221
+ if (!person) continue;
222
+ const isMine =
223
+ (assignment.accountId === p.viewerAccountId && !!p.viewerAccountId) ||
224
+ assignment.resourceId === p.viewerResourceId;
225
+ person.cells[index].chips.push(
226
+ chip(assignment.id, assignment.slotKey, isMine),
227
+ );
228
+ person.breach = worst(
229
+ person.breach,
230
+ worst(
231
+ byResource.get(assignment.resourceId) || null,
232
+ byOccurrence.get(occurrence.id) || null,
233
+ ),
234
+ );
235
+ if (active) {
236
+ const minutes = Math.max(
237
+ 0,
238
+ (Math.min(+end, +p.days[p.days.length - 1].endAt) -
239
+ Math.max(+start, +p.days[0].startAt)) /
240
+ 60000,
241
+ );
242
+ person.weekMinutes += minutes;
243
+ person.cells[index].minutes += minutes;
244
+ dayStaff[index].add(assignment.resourceId);
245
+ const totals = roomMinutes.get(assignment.resourceId) || new Map();
246
+ totals.set(roomId || '', (totals.get(roomId || '') || 0) + minutes);
247
+ roomMinutes.set(assignment.resourceId, totals);
248
+ }
249
+ }
250
+ if (active && occurrence.kind === 'SHIFT' && occurrence.openCount > 0) {
251
+ const open =
252
+ openRows.get(groupKey) ||
253
+ row('OPEN', `open:${groupKey}`, p.groupByRoom ? roomId : null);
254
+ openRows.set(groupKey, open);
255
+ open.cells[index].openCount += occurrence.openCount;
256
+ open.cells[index].chips.push(chip(null, null, false));
257
+ open.cells[index].breach = worst(
258
+ open.cells[index].breach,
259
+ byOccurrence.get(occurrence.id) || byResource.get(roomId || '') || null,
260
+ );
261
+ result.days[index].openCount += occurrence.openCount;
262
+ result.openTotal += occurrence.openCount;
263
+ }
264
+ }
265
+ const timeOffByResource = new Map<string, ScheduleTimeOffGQL[]>();
266
+ for (const timeOff of p.timeOff)
267
+ if (['PENDING', 'APPROVED'].includes(timeOff.status)) {
268
+ const list = timeOffByResource.get(timeOff.resourceId) || [];
269
+ list.push(timeOff);
270
+ timeOffByResource.set(timeOff.resourceId, list);
271
+ }
272
+ const visiblePeople = [...people.values()]
273
+ .filter((person) => {
274
+ const resource = resourceById.get(person.resourceId!)!;
275
+ const hasChip = person.cells.some((cell) => cell.chips.length);
276
+ if (resource.retiredAt && !hasChip) return false;
277
+ if (
278
+ p.mineOnly &&
279
+ resource.id !== p.viewerResourceId &&
280
+ resource.accountId !== p.viewerAccountId
281
+ )
282
+ return false;
283
+ if (
284
+ p.roomFilterId &&
285
+ !hasChip &&
286
+ p.occurrences.some((occurrence) =>
287
+ occurrence.assignments.some(
288
+ (assignment) => assignment.resourceId === resource.id,
289
+ ),
290
+ )
291
+ )
292
+ return false;
293
+ const totals = [...(roomMinutes.get(resource.id) || [])].sort(
294
+ (a, b) =>
295
+ b[1] - a[1] ||
296
+ (roomById.get(a[0])?.ordinal ?? Infinity) -
297
+ (roomById.get(b[0])?.ordinal ?? Infinity) ||
298
+ a[0].localeCompare(b[0]),
299
+ );
300
+ person.roomId = totals[0]?.[0] || null;
301
+ person.breach = worst(person.breach, byResource.get(resource.id) || null);
302
+ person.cells.forEach((cell, i) => {
303
+ cell.timeOff =
304
+ (timeOffByResource.get(resource.id) || [])
305
+ .filter(
306
+ (timeOff) =>
307
+ +new Date(timeOff.startAt) < +p.days[i].endAt &&
308
+ +new Date(timeOff.endAt) > +p.days[i].startAt,
309
+ )
310
+ .sort(
311
+ (a, b) =>
312
+ Number(b.status === 'APPROVED') -
313
+ Number(a.status === 'APPROVED'),
314
+ )[0] || null;
315
+ });
316
+ return true;
317
+ })
318
+ .sort(
319
+ (a, b) =>
320
+ resourceById.get(a.resourceId!)!.ordinal -
321
+ resourceById.get(b.resourceId!)!.ordinal ||
322
+ a.name.localeCompare(b.name),
323
+ );
324
+ if (p.groupByRoom) {
325
+ for (const roomId of [...rooms.map((room) => room.id), '']) {
326
+ if (p.roomFilterId && roomId !== p.roomFilterId) continue;
327
+ const members = visiblePeople.filter(
328
+ (person) => (person.roomId || '') === roomId,
329
+ );
330
+ if (!members.length && !openRows.has(roomId)) continue;
331
+ const group = row('GROUP', `group:${roomId}`, roomId || null);
332
+ group.name = roomById.get(roomId)?.name || '';
333
+ group.breach = byResource.get(roomId) || null;
334
+ result.rows.push(
335
+ group,
336
+ openRows.get(roomId) || row('OPEN', `open:${roomId}`, roomId || null),
337
+ ...members,
338
+ );
339
+ }
340
+ } else
341
+ result.rows = [
342
+ openRows.get('') || row('OPEN', 'open:', null),
343
+ ...visiblePeople,
344
+ ];
345
+ result.days.forEach((day, i) => {
346
+ day.staffCount = dayStaff[i].size;
347
+ });
348
+ return result;
349
+ }
350
+
351
+ /* Give instant picker hints; the server still decides final cross-calendar eligibility. */
352
+ export function getRosterCandidateHints(p: {
353
+ resource: ScheduleResourceGQL;
354
+ occurrence: ScheduleOccurrenceGQL;
355
+ slot: ScheduleSlotGQL | null;
356
+ dayChips: RosterChipObj[];
357
+ timeOff: ScheduleTimeOffGQL[];
358
+ }) {
359
+ const predicate = p.slot?.predicate;
360
+ return {
361
+ predicateMatch:
362
+ !predicate ||
363
+ ((predicate.roles || []).every((role) =>
364
+ p.resource.config.roles.includes(role),
365
+ ) &&
366
+ (predicate.tags || []).every((tag) =>
367
+ p.resource.config.tags.includes(tag),
368
+ ) &&
369
+ (predicate.qualifications || []).every((key) =>
370
+ p.resource.config.qualifications.some((q) => q.key === key),
371
+ )),
372
+ sameDayOverlap: p.dayChips.some(
373
+ (chip) => chip.occurrenceId !== p.occurrence.id,
374
+ ),
375
+ onTimeOff: p.timeOff.some(
376
+ (row) =>
377
+ row.resourceId === p.resource.id &&
378
+ row.status === 'APPROVED' &&
379
+ row.startAt < p.occurrence.endAt &&
380
+ row.endAt > p.occurrence.startAt,
381
+ ),
382
+ alreadyAssigned: p.occurrence.assignments.some(
383
+ (assignment) =>
384
+ assignment.status === 'ASSIGNED' &&
385
+ assignment.resourceId === p.resource.id,
386
+ ),
387
+ };
388
+ }
@@ -1,6 +1,6 @@
1
1
  import { cn } from '@jsb188/app/utils/string.ts';
2
2
  import { DateTime } from 'luxon';
3
- import { useAtom, useAtomValue } from 'jotai';
3
+ import { useAtom } from 'jotai';
4
4
  import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
5
  import {
6
6
  CALENDAR_GUTTER_WIDTH,
@@ -31,9 +31,7 @@ import {
31
31
  normalizeCalendarWeekStartsOn,
32
32
  } from '../libs/calendar-range.ts';
33
33
  import {
34
- applyCalendarOptimisticOverlays,
35
34
  createCalendarStateAtoms,
36
- getCalendarStateScopeKey,
37
35
  type CalendarStateAtoms,
38
36
  } from '../libs/calendar-state.ts';
39
37
  import type { CalendarEventObj } from '../types/calendar.d.ts';
@@ -108,12 +106,15 @@ export function Calendar(p: CalendarProps) {
108
106
  // Created in a ref, never inline in the render body: creating atoms inline
109
107
  // would hand every render a fresh bag and reset all state
110
108
  if (!stateAtomsRef.current) {
111
- stateAtomsRef.current = createCalendarStateAtoms(
112
- getCalendarStateScopeKey(),
113
- );
109
+ stateAtomsRef.current = createCalendarStateAtoms();
114
110
  }
115
111
 
116
- return <CalendarContent {...p} stateAtoms={stateAtomsRef.current} />;
112
+ return (
113
+ <CalendarContent
114
+ {...p}
115
+ stateAtoms={stateAtomsRef.current}
116
+ />
117
+ );
117
118
  }
118
119
 
119
120
  type CalendarContentProps = CalendarProps & {
@@ -171,10 +172,8 @@ const CalendarContent = memo((p: CalendarContentProps) => {
171
172
  stateAtoms,
172
173
  } = p;
173
174
 
174
- const [popoverState, setPopoverState] = useAtom(stateAtoms.popoverStateAtom);
175
- const optimisticEvents = useAtomValue(stateAtoms.optimisticEventsAtom);
176
- const removedEventIds = useAtomValue(
177
- stateAtoms.optimisticallyRemovedEventIdsAtom,
175
+ const [selectedEventId, setSelectedEventId] = useAtom(
176
+ stateAtoms.selectedEventIdAtom,
178
177
  );
179
178
 
180
179
  // "now" ticks every minute to move the now line, but the range only uses it
@@ -191,15 +190,7 @@ const CalendarContent = memo((p: CalendarContentProps) => {
191
190
  );
192
191
 
193
192
  // One pass over the week per data change, not per subscriber
194
- const visibleEvents = useMemo(
195
- () =>
196
- applyCalendarOptimisticOverlays(
197
- events,
198
- optimisticEvents,
199
- removedEventIds,
200
- ),
201
- [events, optimisticEvents, removedEventIds],
202
- );
193
+ const visibleEvents = events;
203
194
 
204
195
  const isTimeGrid = !!CALENDAR_VIEW_DAY_COUNTS[view];
205
196
 
@@ -207,12 +198,23 @@ const CalendarContent = memo((p: CalendarContentProps) => {
207
198
  // running the overlap sweep over it to draw a grid that shows no events
208
199
  // would be pure waste on every render.
209
200
  const timedLayout = useMemo(
210
- () => (isTimeGrid ? getCalendarTimedLayout(visibleEvents, range.days) : []),
201
+ () =>
202
+ isTimeGrid
203
+ ? getCalendarTimedLayout(
204
+ visibleEvents.filter((event) => !event.allDay),
205
+ range.days,
206
+ )
207
+ : [],
211
208
  [isTimeGrid, visibleEvents, range.days],
212
209
  );
213
210
  const allDayBars = useMemo(
214
211
  () =>
215
- isTimeGrid ? getCalendarAllDayLayout(visibleEvents, range.days) : [],
212
+ isTimeGrid
213
+ ? getCalendarAllDayLayout(
214
+ visibleEvents.filter((event) => event.allDay),
215
+ range.days,
216
+ )
217
+ : [],
216
218
  [isTimeGrid, visibleEvents, range.days],
217
219
  );
218
220
  const monthCells = useMemo(
@@ -287,17 +289,11 @@ const CalendarContent = memo((p: CalendarContentProps) => {
287
289
 
288
290
  const handleSelectEvent = useCallback(
289
291
  (eventId: string) => {
290
- setPopoverState((current) =>
291
- // Clicking the open event again closes it, and returning the same
292
- // reference on a no-op keeps subscribers from re-rendering
293
- current?.eventId === eventId
294
- ? null
295
- : { eventId, anchorRect: { top: 0, left: 0, width: 0, height: 0 } },
296
- );
292
+ setSelectedEventId((current) => (current === eventId ? null : eventId));
297
293
 
298
294
  onSelectEvent?.(eventId);
299
295
  },
300
- [onSelectEvent, setPopoverState],
296
+ [onSelectEvent],
301
297
  );
302
298
 
303
299
  /*
@@ -599,8 +595,6 @@ const CalendarContent = memo((p: CalendarContentProps) => {
599
595
  CALENDAR_HOUR_HEIGHT
600
596
  : -1;
601
597
 
602
- const selectedEventId = popoverState?.eventId || null;
603
-
604
598
  // The ghost's own label, so a drag reads as a time range while it is being
605
599
  // drawn rather than as an unlabelled rectangle
606
600
  const draftTimeLabel = useMemo(() => {
@@ -266,7 +266,10 @@ export const MiniCalendar = memo((p: MiniCalendarProps) => {
266
266
  return (
267
267
  <div className={cn('unsel', className)}>
268
268
  {title || onStepMonth ? (
269
- <div className="h_spread" style={FILE_CONSTANTS.headerStyle}>
269
+ <div
270
+ className="h_spread"
271
+ style={FILE_CONSTANTS.headerStyle}
272
+ >
270
273
  <span className="f ellip ft_sm ft_bold cl_md">{title || ''}</span>
271
274
 
272
275
  {onStepMonth ? (
@@ -305,7 +308,7 @@ export const MiniCalendar = memo((p: MiniCalendarProps) => {
305
308
  {columnLabels.map((label, index) => (
306
309
  <div
307
310
  key={index}
308
- className="a_c ft_tn cl_lt"
311
+ className="a_c ft_xxs cl_lt"
309
312
  style={FILE_CONSTANTS.columnLabelStyle}
310
313
  >
311
314
  {label}
@@ -314,7 +317,10 @@ export const MiniCalendar = memo((p: MiniCalendarProps) => {
314
317
  </div>
315
318
 
316
319
  {weeks.map((week, weekIndex) => (
317
- <div key={weekIndex} style={FILE_CONSTANTS.gridStyle}>
320
+ <div
321
+ key={weekIndex}
322
+ style={FILE_CONSTANTS.gridStyle}
323
+ >
318
324
  {week.map((day, dayIndex) => {
319
325
  const isHighlighted = highlightedSet.has(day.dateKey);
320
326
  const isSelected = selectedSet.has(day.dateKey);
@@ -30,7 +30,13 @@ export interface CalendarEventObj {
30
30
  note?: string | null;
31
31
  color?: string | null;
32
32
  // Everyone working this entry, for the assignee chips and "my calendar only"
33
- assigneeAccountIds: string[];
33
+ assigneeResourceIds: string[];
34
+ assigneeNames?: string[];
35
+ roomId?: string | null;
36
+ roomName?: string | null;
37
+ breach?: 'BLOCK' | 'WARN' | null;
38
+ version?: string;
39
+ pending?: boolean;
34
40
  // How many people the entry still needs; drives the "open shift" treatment
35
41
  openCount?: number;
36
42
  // Set when the viewer is one of the assignees, so the grid can mark it
@@ -0,0 +1,19 @@
1
+ import type { ScheduleSlotInput } from '@jsb188/graphql/schedule.d';
2
+ export interface ShiftFormValues {
3
+ kind: 'SHIFT' | 'EVENT' | 'BLOCK';
4
+ title: string;
5
+ roomId: string;
6
+ start: string;
7
+ end: string;
8
+ allDay: boolean;
9
+ note: string;
10
+ location: string;
11
+ slots: ScheduleSlotInput[];
12
+ repeat: '' | 'DAILY' | 'WEEKLY' | 'MONTHLY';
13
+ interval: number;
14
+ weekdays: number[];
15
+ monthDay: number;
16
+ count: string;
17
+ until: string;
18
+ future: boolean;
19
+ }
@@ -3,6 +3,22 @@ import { memo } from 'react';
3
3
  import { CALENDAR_DRAFT_PATTERN_CLASS_NAME } from '../constants/calendar.ts';
4
4
  import type { CalendarEventObj } from '../types/calendar.d.ts';
5
5
 
6
+ const FILE_CONSTANTS = {
7
+ dayHeaderStyle: {
8
+ paddingLeft: 12,
9
+ paddingRight: 12,
10
+ paddingTop: 6,
11
+ paddingBottom: 2,
12
+ },
13
+ eventStyle: {
14
+ paddingLeft: 12,
15
+ paddingRight: 12,
16
+ paddingTop: 4,
17
+ paddingBottom: 4,
18
+ },
19
+ timeLabelStyle: { width: 104 },
20
+ };
21
+
6
22
  /**
7
23
  * The agenda ("Schedule") list.
8
24
  *
@@ -50,15 +66,13 @@ export const CalendarAgendaUI = memo((p: CalendarAgendaUIProps) => {
50
66
  return (
51
67
  <div className="f h_0 app_scr auto_y">
52
68
  {days.map((day) => (
53
- <div key={day.dateKey} className="bd_t_1 bd_t_bd">
69
+ <div
70
+ key={day.dateKey}
71
+ className="bd_t_1 bd_t_bd"
72
+ >
54
73
  <div
55
- className={cn('ft_tn', day.isToday ? 'ft_bold' : 'cl_lt')}
56
- style={{
57
- paddingLeft: 12,
58
- paddingRight: 12,
59
- paddingTop: 6,
60
- paddingBottom: 2,
61
- }}
74
+ className={cn('ft_xxs', day.isToday ? 'ft_bold' : 'cl_lt')}
75
+ style={FILE_CONSTANTS.dayHeaderStyle}
62
76
  >
63
77
  {day.label}
64
78
  </div>
@@ -72,22 +86,17 @@ export const CalendarAgendaUI = memo((p: CalendarAgendaUIProps) => {
72
86
  event.status === 'CANCELED' ? 'strikethrough' : '',
73
87
  selectedEventId === event.id ? 'bg_active' : '',
74
88
  )}
75
- style={{
76
- paddingLeft: 12,
77
- paddingRight: 12,
78
- paddingTop: 4,
79
- paddingBottom: 4,
80
- }}
89
+ style={FILE_CONSTANTS.eventStyle}
81
90
  onClick={() => onSelectEvent(event.id)}
82
91
  >
83
92
  <span
84
93
  className={cn(
85
- 'no_shrink ft_tn cl_lt rel of',
94
+ 'no_shrink ft_xxs cl_lt rel of',
86
95
  event.status === 'DRAFT'
87
96
  ? CALENDAR_DRAFT_PATTERN_CLASS_NAME
88
97
  : '',
89
98
  )}
90
- style={{ width: 104 }}
99
+ style={FILE_CONSTANTS.timeLabelStyle}
91
100
  >
92
101
  {timeLabelByEventId.get(event.id) || ''}
93
102
  </span>
@@ -95,7 +104,7 @@ export const CalendarAgendaUI = memo((p: CalendarAgendaUIProps) => {
95
104
  <span className="f ellip ft_sm">{event.title}</span>
96
105
 
97
106
  {event.isMine ? (
98
- <span className="no_shrink ft_tn cl_lt">•</span>
107
+ <span className="no_shrink ft_xxs cl_lt">•</span>
99
108
  ) : null}
100
109
  </button>
101
110
  ))}