@open-mercato/core 0.5.1-develop.2996.ce62fd491c → 0.5.1-develop.3036.f02c281f23

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.
Files changed (81) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/modules/auth/api/sidebar/preferences/route.js +2 -2
  3. package/dist/modules/auth/api/sidebar/preferences/route.js.map +2 -2
  4. package/dist/modules/auth/api/sidebar/variants/[id]/route.js +2 -2
  5. package/dist/modules/auth/api/sidebar/variants/[id]/route.js.map +2 -2
  6. package/dist/modules/auth/api/sidebar/variants/route.js +1 -1
  7. package/dist/modules/auth/api/sidebar/variants/route.js.map +2 -2
  8. package/dist/modules/auth/backend/sidebar-customization/page.meta.js +1 -0
  9. package/dist/modules/auth/backend/sidebar-customization/page.meta.js.map +2 -2
  10. package/dist/modules/customers/api/companies/[id]/route.js +30 -20
  11. package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
  12. package/dist/modules/customers/api/companies/route.js +12 -7
  13. package/dist/modules/customers/api/companies/route.js.map +2 -2
  14. package/dist/modules/customers/api/people/[id]/companies/enriched/route.js +12 -7
  15. package/dist/modules/customers/api/people/[id]/companies/enriched/route.js.map +2 -2
  16. package/dist/modules/customers/api/people/route.js +12 -7
  17. package/dist/modules/customers/api/people/route.js.map +2 -2
  18. package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js +21 -0
  19. package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js.map +2 -2
  20. package/dist/modules/customers/backend/customers/people-v2/[id]/page.js +27 -30
  21. package/dist/modules/customers/backend/customers/people-v2/[id]/page.js.map +2 -2
  22. package/dist/modules/customers/components/detail/ActivitiesAddNewMenu.js +56 -0
  23. package/dist/modules/customers/components/detail/ActivitiesAddNewMenu.js.map +7 -0
  24. package/dist/modules/customers/components/detail/ActivitiesCard.js +175 -0
  25. package/dist/modules/customers/components/detail/ActivitiesCard.js.map +7 -0
  26. package/dist/modules/customers/components/detail/ActivitiesDayStrip.js +324 -0
  27. package/dist/modules/customers/components/detail/ActivitiesDayStrip.js.map +7 -0
  28. package/dist/modules/customers/components/detail/ActivitiesSection.js +62 -13
  29. package/dist/modules/customers/components/detail/ActivitiesSection.js.map +2 -2
  30. package/dist/modules/customers/components/detail/ActivityLogTab.js +14 -23
  31. package/dist/modules/customers/components/detail/ActivityLogTab.js.map +2 -2
  32. package/dist/modules/customers/components/detail/ActivityTimeline.js +13 -13
  33. package/dist/modules/customers/components/detail/ActivityTimeline.js.map +2 -2
  34. package/dist/modules/customers/components/detail/ActivityTimelineFilters.js +35 -22
  35. package/dist/modules/customers/components/detail/ActivityTimelineFilters.js.map +2 -2
  36. package/dist/modules/customers/components/detail/AiActionChips.js +15 -22
  37. package/dist/modules/customers/components/detail/AiActionChips.js.map +2 -2
  38. package/dist/modules/customers/components/detail/ScheduleActivityDialog.js +196 -28
  39. package/dist/modules/customers/components/detail/ScheduleActivityDialog.js.map +2 -2
  40. package/dist/modules/customers/components/detail/schedule/DateTimeFields.js +2 -2
  41. package/dist/modules/customers/components/detail/schedule/DateTimeFields.js.map +2 -2
  42. package/dist/modules/customers/components/detail/schedule/FooterFields.js +14 -2
  43. package/dist/modules/customers/components/detail/schedule/FooterFields.js.map +2 -2
  44. package/dist/modules/customers/components/detail/schedule/LinkedEntitiesField.js +9 -2
  45. package/dist/modules/customers/components/detail/schedule/LinkedEntitiesField.js.map +2 -2
  46. package/dist/modules/customers/components/detail/schedule/ParticipantsField.js +9 -2
  47. package/dist/modules/customers/components/detail/schedule/ParticipantsField.js.map +2 -2
  48. package/dist/modules/customers/components/detail/schedule/fieldConfig.js +25 -4
  49. package/dist/modules/customers/components/detail/schedule/fieldConfig.js.map +2 -2
  50. package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js +20 -3
  51. package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js.map +2 -2
  52. package/package.json +3 -3
  53. package/src/modules/auth/api/sidebar/preferences/route.ts +2 -2
  54. package/src/modules/auth/api/sidebar/variants/[id]/route.ts +2 -2
  55. package/src/modules/auth/api/sidebar/variants/route.ts +1 -1
  56. package/src/modules/auth/backend/sidebar-customization/page.meta.ts +1 -8
  57. package/src/modules/customers/api/companies/[id]/route.ts +30 -20
  58. package/src/modules/customers/api/companies/route.ts +12 -7
  59. package/src/modules/customers/api/people/[id]/companies/enriched/route.ts +12 -7
  60. package/src/modules/customers/api/people/route.ts +12 -7
  61. package/src/modules/customers/backend/customers/companies-v2/[id]/page.tsx +22 -0
  62. package/src/modules/customers/backend/customers/people-v2/[id]/page.tsx +28 -21
  63. package/src/modules/customers/components/detail/ActivitiesAddNewMenu.tsx +67 -0
  64. package/src/modules/customers/components/detail/ActivitiesCard.tsx +231 -0
  65. package/src/modules/customers/components/detail/ActivitiesDayStrip.tsx +390 -0
  66. package/src/modules/customers/components/detail/ActivitiesSection.tsx +91 -40
  67. package/src/modules/customers/components/detail/ActivityLogTab.tsx +25 -23
  68. package/src/modules/customers/components/detail/ActivityTimeline.tsx +15 -19
  69. package/src/modules/customers/components/detail/ActivityTimelineFilters.tsx +36 -29
  70. package/src/modules/customers/components/detail/AiActionChips.tsx +17 -23
  71. package/src/modules/customers/components/detail/ScheduleActivityDialog.tsx +233 -41
  72. package/src/modules/customers/components/detail/schedule/DateTimeFields.tsx +6 -2
  73. package/src/modules/customers/components/detail/schedule/FooterFields.tsx +22 -2
  74. package/src/modules/customers/components/detail/schedule/LinkedEntitiesField.tsx +10 -2
  75. package/src/modules/customers/components/detail/schedule/ParticipantsField.tsx +10 -2
  76. package/src/modules/customers/components/detail/schedule/fieldConfig.ts +26 -6
  77. package/src/modules/customers/components/detail/schedule/useScheduleFormState.ts +32 -3
  78. package/src/modules/customers/i18n/de.json +69 -2
  79. package/src/modules/customers/i18n/en.json +69 -2
  80. package/src/modules/customers/i18n/es.json +69 -2
  81. package/src/modules/customers/i18n/pl.json +68 -1
@@ -0,0 +1,324 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { ChevronLeft, ChevronRight } from "lucide-react";
5
+ import { cn } from "@open-mercato/shared/lib/utils";
6
+ import { useT } from "@open-mercato/shared/lib/i18n/context";
7
+ import { readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
8
+ const VISIBLE_DAYS = 5;
9
+ const BUSYNESS_SLOTS = 10;
10
+ const SLOT_START_HOUR = 7;
11
+ const SLOT_END_HOUR = 22;
12
+ const DAY_LABEL_KEYS = [
13
+ [0, "customers.calendar.day.sun", "SUN"],
14
+ [1, "customers.calendar.day.mon", "MON"],
15
+ [2, "customers.calendar.day.tue", "TUE"],
16
+ [3, "customers.calendar.day.wed", "WED"],
17
+ [4, "customers.calendar.day.thu", "THU"],
18
+ [5, "customers.calendar.day.fri", "FRI"],
19
+ [6, "customers.calendar.day.sat", "SAT"]
20
+ ];
21
+ const MONTH_KEYS = [
22
+ [0, "customers.calendar.month.january", "January"],
23
+ [1, "customers.calendar.month.february", "February"],
24
+ [2, "customers.calendar.month.march", "March"],
25
+ [3, "customers.calendar.month.april", "April"],
26
+ [4, "customers.calendar.month.may", "May"],
27
+ [5, "customers.calendar.month.june", "June"],
28
+ [6, "customers.calendar.month.july", "July"],
29
+ [7, "customers.calendar.month.august", "August"],
30
+ [8, "customers.calendar.month.september", "September"],
31
+ [9, "customers.calendar.month.october", "October"],
32
+ [10, "customers.calendar.month.november", "November"],
33
+ [11, "customers.calendar.month.december", "December"]
34
+ ];
35
+ function startOfDay(date) {
36
+ const next = new Date(date);
37
+ next.setHours(0, 0, 0, 0);
38
+ return next;
39
+ }
40
+ function endOfDay(date) {
41
+ const next = new Date(date);
42
+ next.setHours(23, 59, 59, 999);
43
+ return next;
44
+ }
45
+ function isSameDay(a, b) {
46
+ return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
47
+ }
48
+ function isWeekend(date) {
49
+ const day = date.getDay();
50
+ return day === 0 || day === 6;
51
+ }
52
+ function addDays(date, delta) {
53
+ const next = new Date(date);
54
+ next.setDate(date.getDate() + delta);
55
+ return next;
56
+ }
57
+ function buildVisibleDays(anchor) {
58
+ const start = startOfDay(anchor);
59
+ return Array.from({ length: VISIBLE_DAYS }, (_, index) => addDays(start, index));
60
+ }
61
+ function anchorCenteredOn(focalDate) {
62
+ return startOfDay(addDays(focalDate, -Math.floor(VISIBLE_DAYS / 2)));
63
+ }
64
+ function emptyBusyness() {
65
+ return {
66
+ totalMinutes: 0,
67
+ eventCount: 0,
68
+ slots: Array(BUSYNESS_SLOTS).fill("empty")
69
+ };
70
+ }
71
+ function computeDayBusyness(events, day) {
72
+ if (events.length === 0) return emptyBusyness();
73
+ const dayStart = startOfDay(day).getTime();
74
+ const slotMs = (SLOT_END_HOUR - SLOT_START_HOUR) * 60 * 60 * 1e3 / BUSYNESS_SLOTS;
75
+ const slotMinutes = slotMs / 6e4;
76
+ const slotCounts = Array(BUSYNESS_SLOTS).fill(0);
77
+ const slotMinutesUsed = Array(BUSYNESS_SLOTS).fill(0);
78
+ let totalMinutes = 0;
79
+ let eventCount = 0;
80
+ for (const event of events) {
81
+ const startIso = event.scheduledAt ?? event.occurredAt ?? event.createdAt;
82
+ if (!startIso) continue;
83
+ const start = new Date(startIso);
84
+ if (Number.isNaN(start.getTime())) continue;
85
+ if (!isSameDay(start, day)) continue;
86
+ eventCount += 1;
87
+ const durationMinutes = typeof event.duration === "number" && event.duration > 0 ? event.duration : 30;
88
+ totalMinutes += durationMinutes;
89
+ const eventStartMs = start.getTime();
90
+ const eventEndMs = eventStartMs + durationMinutes * 6e4;
91
+ const slotsStartMs = dayStart + SLOT_START_HOUR * 60 * 60 * 1e3;
92
+ for (let slot = 0; slot < BUSYNESS_SLOTS; slot += 1) {
93
+ const slotStart = slotsStartMs + slot * slotMs;
94
+ const slotEnd = slotStart + slotMs;
95
+ const overlapStart = Math.max(slotStart, eventStartMs);
96
+ const overlapEnd = Math.min(slotEnd, eventEndMs);
97
+ const overlapMinutes = Math.max(0, (overlapEnd - overlapStart) / 6e4);
98
+ if (overlapMinutes <= 0) continue;
99
+ slotCounts[slot] += 1;
100
+ slotMinutesUsed[slot] += overlapMinutes;
101
+ }
102
+ }
103
+ const slots = slotCounts.map((count, index) => {
104
+ if (count === 0) return "empty";
105
+ if (count > 1) return "conflict";
106
+ const used = slotMinutesUsed[index];
107
+ if (used >= slotMinutes * 0.5) return "full";
108
+ return "partial";
109
+ });
110
+ return { totalMinutes, eventCount, slots };
111
+ }
112
+ function formatBusyLabel(busy, t) {
113
+ if (busy.eventCount === 0) return "";
114
+ const durationLabel = busy.totalMinutes < 60 ? t("customers.activities.calendar.minutesShort", "{minutes}m", { minutes: Math.max(Math.round(busy.totalMinutes), 1) }) : t("customers.activities.calendar.hoursShort", "{hours}h", { hours: Math.floor(busy.totalMinutes / 60) });
115
+ return t("customers.activities.calendar.eventsSummary", "{count} {countLabel} \xB7 {duration}", {
116
+ count: busy.eventCount,
117
+ countLabel: busy.eventCount === 1 ? t("customers.activities.calendar.eventSingular", "event") : t("customers.activities.calendar.eventPlural", "events"),
118
+ duration: durationLabel
119
+ });
120
+ }
121
+ function formatMonthLabel(date, t) {
122
+ const monthEntry = MONTH_KEYS.find(([index]) => index === date.getMonth());
123
+ const monthName = monthEntry ? t(monthEntry[1], monthEntry[2]) : "";
124
+ return t("customers.activities.calendar.monthYear", "{month} {year}", { month: monthName, year: date.getFullYear() });
125
+ }
126
+ function formatDayLabel(date, t) {
127
+ const entry = DAY_LABEL_KEYS.find(([index]) => index === date.getDay());
128
+ return entry ? t(entry[1], entry[2]) : "";
129
+ }
130
+ function ActivitiesDayStrip({ entityId, selectedDate, onSelectDate, refreshKey = 0 }) {
131
+ const t = useT();
132
+ const [anchor, setAnchor] = React.useState(() => anchorCenteredOn(selectedDate));
133
+ const [events, setEvents] = React.useState([]);
134
+ React.useEffect(() => {
135
+ setAnchor((current) => {
136
+ const days = buildVisibleDays(current);
137
+ const visible = days.some((day) => isSameDay(day, selectedDate));
138
+ if (visible) return current;
139
+ return anchorCenteredOn(selectedDate);
140
+ });
141
+ }, [selectedDate]);
142
+ const visibleDays = React.useMemo(() => buildVisibleDays(anchor), [anchor]);
143
+ const headerLabel = React.useMemo(() => formatMonthLabel(visibleDays[0], t), [visibleDays, t]);
144
+ React.useEffect(() => {
145
+ if (!entityId || visibleDays.length === 0) return;
146
+ const controller = new AbortController();
147
+ const fromIso = startOfDay(visibleDays[0]).toISOString();
148
+ const toIso = endOfDay(visibleDays[visibleDays.length - 1]).toISOString();
149
+ const params = new URLSearchParams({
150
+ entityId,
151
+ from: fromIso,
152
+ to: toIso,
153
+ limit: "100",
154
+ sortField: "scheduledAt",
155
+ sortDir: "asc",
156
+ excludeInteractionType: "task"
157
+ });
158
+ void (async () => {
159
+ try {
160
+ const payload = await readApiResultOrThrow(
161
+ `/api/customers/interactions?${params.toString()}`,
162
+ { signal: controller.signal }
163
+ );
164
+ setEvents(Array.isArray(payload?.items) ? payload.items : []);
165
+ } catch (err) {
166
+ if (err?.name !== "AbortError") {
167
+ console.warn("[ActivitiesDayStrip] failed to load interactions", err);
168
+ }
169
+ setEvents([]);
170
+ }
171
+ })();
172
+ return () => controller.abort();
173
+ }, [entityId, visibleDays, refreshKey]);
174
+ const todayDate = React.useMemo(() => startOfDay(/* @__PURE__ */ new Date()), []);
175
+ const handlePrev = React.useCallback(() => {
176
+ setAnchor((current) => addDays(current, -VISIBLE_DAYS));
177
+ }, []);
178
+ const handleNext = React.useCallback(() => {
179
+ setAnchor((current) => addDays(current, VISIBLE_DAYS));
180
+ }, []);
181
+ const handleHeaderPrev = React.useCallback(() => {
182
+ setAnchor((current) => {
183
+ const next = new Date(current);
184
+ next.setMonth(current.getMonth() - 1);
185
+ return startOfDay(next);
186
+ });
187
+ }, []);
188
+ const handleHeaderNext = React.useCallback(() => {
189
+ setAnchor((current) => {
190
+ const next = new Date(current);
191
+ next.setMonth(current.getMonth() + 1);
192
+ return startOfDay(next);
193
+ });
194
+ }, []);
195
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2.5 rounded-md px-3.5 py-3 w-full", children: [
196
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-1.5 rounded-md bg-muted px-1.5 py-1.5", children: [
197
+ /* @__PURE__ */ jsx(
198
+ "button",
199
+ {
200
+ type: "button",
201
+ onClick: handleHeaderPrev,
202
+ "aria-label": t("customers.activities.calendar.prevMonth", "Previous month"),
203
+ className: "flex size-6 items-center justify-center rounded-md border border-border bg-card shadow-xs hover:bg-accent/40",
204
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "size-4 text-foreground" })
205
+ }
206
+ ),
207
+ /* @__PURE__ */ jsx("span", { className: "flex-1 text-center text-sm font-medium leading-5 text-foreground", children: headerLabel }),
208
+ /* @__PURE__ */ jsx(
209
+ "button",
210
+ {
211
+ type: "button",
212
+ onClick: handleHeaderNext,
213
+ "aria-label": t("customers.activities.calendar.nextMonth", "Next month"),
214
+ className: "flex size-6 items-center justify-center rounded-md border border-border bg-card shadow-xs hover:bg-accent/40",
215
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "size-4 text-foreground" })
216
+ }
217
+ )
218
+ ] }),
219
+ /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-2", children: [
220
+ /* @__PURE__ */ jsx(
221
+ "button",
222
+ {
223
+ type: "button",
224
+ onClick: handlePrev,
225
+ "aria-label": t("customers.activities.calendar.prevWindow", "Previous days"),
226
+ className: "flex size-6 shrink-0 items-center justify-center rounded-md border border-border bg-card shadow-xs hover:bg-accent/40",
227
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "size-4 text-foreground" })
228
+ }
229
+ ),
230
+ /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-stretch justify-center gap-1", children: visibleDays.map((day) => {
231
+ const busy = computeDayBusyness(events, day);
232
+ const isSelected = isSameDay(day, selectedDate);
233
+ const isToday = isSameDay(day, todayDate);
234
+ const weekend = isWeekend(day);
235
+ const busyLabel = busy.eventCount > 0 ? formatBusyLabel(busy, t) : weekend ? t("customers.activities.calendar.weekend", "Weekend") : "";
236
+ return /* @__PURE__ */ jsx(
237
+ DayCard,
238
+ {
239
+ day,
240
+ isActive: isSelected,
241
+ isToday,
242
+ busyness: busy,
243
+ label: busyLabel,
244
+ dayName: formatDayLabel(day, t),
245
+ onSelect: () => onSelectDate(day)
246
+ },
247
+ day.toISOString()
248
+ );
249
+ }) }),
250
+ /* @__PURE__ */ jsx(
251
+ "button",
252
+ {
253
+ type: "button",
254
+ onClick: handleNext,
255
+ "aria-label": t("customers.activities.calendar.nextWindow", "Next days"),
256
+ className: "flex size-6 shrink-0 items-center justify-center rounded-md border border-border bg-card shadow-xs hover:bg-accent/40",
257
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "size-4 text-foreground" })
258
+ }
259
+ )
260
+ ] })
261
+ ] });
262
+ }
263
+ function DayCard({ day, isActive, isToday, busyness, label, dayName, onSelect }) {
264
+ const dayNumber = String(day.getDate()).padStart(2, "0");
265
+ return /* @__PURE__ */ jsxs(
266
+ "button",
267
+ {
268
+ type: "button",
269
+ onClick: onSelect,
270
+ "aria-pressed": isActive,
271
+ "aria-label": `${dayName} ${dayNumber}`,
272
+ className: cn(
273
+ "flex h-[104px] w-[101px] flex-col items-center gap-[6px] overflow-hidden rounded-[10px] border p-[12px] transition-colors",
274
+ isActive ? "border-transparent bg-foreground" : "border-border bg-card hover:border-foreground/40"
275
+ ),
276
+ children: [
277
+ /* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium leading-none tracking-[0.44px] text-muted-foreground", children: dayName }),
278
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-[5px]", children: [
279
+ /* @__PURE__ */ jsx(
280
+ "span",
281
+ {
282
+ className: cn(
283
+ "text-2xl font-semibold leading-7",
284
+ isActive ? "text-background" : "text-foreground"
285
+ ),
286
+ children: dayNumber
287
+ }
288
+ ),
289
+ isToday ? /* @__PURE__ */ jsx(
290
+ "span",
291
+ {
292
+ className: "inline-block size-1.5 rounded-full bg-status-info-icon",
293
+ "aria-hidden": true
294
+ }
295
+ ) : null
296
+ ] }),
297
+ /* @__PURE__ */ jsx("div", { className: "flex h-4 w-[82px] items-end gap-[1.5px]", children: busyness.slots.map((state, index) => /* @__PURE__ */ jsx(BusySlot, { state, active: isActive }, index)) }),
298
+ /* @__PURE__ */ jsx("span", { className: "text-[11px] leading-[14px] font-normal whitespace-nowrap text-muted-foreground", children: label })
299
+ ]
300
+ }
301
+ );
302
+ }
303
+ function BusySlot({ state, active }) {
304
+ const heightClass = state === "empty" ? "h-0.5" : state === "partial" ? "h-2" : "h-3.5";
305
+ let bgClass;
306
+ if (state === "conflict") {
307
+ bgClass = "bg-status-error-icon";
308
+ } else if (active) {
309
+ if (state === "empty") bgClass = "bg-background/30";
310
+ else if (state === "partial") bgClass = "bg-background/60";
311
+ else bgClass = "bg-background";
312
+ } else {
313
+ if (state === "empty") bgClass = "bg-border";
314
+ else if (state === "partial") bgClass = "bg-muted-foreground";
315
+ else bgClass = "bg-foreground";
316
+ }
317
+ return /* @__PURE__ */ jsx("div", { className: cn("w-[7px] shrink-0 rounded-[1.5px]", heightClass, bgClass), "aria-hidden": true });
318
+ }
319
+ var ActivitiesDayStrip_default = ActivitiesDayStrip;
320
+ export {
321
+ ActivitiesDayStrip,
322
+ ActivitiesDayStrip_default as default
323
+ };
324
+ //# sourceMappingURL=ActivitiesDayStrip.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/modules/customers/components/detail/ActivitiesDayStrip.tsx"],
4
+ "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { ChevronLeft, ChevronRight } from 'lucide-react'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { TranslateFn } from '@open-mercato/shared/lib/i18n/context'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport type { InteractionSummary } from './types'\n\ninterface ActivitiesDayStripProps {\n entityId: string\n selectedDate: Date\n onSelectDate: (date: Date) => void\n refreshKey?: number\n}\n\nconst VISIBLE_DAYS = 5\nconst BUSYNESS_SLOTS = 10\nconst SLOT_START_HOUR = 7\nconst SLOT_END_HOUR = 22\n\nconst DAY_LABEL_KEYS: Array<[number, string, string]> = [\n [0, 'customers.calendar.day.sun', 'SUN'],\n [1, 'customers.calendar.day.mon', 'MON'],\n [2, 'customers.calendar.day.tue', 'TUE'],\n [3, 'customers.calendar.day.wed', 'WED'],\n [4, 'customers.calendar.day.thu', 'THU'],\n [5, 'customers.calendar.day.fri', 'FRI'],\n [6, 'customers.calendar.day.sat', 'SAT'],\n]\n\nconst MONTH_KEYS: Array<[number, string, string]> = [\n [0, 'customers.calendar.month.january', 'January'],\n [1, 'customers.calendar.month.february', 'February'],\n [2, 'customers.calendar.month.march', 'March'],\n [3, 'customers.calendar.month.april', 'April'],\n [4, 'customers.calendar.month.may', 'May'],\n [5, 'customers.calendar.month.june', 'June'],\n [6, 'customers.calendar.month.july', 'July'],\n [7, 'customers.calendar.month.august', 'August'],\n [8, 'customers.calendar.month.september', 'September'],\n [9, 'customers.calendar.month.october', 'October'],\n [10, 'customers.calendar.month.november', 'November'],\n [11, 'customers.calendar.month.december', 'December'],\n]\n\nfunction startOfDay(date: Date): Date {\n const next = new Date(date)\n next.setHours(0, 0, 0, 0)\n return next\n}\n\nfunction endOfDay(date: Date): Date {\n const next = new Date(date)\n next.setHours(23, 59, 59, 999)\n return next\n}\n\nfunction isSameDay(a: Date, b: Date): boolean {\n return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate()\n}\n\nfunction isWeekend(date: Date): boolean {\n const day = date.getDay()\n return day === 0 || day === 6\n}\n\nfunction addDays(date: Date, delta: number): Date {\n const next = new Date(date)\n next.setDate(date.getDate() + delta)\n return next\n}\n\nfunction buildVisibleDays(anchor: Date): Date[] {\n const start = startOfDay(anchor)\n return Array.from({ length: VISIBLE_DAYS }, (_, index) => addDays(start, index))\n}\n\n// Anchor the visible window so that the given focal date lands at the center slot\n// (position 2 out of 5). Matches Figma 784:809 where the selected day is centered.\nfunction anchorCenteredOn(focalDate: Date): Date {\n return startOfDay(addDays(focalDate, -Math.floor(VISIBLE_DAYS / 2)))\n}\n\ntype SlotState = 'empty' | 'partial' | 'full' | 'conflict'\n\ntype DayBusyness = {\n totalMinutes: number\n eventCount: number\n slots: SlotState[]\n}\n\nfunction emptyBusyness(): DayBusyness {\n return {\n totalMinutes: 0,\n eventCount: 0,\n slots: Array<SlotState>(BUSYNESS_SLOTS).fill('empty'),\n }\n}\n\nfunction computeDayBusyness(events: InteractionSummary[], day: Date): DayBusyness {\n if (events.length === 0) return emptyBusyness()\n const dayStart = startOfDay(day).getTime()\n const slotMs = ((SLOT_END_HOUR - SLOT_START_HOUR) * 60 * 60 * 1000) / BUSYNESS_SLOTS\n const slotMinutes = slotMs / 60000\n const slotCounts: number[] = Array(BUSYNESS_SLOTS).fill(0)\n const slotMinutesUsed: number[] = Array(BUSYNESS_SLOTS).fill(0)\n let totalMinutes = 0\n let eventCount = 0\n\n for (const event of events) {\n const startIso = event.scheduledAt ?? event.occurredAt ?? event.createdAt\n if (!startIso) continue\n const start = new Date(startIso)\n if (Number.isNaN(start.getTime())) continue\n if (!isSameDay(start, day)) continue\n eventCount += 1\n const durationMinutes = typeof event.duration === 'number' && event.duration > 0 ? event.duration : 30\n totalMinutes += durationMinutes\n const eventStartMs = start.getTime()\n const eventEndMs = eventStartMs + durationMinutes * 60000\n const slotsStartMs = dayStart + SLOT_START_HOUR * 60 * 60 * 1000\n for (let slot = 0; slot < BUSYNESS_SLOTS; slot += 1) {\n const slotStart = slotsStartMs + slot * slotMs\n const slotEnd = slotStart + slotMs\n const overlapStart = Math.max(slotStart, eventStartMs)\n const overlapEnd = Math.min(slotEnd, eventEndMs)\n const overlapMinutes = Math.max(0, (overlapEnd - overlapStart) / 60000)\n if (overlapMinutes <= 0) continue\n slotCounts[slot] += 1\n slotMinutesUsed[slot] += overlapMinutes\n }\n }\n\n const slots: SlotState[] = slotCounts.map((count, index) => {\n if (count === 0) return 'empty'\n if (count > 1) return 'conflict'\n const used = slotMinutesUsed[index]\n if (used >= slotMinutes * 0.5) return 'full'\n return 'partial'\n })\n\n return { totalMinutes, eventCount, slots }\n}\n\nfunction formatBusyLabel(busy: DayBusyness, t: TranslateFn): string {\n if (busy.eventCount === 0) return ''\n // Match Figma 784:809 label format: \"Xm\" when under an hour, \"Xh\" otherwise.\n // Mixed \"Xh Ym\" overflows the 101px card and is not part of the visual spec.\n const durationLabel = busy.totalMinutes < 60\n ? t('customers.activities.calendar.minutesShort', '{minutes}m', { minutes: Math.max(Math.round(busy.totalMinutes), 1) })\n : t('customers.activities.calendar.hoursShort', '{hours}h', { hours: Math.floor(busy.totalMinutes / 60) })\n return t('customers.activities.calendar.eventsSummary', '{count} {countLabel} \u00B7 {duration}', {\n count: busy.eventCount,\n countLabel: busy.eventCount === 1\n ? t('customers.activities.calendar.eventSingular', 'event')\n : t('customers.activities.calendar.eventPlural', 'events'),\n duration: durationLabel,\n })\n}\n\nfunction formatMonthLabel(date: Date, t: TranslateFn): string {\n const monthEntry = MONTH_KEYS.find(([index]) => index === date.getMonth())\n const monthName = monthEntry ? t(monthEntry[1], monthEntry[2]) : ''\n return t('customers.activities.calendar.monthYear', '{month} {year}', { month: monthName, year: date.getFullYear() })\n}\n\nfunction formatDayLabel(date: Date, t: TranslateFn): string {\n const entry = DAY_LABEL_KEYS.find(([index]) => index === date.getDay())\n return entry ? t(entry[1], entry[2]) : ''\n}\n\nexport function ActivitiesDayStrip({ entityId, selectedDate, onSelectDate, refreshKey = 0 }: ActivitiesDayStripProps) {\n const t = useT()\n const [anchor, setAnchor] = React.useState<Date>(() => anchorCenteredOn(selectedDate))\n const [events, setEvents] = React.useState<InteractionSummary[]>([])\n\n React.useEffect(() => {\n setAnchor((current) => {\n const days = buildVisibleDays(current)\n const visible = days.some((day) => isSameDay(day, selectedDate))\n if (visible) return current\n return anchorCenteredOn(selectedDate)\n })\n }, [selectedDate])\n\n const visibleDays = React.useMemo(() => buildVisibleDays(anchor), [anchor])\n const headerLabel = React.useMemo(() => formatMonthLabel(visibleDays[0], t), [visibleDays, t])\n\n React.useEffect(() => {\n if (!entityId || visibleDays.length === 0) return\n const controller = new AbortController()\n const fromIso = startOfDay(visibleDays[0]).toISOString()\n const toIso = endOfDay(visibleDays[visibleDays.length - 1]).toISOString()\n const params = new URLSearchParams({\n entityId,\n from: fromIso,\n to: toIso,\n limit: '100',\n sortField: 'scheduledAt',\n sortDir: 'asc',\n excludeInteractionType: 'task',\n })\n void (async () => {\n try {\n const payload = await readApiResultOrThrow<{ items?: InteractionSummary[] }>(\n `/api/customers/interactions?${params.toString()}`,\n { signal: controller.signal },\n )\n setEvents(Array.isArray(payload?.items) ? payload.items : [])\n } catch (err) {\n if ((err as { name?: string } | null)?.name !== 'AbortError') {\n console.warn('[ActivitiesDayStrip] failed to load interactions', err)\n }\n setEvents([])\n }\n })()\n return () => controller.abort()\n }, [entityId, visibleDays, refreshKey])\n\n const todayDate = React.useMemo(() => startOfDay(new Date()), [])\n\n const handlePrev = React.useCallback(() => {\n setAnchor((current) => addDays(current, -VISIBLE_DAYS))\n }, [])\n const handleNext = React.useCallback(() => {\n setAnchor((current) => addDays(current, VISIBLE_DAYS))\n }, [])\n const handleHeaderPrev = React.useCallback(() => {\n setAnchor((current) => {\n const next = new Date(current)\n next.setMonth(current.getMonth() - 1)\n return startOfDay(next)\n })\n }, [])\n const handleHeaderNext = React.useCallback(() => {\n setAnchor((current) => {\n const next = new Date(current)\n next.setMonth(current.getMonth() + 1)\n return startOfDay(next)\n })\n }, [])\n\n return (\n <div className=\"flex flex-col gap-2.5 rounded-md px-3.5 py-3 w-full\">\n <div className=\"flex items-center justify-center gap-1.5 rounded-md bg-muted px-1.5 py-1.5\">\n <button\n type=\"button\"\n onClick={handleHeaderPrev}\n aria-label={t('customers.activities.calendar.prevMonth', 'Previous month')}\n className=\"flex size-6 items-center justify-center rounded-md border border-border bg-card shadow-xs hover:bg-accent/40\"\n >\n <ChevronLeft className=\"size-4 text-foreground\" />\n </button>\n <span className=\"flex-1 text-center text-sm font-medium leading-5 text-foreground\">{headerLabel}</span>\n <button\n type=\"button\"\n onClick={handleHeaderNext}\n aria-label={t('customers.activities.calendar.nextMonth', 'Next month')}\n className=\"flex size-6 items-center justify-center rounded-md border border-border bg-card shadow-xs hover:bg-accent/40\"\n >\n <ChevronRight className=\"size-4 text-foreground\" />\n </button>\n </div>\n <div className=\"flex w-full items-center gap-2\">\n <button\n type=\"button\"\n onClick={handlePrev}\n aria-label={t('customers.activities.calendar.prevWindow', 'Previous days')}\n className=\"flex size-6 shrink-0 items-center justify-center rounded-md border border-border bg-card shadow-xs hover:bg-accent/40\"\n >\n <ChevronLeft className=\"size-4 text-foreground\" />\n </button>\n <div className=\"flex flex-1 items-stretch justify-center gap-1\">\n {visibleDays.map((day) => {\n const busy = computeDayBusyness(events, day)\n const isSelected = isSameDay(day, selectedDate)\n const isToday = isSameDay(day, todayDate)\n const weekend = isWeekend(day)\n const busyLabel = busy.eventCount > 0\n ? formatBusyLabel(busy, t)\n : weekend\n ? t('customers.activities.calendar.weekend', 'Weekend')\n : ''\n return (\n <DayCard\n key={day.toISOString()}\n day={day}\n isActive={isSelected}\n isToday={isToday}\n busyness={busy}\n label={busyLabel}\n dayName={formatDayLabel(day, t)}\n onSelect={() => onSelectDate(day)}\n />\n )\n })}\n </div>\n <button\n type=\"button\"\n onClick={handleNext}\n aria-label={t('customers.activities.calendar.nextWindow', 'Next days')}\n className=\"flex size-6 shrink-0 items-center justify-center rounded-md border border-border bg-card shadow-xs hover:bg-accent/40\"\n >\n <ChevronRight className=\"size-4 text-foreground\" />\n </button>\n </div>\n </div>\n )\n}\n\ninterface DayCardProps {\n day: Date\n isActive: boolean\n isToday: boolean\n busyness: DayBusyness\n label: string\n dayName: string\n onSelect: () => void\n}\n\nfunction DayCard({ day, isActive, isToday, busyness, label, dayName, onSelect }: DayCardProps) {\n const dayNumber = String(day.getDate()).padStart(2, '0')\n return (\n <button\n type=\"button\"\n onClick={onSelect}\n aria-pressed={isActive}\n aria-label={`${dayName} ${dayNumber}`}\n className={cn(\n 'flex h-[104px] w-[101px] flex-col items-center gap-[6px] overflow-hidden rounded-[10px] border p-[12px] transition-colors',\n isActive\n ? 'border-transparent bg-foreground'\n : 'border-border bg-card hover:border-foreground/40',\n )}\n >\n <span className=\"text-[11px] font-medium leading-none tracking-[0.44px] text-muted-foreground\">\n {dayName}\n </span>\n <div className=\"flex items-center gap-[5px]\">\n <span\n className={cn(\n 'text-2xl font-semibold leading-7',\n isActive ? 'text-background' : 'text-foreground',\n )}\n >\n {dayNumber}\n </span>\n {isToday ? (\n <span\n className=\"inline-block size-1.5 rounded-full bg-status-info-icon\"\n aria-hidden\n />\n ) : null}\n </div>\n <div className=\"flex h-4 w-[82px] items-end gap-[1.5px]\">\n {busyness.slots.map((state, index) => (\n <BusySlot key={index} state={state} active={isActive} />\n ))}\n </div>\n <span className=\"text-[11px] leading-[14px] font-normal whitespace-nowrap text-muted-foreground\">\n {label}\n </span>\n </button>\n )\n}\n\nfunction BusySlot({ state, active }: { state: SlotState; active: boolean }) {\n const heightClass = state === 'empty'\n ? 'h-0.5'\n : state === 'partial'\n ? 'h-2'\n : 'h-3.5'\n let bgClass: string\n if (state === 'conflict') {\n bgClass = 'bg-status-error-icon'\n } else if (active) {\n if (state === 'empty') bgClass = 'bg-background/30'\n else if (state === 'partial') bgClass = 'bg-background/60'\n else bgClass = 'bg-background'\n } else {\n if (state === 'empty') bgClass = 'bg-border'\n else if (state === 'partial') bgClass = 'bg-muted-foreground'\n else bgClass = 'bg-foreground'\n }\n return <div className={cn('w-[7px] shrink-0 rounded-[1.5px]', heightClass, bgClass)} aria-hidden />\n}\n\nexport default ActivitiesDayStrip\n"],
5
+ "mappings": ";AAsPM,SAOI,KAPJ;A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AAA,QACA,oBAAC,SAAI,WAAU,2CACZ,mBAAS,MAAM,IAAI,CAAC,OAAO,UAC1B,oBAAC,YAAqB,OAAc,QAAQ,YAA7B,KAAuC,CACvD,GACH;AAAA,QACA,oBAAC,UAAK,WAAU,kFACb,iBACH;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,SAAS,SAAS,EAAE,OAAO,OAAO,GAA0C;AAC1E,QAAM,cAAc,UAAU,UAC1B,UACA,UAAU,YACR,QACA;AACN,MAAI;AACJ,MAAI,UAAU,YAAY;AACxB,cAAU;AAAA,EACZ,WAAW,QAAQ;AACjB,QAAI,UAAU,QAAS,WAAU;AAAA,aACxB,UAAU,UAAW,WAAU;AAAA,QACnC,WAAU;AAAA,EACjB,OAAO;AACL,QAAI,UAAU,QAAS,WAAU;AAAA,aACxB,UAAU,UAAW,WAAU;AAAA,QACnC,WAAU;AAAA,EACjB;AACA,SAAO,oBAAC,SAAI,WAAW,GAAG,oCAAoC,aAAa,OAAO,GAAG,eAAW,MAAC;AACnG;AAEA,IAAO,6BAAQ;",
6
+ "names": []
7
+ }
@@ -1,11 +1,12 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
- import { Clock } from "lucide-react";
4
+ import { Clock, Search } from "lucide-react";
5
5
  import { useT } from "@open-mercato/shared/lib/i18n/context";
6
6
  import { readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
7
7
  import { flash } from "@open-mercato/ui/backend/FlashMessages";
8
8
  import { Button } from "@open-mercato/ui/primitives/button";
9
+ import { Kbd } from "@open-mercato/ui/primitives/kbd";
9
10
  import { ActivityTimelineFilters } from "./ActivityTimelineFilters.js";
10
11
  import { ActivityTimeline } from "./ActivityTimeline.js";
11
12
  function toDateOnly(value) {
@@ -77,10 +78,37 @@ function ActivitiesSection({
77
78
  const [filterTypes, setFilterTypes] = React.useState([]);
78
79
  const [filterDateFrom, setFilterDateFrom] = React.useState("");
79
80
  const [filterDateTo, setFilterDateTo] = React.useState("");
81
+ const [searchTerm, setSearchTerm] = React.useState("");
80
82
  const [activities, setActivities] = React.useState([]);
81
83
  const [loading, setLoading] = React.useState(false);
82
84
  const [hasMore, setHasMore] = React.useState(false);
83
85
  const [loadedPages, setLoadedPages] = React.useState(1);
86
+ const searchInputRef = React.useRef(null);
87
+ React.useEffect(() => {
88
+ if (!entityId) return;
89
+ function handleShortcut(event) {
90
+ if ((event.metaKey || event.ctrlKey) && event.key === "1") {
91
+ event.preventDefault();
92
+ searchInputRef.current?.focus();
93
+ }
94
+ }
95
+ window.addEventListener("keydown", handleShortcut);
96
+ return () => window.removeEventListener("keydown", handleShortcut);
97
+ }, [entityId]);
98
+ const visibleActivities = React.useMemo(() => {
99
+ const term = searchTerm.trim().toLowerCase();
100
+ if (!term) return activities;
101
+ return activities.filter((activity) => {
102
+ const haystack = [
103
+ activity.title,
104
+ activity.body,
105
+ activity.authorName,
106
+ activity.dealTitle,
107
+ activity.interactionType
108
+ ].filter((value) => typeof value === "string" && value.length > 0).join(" ").toLowerCase();
109
+ return haystack.includes(term);
110
+ });
111
+ }, [activities, searchTerm]);
84
112
  React.useEffect(() => {
85
113
  onActionChange?.(null);
86
114
  return () => onActionChange?.(null);
@@ -212,12 +240,30 @@ function ActivitiesSection({
212
240
  }).catch((err) => console.warn("[ActivitiesSection] resolve author names failed", err));
213
241
  return () => controller.abort();
214
242
  }, [activities]);
215
- return /* @__PURE__ */ jsxs("div", { className: "rounded-2xl border border-border/70 bg-card p-5", children: [
216
- /* @__PURE__ */ jsx("div", { className: "mb-4 flex flex-wrap items-center justify-between gap-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
217
- /* @__PURE__ */ jsx(Clock, { className: "size-4 text-muted-foreground" }),
218
- /* @__PURE__ */ jsx("h3", { className: "text-base font-semibold text-foreground", children: entityName ? t("customers.timeline.history.title", "Interaction history with {{name}}", { name: entityName }) : t("customers.timeline.history.titleGeneric", "Interaction history") })
219
- ] }) }),
220
- /* @__PURE__ */ jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsx(
243
+ const totalCount = activities.length;
244
+ const visibleCount = visibleActivities.length;
245
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3.5 rounded-[10px] border border-border bg-card pt-4 pb-[18px] px-[18px]", children: [
246
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
247
+ /* @__PURE__ */ jsx(Clock, { className: "size-[15px] text-muted-foreground" }),
248
+ /* @__PURE__ */ jsx("h3", { className: "text-[13px] font-semibold text-foreground", children: entityName ? t("customers.timeline.history.title", "Interaction history with {{name}}", { name: entityName }) : t("customers.timeline.history.titleGeneric", "Interaction history") })
249
+ ] }),
250
+ /* @__PURE__ */ jsxs("label", { className: "relative flex items-center", children: [
251
+ /* @__PURE__ */ jsx(Search, { className: "pointer-events-none absolute left-2.5 size-5 text-muted-foreground", "aria-hidden": true }),
252
+ /* @__PURE__ */ jsx(
253
+ "input",
254
+ {
255
+ ref: searchInputRef,
256
+ type: "search",
257
+ value: searchTerm,
258
+ onChange: (event) => setSearchTerm(event.target.value),
259
+ placeholder: t("customers.timeline.history.searchPlaceholder", "Search..."),
260
+ "aria-label": t("customers.timeline.history.searchAriaLabel", "Search interaction history"),
261
+ className: "h-9 w-full rounded-[10px] border border-border bg-card pl-9 pr-14 text-sm text-foreground shadow-xs placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden"
262
+ }
263
+ ),
264
+ /* @__PURE__ */ jsx(Kbd, { className: "pointer-events-none absolute right-2 hidden text-[11px] uppercase tracking-[0.48px] sm:inline-flex", children: "\u23181" })
265
+ ] }),
266
+ /* @__PURE__ */ jsx(
221
267
  ActivityTimelineFilters,
222
268
  {
223
269
  entityId,
@@ -233,13 +279,16 @@ function ActivitiesSection({
233
279
  setFilterDateTo("");
234
280
  }
235
281
  }
236
- ) }),
237
- loading && activities.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-dashed border-border/70 px-4 py-8 text-sm text-muted-foreground", children: t("customers.people.detail.activities.loading", "Loading activities\u2026") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
238
- /* @__PURE__ */ jsx(ActivityTimeline, { activities, onEdit: onEditActivity }),
239
- activities.length > 0 ? /* @__PURE__ */ jsx("div", { className: "border-t px-5 py-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
240
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("customers.activities.seeAll", "See all {count} activities", { count: activities.length }) }),
282
+ ),
283
+ loading && totalCount === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-dashed border-border/70 px-4 py-8 text-sm text-muted-foreground", children: t("customers.people.detail.activities.loading", "Loading activities\u2026") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
284
+ /* @__PURE__ */ jsx(ActivityTimeline, { activities: visibleActivities, onEdit: onEditActivity }),
285
+ totalCount > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 border-t border-border/60 pt-3", children: [
286
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: searchTerm.trim() ? t("customers.activities.seeMatching", "Showing {visible} of {total} activities", {
287
+ visible: visibleCount,
288
+ total: totalCount
289
+ }) : t("customers.activities.seeAll", "See all {count} activities", { count: totalCount }) }),
241
290
  hasMore ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "link", size: "sm", onClick: () => setLoadedPages((value) => value + 1), children: t("customers.activities.loadMore", "Load more") }) : null
242
- ] }) }) : null
291
+ ] }) : null
243
292
  ] })
244
293
  ] });
245
294
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/customers/components/detail/ActivitiesSection.tsx"],
4
- "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { Clock } from 'lucide-react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport type { SectionAction, TabEmptyStateConfig } from '@open-mercato/ui/backend/detail'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { ActivityTimelineFilters } from './ActivityTimelineFilters'\nimport { ActivityTimeline } from './ActivityTimeline'\nimport type { ActivitySummary, InteractionSummary } from './types'\n\ntype GuardedMutationRunner = <T>(\n operation: () => Promise<T>,\n mutationPayload?: Record<string, unknown>,\n) => Promise<T>\n\nexport type ActivitiesSectionProps = {\n entityId: string | null\n entityName?: string | null\n dealId?: string | null\n useCanonicalInteractions?: boolean\n addActionLabel: string\n emptyState: TabEmptyStateConfig\n onActionChange?: (action: SectionAction | null) => void\n onLoadingChange?: (isLoading: boolean) => void\n onDataRefresh?: () => void\n dealOptions?: Array<{ id: string; label: string }>\n entityOptions?: Array<{ id: string; label: string }>\n defaultEntityId?: string | null\n runGuardedMutation?: GuardedMutationRunner\n refreshKey?: number\n onEditActivity?: (activity: InteractionSummary) => void\n}\n\nfunction toDateOnly(value: string | null | undefined): string {\n if (!value) return ''\n const date = new Date(value)\n return Number.isNaN(date.getTime()) ? '' : date.toISOString().slice(0, 10)\n}\n\nfunction normalizeLegacyActivity(activity: ActivitySummary): InteractionSummary {\n return {\n id: activity.id,\n interactionType: activity.activityType,\n title: activity.subject ?? null,\n body: activity.body ?? null,\n status: 'done',\n scheduledAt: null,\n occurredAt: activity.occurredAt ?? null,\n priority: null,\n authorUserId: activity.authorUserId ?? null,\n ownerUserId: null,\n appearanceIcon: activity.appearanceIcon ?? null,\n appearanceColor: activity.appearanceColor ?? null,\n source: 'legacy-activity',\n entityId: activity.entityId ?? null,\n dealId: activity.dealId ?? null,\n organizationId: null,\n tenantId: null,\n authorName: activity.authorName ?? null,\n authorEmail: activity.authorEmail ?? null,\n dealTitle: activity.dealTitle ?? null,\n customValues: activity.customValues ?? null,\n createdAt: activity.createdAt,\n updatedAt: activity.createdAt,\n }\n}\n\nfunction sortTimelineActivities(items: InteractionSummary[]): InteractionSummary[] {\n const now = Date.now()\n return [...items].sort((left, right) => {\n const leftScheduled = left.scheduledAt ? new Date(left.scheduledAt).getTime() : Number.NaN\n const rightScheduled = right.scheduledAt ? new Date(right.scheduledAt).getTime() : Number.NaN\n const leftIsPlanned = left.status === 'planned' && Number.isFinite(leftScheduled)\n const rightIsPlanned = right.status === 'planned' && Number.isFinite(rightScheduled)\n const leftIsUpcoming = leftIsPlanned && leftScheduled >= now\n const rightIsUpcoming = rightIsPlanned && rightScheduled >= now\n\n if (leftIsUpcoming !== rightIsUpcoming) {\n return leftIsUpcoming ? -1 : 1\n }\n\n if (leftIsUpcoming && rightIsUpcoming) {\n if (leftScheduled === rightScheduled) return left.id.localeCompare(right.id)\n return leftScheduled - rightScheduled\n }\n\n const leftTime = left.occurredAt ?? left.createdAt\n const rightTime = right.occurredAt ?? right.createdAt\n const compare = rightTime.localeCompare(leftTime)\n if (compare !== 0) return compare\n return right.id.localeCompare(left.id)\n })\n}\n\nexport function ActivitiesSection({\n entityId,\n entityName,\n dealId,\n useCanonicalInteractions = false,\n onActionChange,\n onLoadingChange,\n refreshKey = 0,\n onEditActivity,\n}: ActivitiesSectionProps) {\n const t = useT()\n const [filterTypes, setFilterTypes] = React.useState<string[]>([])\n const [filterDateFrom, setFilterDateFrom] = React.useState('')\n const [filterDateTo, setFilterDateTo] = React.useState('')\n const [activities, setActivities] = React.useState<InteractionSummary[]>([])\n const [loading, setLoading] = React.useState(false)\n const [hasMore, setHasMore] = React.useState(false)\n const [loadedPages, setLoadedPages] = React.useState(1)\n\n React.useEffect(() => {\n onActionChange?.(null)\n return () => onActionChange?.(null)\n }, [onActionChange])\n\n React.useEffect(() => {\n onLoadingChange?.(loading)\n }, [loading, onLoadingChange])\n\n const loadActivities = React.useCallback(async () => {\n if (!entityId) {\n setActivities([])\n return\n }\n\n setLoading(true)\n try {\n // Always fetch canonical interactions (new activities are always created here)\n const canonicalParams = new URLSearchParams({\n entityId,\n limit: '50',\n sortField: 'occurredAt',\n sortDir: 'desc',\n excludeInteractionType: 'task',\n })\n if (dealId) canonicalParams.set('dealId', dealId)\n if (filterTypes.length > 0) canonicalParams.set('type', filterTypes.join(','))\n if (filterDateFrom) canonicalParams.set('from', filterDateFrom)\n if (filterDateTo) canonicalParams.set('to', filterDateTo)\n\n const canonicalItems: InteractionSummary[] = []\n let canonicalCursor: string | undefined\n let canonicalHasMore = false\n let pageIndex = 0\n do {\n const params = new URLSearchParams(canonicalParams)\n if (canonicalCursor) params.set('cursor', canonicalCursor)\n const canonicalPayload = await readApiResultOrThrow<{ items?: InteractionSummary[]; nextCursor?: string }>(\n `/api/customers/interactions?${params.toString()}`,\n ).catch(() => ({ items: [] as InteractionSummary[], nextCursor: undefined }))\n canonicalItems.push(...(Array.isArray(canonicalPayload?.items) ? canonicalPayload.items : []))\n canonicalCursor = typeof canonicalPayload?.nextCursor === 'string' ? canonicalPayload.nextCursor : undefined\n canonicalHasMore = Boolean(canonicalCursor)\n pageIndex += 1\n } while (canonicalCursor && pageIndex < loadedPages)\n\n if (useCanonicalInteractions) {\n setActivities(sortTimelineActivities(canonicalItems))\n setHasMore(canonicalHasMore)\n return\n }\n\n // In legacy mode, also fetch legacy activities and merge with canonical\n const legacyItems: InteractionSummary[] = []\n let legacyTotalPages = 1\n for (let legacyPage = 1; legacyPage <= loadedPages; legacyPage += 1) {\n const legacyParams = new URLSearchParams({\n entityId,\n page: String(legacyPage),\n pageSize: '50',\n sortField: 'occurredAt',\n sortDir: 'desc',\n })\n if (dealId) legacyParams.set('dealId', dealId)\n const legacyPayload = await readApiResultOrThrow<{ items?: ActivitySummary[]; totalPages?: number }>(\n `/api/customers/activities?${legacyParams.toString()}`,\n ).catch(() => ({ items: [] as ActivitySummary[], totalPages: 1 }))\n legacyItems.push(...(Array.isArray(legacyPayload?.items) ? legacyPayload.items.map(normalizeLegacyActivity) : []))\n legacyTotalPages = typeof legacyPayload?.totalPages === 'number' ? legacyPayload.totalPages : legacyTotalPages\n }\n const legacyFiltered = legacyItems.filter((entry) => {\n if (filterTypes.length > 0 && !filterTypes.includes(entry.interactionType)) return false\n const dateOnly = toDateOnly(entry.occurredAt ?? entry.createdAt)\n if (filterDateFrom && dateOnly < filterDateFrom) return false\n if (filterDateTo && dateOnly > filterDateTo) return false\n return true\n })\n\n // Merge and deduplicate by id, sort newest first\n const seen = new Set<string>()\n const merged: InteractionSummary[] = []\n for (const item of [...canonicalItems, ...legacyFiltered]) {\n if (!seen.has(item.id)) {\n seen.add(item.id)\n merged.push(item)\n }\n }\n setActivities(sortTimelineActivities(merged))\n setHasMore(canonicalHasMore || legacyTotalPages > loadedPages)\n } catch (error) {\n console.error('customers.activities.history failed', error)\n flash(t('customers.activities.loadFailed', 'Failed to load activities.'), 'error')\n setActivities([])\n setHasMore(false)\n } finally {\n setLoading(false)\n }\n }, [dealId, entityId, filterDateFrom, filterDateTo, filterTypes, loadedPages, useCanonicalInteractions, refreshKey, t])\n\n React.useEffect(() => {\n setLoadedPages(1)\n }, [dealId, entityId, filterDateFrom, filterDateTo, filterTypes, useCanonicalInteractions])\n\n const resolvedUserIdsRef = React.useRef(new Set<string>())\n\n // Resolve missing author names from user IDs\n React.useEffect(() => {\n loadActivities()\n .then(() => { resolvedUserIdsRef.current = new Set() })\n .catch((err) => console.warn('[ActivitiesSection] loadActivities failed', err))\n }, [loadActivities])\n\n React.useEffect(() => {\n const unresolvedIds = new Set<string>()\n for (const a of activities) {\n if (a.authorUserId && !a.authorName && !resolvedUserIdsRef.current.has(a.authorUserId)) {\n unresolvedIds.add(a.authorUserId)\n }\n }\n if (unresolvedIds.size === 0) return\n\n for (const uid of unresolvedIds) resolvedUserIdsRef.current.add(uid)\n\n const controller = new AbortController()\n readApiResultOrThrow<{ items?: Array<Record<string, unknown>> }>(\n `/api/auth/users?ids=${[...unresolvedIds].join(',')}`,\n { signal: controller.signal },\n )\n .then((data) => {\n const users = Array.isArray(data?.items) ? data.items : []\n const nameMap = new Map<string, string>()\n for (const user of users) {\n const userId = typeof user.id === 'string' ? user.id : null\n const name = typeof user.display_name === 'string' && user.display_name.trim()\n ? user.display_name.trim()\n : typeof user.email === 'string'\n ? user.email\n : null\n if (userId && name) nameMap.set(userId, name)\n }\n if (nameMap.size > 0) {\n setActivities((prev) =>\n prev.map((a) => {\n if (a.authorUserId && !a.authorName && nameMap.has(a.authorUserId)) {\n return { ...a, authorName: nameMap.get(a.authorUserId) ?? null }\n }\n return a\n }),\n )\n }\n })\n .catch((err) => console.warn('[ActivitiesSection] resolve author names failed', err))\n return () => controller.abort()\n }, [activities])\n\n return (\n <div className=\"rounded-2xl border border-border/70 bg-card p-5\">\n <div className=\"mb-4 flex flex-wrap items-center justify-between gap-3\">\n <div className=\"flex items-center gap-2\">\n <Clock className=\"size-4 text-muted-foreground\" />\n <h3 className=\"text-base font-semibold text-foreground\">\n {entityName\n ? t('customers.timeline.history.title', 'Interaction history with {{name}}', { name: entityName })\n : t('customers.timeline.history.titleGeneric', 'Interaction history')}\n </h3>\n </div>\n </div>\n\n <div className=\"mb-4\">\n <ActivityTimelineFilters\n entityId={entityId}\n activeTypes={filterTypes}\n dateFrom={filterDateFrom}\n dateTo={filterDateTo}\n onTypesChange={setFilterTypes}\n onDateFromChange={setFilterDateFrom}\n onDateToChange={setFilterDateTo}\n onReset={() => {\n setFilterTypes([])\n setFilterDateFrom('')\n setFilterDateTo('')\n }}\n />\n </div>\n\n {loading && activities.length === 0 ? (\n <div className=\"rounded-lg border border-dashed border-border/70 px-4 py-8 text-sm text-muted-foreground\">\n {t('customers.people.detail.activities.loading', 'Loading activities\u2026')}\n </div>\n ) : (\n <>\n <ActivityTimeline activities={activities} onEdit={onEditActivity} />\n {activities.length > 0 ? (\n <div className=\"border-t px-5 py-3\">\n <div className=\"flex items-center justify-between gap-3\">\n <span className=\"text-xs text-muted-foreground\">\n {t('customers.activities.seeAll', 'See all {count} activities', { count: activities.length })}\n </span>\n {hasMore ? (\n <Button type=\"button\" variant=\"link\" size=\"sm\" onClick={() => setLoadedPages((value) => value + 1)}>\n {t('customers.activities.loadMore', 'Load more')}\n </Button>\n ) : null}\n </div>\n </div>\n ) : null}\n </>\n )}\n </div>\n )\n}\n\nexport default ActivitiesSection\n"],
5
- "mappings": ";AAkRQ,SAgCA,UA/BE,KADF;AAhRR,YAAY,WAAW;AACvB,SAAS,aAAa;AACtB,SAAS,YAAY;AACrB,SAAS,4BAA4B;AACrC,SAAS,aAAa;AAEtB,SAAS,cAAc;AACvB,SAAS,+BAA+B;AACxC,SAAS,wBAAwB;AA0BjC,SAAS,WAAW,OAA0C;AAC5D,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,SAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,IAAI,KAAK,KAAK,YAAY,EAAE,MAAM,GAAG,EAAE;AAC3E;AAEA,SAAS,wBAAwB,UAA+C;AAC9E,SAAO;AAAA,IACL,IAAI,SAAS;AAAA,IACb,iBAAiB,SAAS;AAAA,IAC1B,OAAO,SAAS,WAAW;AAAA,IAC3B,MAAM,SAAS,QAAQ;AAAA,IACvB,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,YAAY,SAAS,cAAc;AAAA,IACnC,UAAU;AAAA,IACV,cAAc,SAAS,gBAAgB;AAAA,IACvC,aAAa;AAAA,IACb,gBAAgB,SAAS,kBAAkB;AAAA,IAC3C,iBAAiB,SAAS,mBAAmB;AAAA,IAC7C,QAAQ;AAAA,IACR,UAAU,SAAS,YAAY;AAAA,IAC/B,QAAQ,SAAS,UAAU;AAAA,IAC3B,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,YAAY,SAAS,cAAc;AAAA,IACnC,aAAa,SAAS,eAAe;AAAA,IACrC,WAAW,SAAS,aAAa;AAAA,IACjC,cAAc,SAAS,gBAAgB;AAAA,IACvC,WAAW,SAAS;AAAA,IACpB,WAAW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;AAAA,IAEA,oBAAC,SAAI,WAAU,QACb;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,aAAa;AAAA,QACb,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,eAAe;AAAA,QACf,kBAAkB;AAAA,QAClB,gBAAgB;AAAA,QAChB,SAAS,MAAM;AACb,yBAAe,CAAC,CAAC;AACjB,4BAAkB,EAAE;AACpB,0BAAgB,EAAE;AAAA,QACpB;AAAA;AAAA,IACF,GACF;AAAA,IAEC,WAAW,WAAW,WAAW,IAChC,oBAAC,SAAI,WAAU,4FACZ,YAAE,8CAA8C,0BAAqB,GACxE,IAEA,iCACE;AAAA,0BAAC,oBAAiB,YAAwB,QAAQ,gBAAgB;AAAA,MACjE,WAAW,SAAS,IACnB,oBAAC,SAAI,WAAU,sBACb,+BAAC,SAAI,WAAU,2CACb;AAAA,4BAAC,UAAK,WAAU,iCACb,YAAE,+BAA+B,8BAA8B,EAAE,OAAO,WAAW,OAAO,CAAC,GAC9F;AAAA,QACC,UACC,oBAAC,UAAO,MAAK,UAAS,SAAQ,QAAO,MAAK,MAAK,SAAS,MAAM,eAAe,CAAC,UAAU,QAAQ,CAAC,GAC9F,YAAE,iCAAiC,WAAW,GACjD,IACE;AAAA,SACN,GACF,IACE;AAAA,OACN;AAAA,KAEJ;AAEJ;AAEA,IAAO,4BAAQ;",
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { Clock, Search } from 'lucide-react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport type { SectionAction, TabEmptyStateConfig } from '@open-mercato/ui/backend/detail'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Kbd } from '@open-mercato/ui/primitives/kbd'\nimport { ActivityTimelineFilters } from './ActivityTimelineFilters'\nimport { ActivityTimeline } from './ActivityTimeline'\nimport type { ActivitySummary, InteractionSummary } from './types'\n\ntype GuardedMutationRunner = <T>(\n operation: () => Promise<T>,\n mutationPayload?: Record<string, unknown>,\n) => Promise<T>\n\nexport type ActivitiesSectionProps = {\n entityId: string | null\n entityName?: string | null\n dealId?: string | null\n useCanonicalInteractions?: boolean\n addActionLabel: string\n emptyState: TabEmptyStateConfig\n onActionChange?: (action: SectionAction | null) => void\n onLoadingChange?: (isLoading: boolean) => void\n onDataRefresh?: () => void\n dealOptions?: Array<{ id: string; label: string }>\n entityOptions?: Array<{ id: string; label: string }>\n defaultEntityId?: string | null\n runGuardedMutation?: GuardedMutationRunner\n refreshKey?: number\n onEditActivity?: (activity: InteractionSummary) => void\n}\n\nfunction toDateOnly(value: string | null | undefined): string {\n if (!value) return ''\n const date = new Date(value)\n return Number.isNaN(date.getTime()) ? '' : date.toISOString().slice(0, 10)\n}\n\nfunction normalizeLegacyActivity(activity: ActivitySummary): InteractionSummary {\n return {\n id: activity.id,\n interactionType: activity.activityType,\n title: activity.subject ?? null,\n body: activity.body ?? null,\n status: 'done',\n scheduledAt: null,\n occurredAt: activity.occurredAt ?? null,\n priority: null,\n authorUserId: activity.authorUserId ?? null,\n ownerUserId: null,\n appearanceIcon: activity.appearanceIcon ?? null,\n appearanceColor: activity.appearanceColor ?? null,\n source: 'legacy-activity',\n entityId: activity.entityId ?? null,\n dealId: activity.dealId ?? null,\n organizationId: null,\n tenantId: null,\n authorName: activity.authorName ?? null,\n authorEmail: activity.authorEmail ?? null,\n dealTitle: activity.dealTitle ?? null,\n customValues: activity.customValues ?? null,\n createdAt: activity.createdAt,\n updatedAt: activity.createdAt,\n }\n}\n\nfunction sortTimelineActivities(items: InteractionSummary[]): InteractionSummary[] {\n const now = Date.now()\n return [...items].sort((left, right) => {\n const leftScheduled = left.scheduledAt ? new Date(left.scheduledAt).getTime() : Number.NaN\n const rightScheduled = right.scheduledAt ? new Date(right.scheduledAt).getTime() : Number.NaN\n const leftIsPlanned = left.status === 'planned' && Number.isFinite(leftScheduled)\n const rightIsPlanned = right.status === 'planned' && Number.isFinite(rightScheduled)\n const leftIsUpcoming = leftIsPlanned && leftScheduled >= now\n const rightIsUpcoming = rightIsPlanned && rightScheduled >= now\n\n if (leftIsUpcoming !== rightIsUpcoming) {\n return leftIsUpcoming ? -1 : 1\n }\n\n if (leftIsUpcoming && rightIsUpcoming) {\n if (leftScheduled === rightScheduled) return left.id.localeCompare(right.id)\n return leftScheduled - rightScheduled\n }\n\n const leftTime = left.occurredAt ?? left.createdAt\n const rightTime = right.occurredAt ?? right.createdAt\n const compare = rightTime.localeCompare(leftTime)\n if (compare !== 0) return compare\n return right.id.localeCompare(left.id)\n })\n}\n\nexport function ActivitiesSection({\n entityId,\n entityName,\n dealId,\n useCanonicalInteractions = false,\n onActionChange,\n onLoadingChange,\n refreshKey = 0,\n onEditActivity,\n}: ActivitiesSectionProps) {\n const t = useT()\n const [filterTypes, setFilterTypes] = React.useState<string[]>([])\n const [filterDateFrom, setFilterDateFrom] = React.useState('')\n const [filterDateTo, setFilterDateTo] = React.useState('')\n const [searchTerm, setSearchTerm] = React.useState('')\n const [activities, setActivities] = React.useState<InteractionSummary[]>([])\n const [loading, setLoading] = React.useState(false)\n const [hasMore, setHasMore] = React.useState(false)\n const [loadedPages, setLoadedPages] = React.useState(1)\n const searchInputRef = React.useRef<HTMLInputElement>(null)\n\n React.useEffect(() => {\n if (!entityId) return\n function handleShortcut(event: KeyboardEvent) {\n if ((event.metaKey || event.ctrlKey) && event.key === '1') {\n event.preventDefault()\n searchInputRef.current?.focus()\n }\n }\n window.addEventListener('keydown', handleShortcut)\n return () => window.removeEventListener('keydown', handleShortcut)\n }, [entityId])\n\n const visibleActivities = React.useMemo(() => {\n const term = searchTerm.trim().toLowerCase()\n if (!term) return activities\n return activities.filter((activity) => {\n const haystack = [\n activity.title,\n activity.body,\n activity.authorName,\n activity.dealTitle,\n activity.interactionType,\n ]\n .filter((value): value is string => typeof value === 'string' && value.length > 0)\n .join(' ')\n .toLowerCase()\n return haystack.includes(term)\n })\n }, [activities, searchTerm])\n\n React.useEffect(() => {\n onActionChange?.(null)\n return () => onActionChange?.(null)\n }, [onActionChange])\n\n React.useEffect(() => {\n onLoadingChange?.(loading)\n }, [loading, onLoadingChange])\n\n const loadActivities = React.useCallback(async () => {\n if (!entityId) {\n setActivities([])\n return\n }\n\n setLoading(true)\n try {\n // Always fetch canonical interactions (new activities are always created here)\n const canonicalParams = new URLSearchParams({\n entityId,\n limit: '50',\n sortField: 'occurredAt',\n sortDir: 'desc',\n excludeInteractionType: 'task',\n })\n if (dealId) canonicalParams.set('dealId', dealId)\n if (filterTypes.length > 0) canonicalParams.set('type', filterTypes.join(','))\n if (filterDateFrom) canonicalParams.set('from', filterDateFrom)\n if (filterDateTo) canonicalParams.set('to', filterDateTo)\n\n const canonicalItems: InteractionSummary[] = []\n let canonicalCursor: string | undefined\n let canonicalHasMore = false\n let pageIndex = 0\n do {\n const params = new URLSearchParams(canonicalParams)\n if (canonicalCursor) params.set('cursor', canonicalCursor)\n const canonicalPayload = await readApiResultOrThrow<{ items?: InteractionSummary[]; nextCursor?: string }>(\n `/api/customers/interactions?${params.toString()}`,\n ).catch(() => ({ items: [] as InteractionSummary[], nextCursor: undefined }))\n canonicalItems.push(...(Array.isArray(canonicalPayload?.items) ? canonicalPayload.items : []))\n canonicalCursor = typeof canonicalPayload?.nextCursor === 'string' ? canonicalPayload.nextCursor : undefined\n canonicalHasMore = Boolean(canonicalCursor)\n pageIndex += 1\n } while (canonicalCursor && pageIndex < loadedPages)\n\n if (useCanonicalInteractions) {\n setActivities(sortTimelineActivities(canonicalItems))\n setHasMore(canonicalHasMore)\n return\n }\n\n // In legacy mode, also fetch legacy activities and merge with canonical\n const legacyItems: InteractionSummary[] = []\n let legacyTotalPages = 1\n for (let legacyPage = 1; legacyPage <= loadedPages; legacyPage += 1) {\n const legacyParams = new URLSearchParams({\n entityId,\n page: String(legacyPage),\n pageSize: '50',\n sortField: 'occurredAt',\n sortDir: 'desc',\n })\n if (dealId) legacyParams.set('dealId', dealId)\n const legacyPayload = await readApiResultOrThrow<{ items?: ActivitySummary[]; totalPages?: number }>(\n `/api/customers/activities?${legacyParams.toString()}`,\n ).catch(() => ({ items: [] as ActivitySummary[], totalPages: 1 }))\n legacyItems.push(...(Array.isArray(legacyPayload?.items) ? legacyPayload.items.map(normalizeLegacyActivity) : []))\n legacyTotalPages = typeof legacyPayload?.totalPages === 'number' ? legacyPayload.totalPages : legacyTotalPages\n }\n const legacyFiltered = legacyItems.filter((entry) => {\n if (filterTypes.length > 0 && !filterTypes.includes(entry.interactionType)) return false\n const dateOnly = toDateOnly(entry.occurredAt ?? entry.createdAt)\n if (filterDateFrom && dateOnly < filterDateFrom) return false\n if (filterDateTo && dateOnly > filterDateTo) return false\n return true\n })\n\n // Merge and deduplicate by id, sort newest first\n const seen = new Set<string>()\n const merged: InteractionSummary[] = []\n for (const item of [...canonicalItems, ...legacyFiltered]) {\n if (!seen.has(item.id)) {\n seen.add(item.id)\n merged.push(item)\n }\n }\n setActivities(sortTimelineActivities(merged))\n setHasMore(canonicalHasMore || legacyTotalPages > loadedPages)\n } catch (error) {\n console.error('customers.activities.history failed', error)\n flash(t('customers.activities.loadFailed', 'Failed to load activities.'), 'error')\n setActivities([])\n setHasMore(false)\n } finally {\n setLoading(false)\n }\n }, [dealId, entityId, filterDateFrom, filterDateTo, filterTypes, loadedPages, useCanonicalInteractions, refreshKey, t])\n\n React.useEffect(() => {\n setLoadedPages(1)\n }, [dealId, entityId, filterDateFrom, filterDateTo, filterTypes, useCanonicalInteractions])\n\n const resolvedUserIdsRef = React.useRef(new Set<string>())\n\n // Resolve missing author names from user IDs\n React.useEffect(() => {\n loadActivities()\n .then(() => { resolvedUserIdsRef.current = new Set() })\n .catch((err) => console.warn('[ActivitiesSection] loadActivities failed', err))\n }, [loadActivities])\n\n React.useEffect(() => {\n const unresolvedIds = new Set<string>()\n for (const a of activities) {\n if (a.authorUserId && !a.authorName && !resolvedUserIdsRef.current.has(a.authorUserId)) {\n unresolvedIds.add(a.authorUserId)\n }\n }\n if (unresolvedIds.size === 0) return\n\n for (const uid of unresolvedIds) resolvedUserIdsRef.current.add(uid)\n\n const controller = new AbortController()\n readApiResultOrThrow<{ items?: Array<Record<string, unknown>> }>(\n `/api/auth/users?ids=${[...unresolvedIds].join(',')}`,\n { signal: controller.signal },\n )\n .then((data) => {\n const users = Array.isArray(data?.items) ? data.items : []\n const nameMap = new Map<string, string>()\n for (const user of users) {\n const userId = typeof user.id === 'string' ? user.id : null\n const name = typeof user.display_name === 'string' && user.display_name.trim()\n ? user.display_name.trim()\n : typeof user.email === 'string'\n ? user.email\n : null\n if (userId && name) nameMap.set(userId, name)\n }\n if (nameMap.size > 0) {\n setActivities((prev) =>\n prev.map((a) => {\n if (a.authorUserId && !a.authorName && nameMap.has(a.authorUserId)) {\n return { ...a, authorName: nameMap.get(a.authorUserId) ?? null }\n }\n return a\n }),\n )\n }\n })\n .catch((err) => console.warn('[ActivitiesSection] resolve author names failed', err))\n return () => controller.abort()\n }, [activities])\n\n const totalCount = activities.length\n const visibleCount = visibleActivities.length\n\n return (\n <div className=\"flex flex-col gap-3.5 rounded-[10px] border border-border bg-card pt-4 pb-[18px] px-[18px]\">\n <div className=\"flex items-center gap-2\">\n <Clock className=\"size-[15px] text-muted-foreground\" />\n <h3 className=\"text-[13px] font-semibold text-foreground\">\n {entityName\n ? t('customers.timeline.history.title', 'Interaction history with {{name}}', { name: entityName })\n : t('customers.timeline.history.titleGeneric', 'Interaction history')}\n </h3>\n </div>\n\n <label className=\"relative flex items-center\">\n <Search className=\"pointer-events-none absolute left-2.5 size-5 text-muted-foreground\" aria-hidden />\n <input\n ref={searchInputRef}\n type=\"search\"\n value={searchTerm}\n onChange={(event) => setSearchTerm(event.target.value)}\n placeholder={t('customers.timeline.history.searchPlaceholder', 'Search...')}\n aria-label={t('customers.timeline.history.searchAriaLabel', 'Search interaction history')}\n className=\"h-9 w-full rounded-[10px] border border-border bg-card pl-9 pr-14 text-sm text-foreground shadow-xs placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden\"\n />\n <Kbd className=\"pointer-events-none absolute right-2 hidden text-[11px] uppercase tracking-[0.48px] sm:inline-flex\">\n \u23181\n </Kbd>\n </label>\n\n <ActivityTimelineFilters\n entityId={entityId}\n activeTypes={filterTypes}\n dateFrom={filterDateFrom}\n dateTo={filterDateTo}\n onTypesChange={setFilterTypes}\n onDateFromChange={setFilterDateFrom}\n onDateToChange={setFilterDateTo}\n onReset={() => {\n setFilterTypes([])\n setFilterDateFrom('')\n setFilterDateTo('')\n }}\n />\n\n {loading && totalCount === 0 ? (\n <div className=\"rounded-lg border border-dashed border-border/70 px-4 py-8 text-sm text-muted-foreground\">\n {t('customers.people.detail.activities.loading', 'Loading activities\u2026')}\n </div>\n ) : (\n <>\n <ActivityTimeline activities={visibleActivities} onEdit={onEditActivity} />\n {totalCount > 0 ? (\n <div className=\"flex items-center justify-between gap-3 border-t border-border/60 pt-3\">\n <span className=\"text-xs text-muted-foreground\">\n {searchTerm.trim()\n ? t('customers.activities.seeMatching', 'Showing {visible} of {total} activities', {\n visible: visibleCount,\n total: totalCount,\n })\n : t('customers.activities.seeAll', 'See all {count} activities', { count: totalCount })}\n </span>\n {hasMore ? (\n <Button type=\"button\" variant=\"link\" size=\"sm\" onClick={() => setLoadedPages((value) => value + 1)}>\n {t('customers.activities.loadMore', 'Load more')}\n </Button>\n ) : null}\n </div>\n ) : null}\n </>\n )}\n </div>\n )\n}\n\nexport default ActivitiesSection\n"],
5
+ "mappings": ";AAqTM,SA6CE,UA5CA,KADF;AAnTN,YAAY,WAAW;AACvB,SAAS,OAAO,cAAc;AAC9B,SAAS,YAAY;AACrB,SAAS,4BAA4B;AACrC,SAAS,aAAa;AAEtB,SAAS,cAAc;AACvB,SAAS,WAAW;AACpB,SAAS,+BAA+B;AACxC,SAAS,wBAAwB;AA0BjC,SAAS,WAAW,O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