@open-mercato/core 0.10.1-develop.7669.1.120a2cf7f1 → 0.10.1-develop.7671.1.9117e4b0b3
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.
- package/.turbo/turbo-build.log +1 -1
- package/dist/modules/customers/commands/interactions.js +65 -21
- package/dist/modules/customers/commands/interactions.js.map +2 -2
- package/dist/modules/customers/components/detail/ScheduleActivityDialog.js +26 -24
- package/dist/modules/customers/components/detail/ScheduleActivityDialog.js.map +2 -2
- package/dist/modules/customers/components/detail/schedule/fieldConfig.js +10 -1
- package/dist/modules/customers/components/detail/schedule/fieldConfig.js.map +2 -2
- package/dist/modules/customers/components/detail/schedule/index.js +2 -1
- package/dist/modules/customers/components/detail/schedule/index.js.map +2 -2
- package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js +5 -4
- package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js.map +2 -2
- package/dist/modules/warranty_claims/commands/claims.js +2 -2
- package/dist/modules/warranty_claims/commands/claims.js.map +2 -2
- package/package.json +7 -7
- package/src/modules/customers/commands/interactions.ts +87 -35
- package/src/modules/customers/components/detail/ScheduleActivityDialog.tsx +31 -24
- package/src/modules/customers/components/detail/schedule/fieldConfig.ts +16 -0
- package/src/modules/customers/components/detail/schedule/index.ts +1 -1
- package/src/modules/customers/components/detail/schedule/useScheduleFormState.ts +12 -6
- package/src/modules/warranty_claims/commands/claims.ts +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { isDateRequired } from "./fieldConfig.js";
|
|
2
|
+
import { isDateRequired, resolveScheduleActivityType } from "./fieldConfig.js";
|
|
3
3
|
const PARTICIPANT_COLORS = [
|
|
4
4
|
"bg-chart-emerald",
|
|
5
5
|
"bg-chart-blue",
|
|
@@ -74,8 +74,9 @@ function useScheduleFormState({ open, editData }) {
|
|
|
74
74
|
React.useEffect(() => {
|
|
75
75
|
if (open) {
|
|
76
76
|
if (editData) {
|
|
77
|
-
const
|
|
78
|
-
|
|
77
|
+
const rawType = editData.interactionType ?? "meeting";
|
|
78
|
+
const resolvedType = resolveScheduleActivityType(rawType);
|
|
79
|
+
setActivityType(rawType);
|
|
79
80
|
setTitle(editData.title ?? "");
|
|
80
81
|
const sourceTimestamp = editData.scheduledAt ?? editData.occurredAt ?? null;
|
|
81
82
|
const seedDate = sourceTimestamp ? new Date(sourceTimestamp) : null;
|
|
@@ -168,7 +169,7 @@ function useScheduleFormState({ open, editData }) {
|
|
|
168
169
|
}
|
|
169
170
|
if (lastReminderTypeRef.current === activityType) return;
|
|
170
171
|
lastReminderTypeRef.current = activityType;
|
|
171
|
-
setReminderMinutes(DEFAULT_REMINDER_MINUTES[activityType]);
|
|
172
|
+
setReminderMinutes(DEFAULT_REMINDER_MINUTES[resolveScheduleActivityType(activityType)]);
|
|
172
173
|
}, [activityType, isEditing, open]);
|
|
173
174
|
const removeParticipant = React.useCallback((index) => {
|
|
174
175
|
setParticipants((prev) => prev.filter((_, i) => i !== index));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/customers/components/detail/schedule/useScheduleFormState.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react'\nimport type { ActivityType } from './fieldConfig'\nimport { isDateRequired } from './fieldConfig'\n\nexport type RsvpStatus = 'pending' | 'accepted' | 'declined' | 'tentative'\n\nexport type Participant = {\n userId?: string\n name: string\n email?: string\n color?: string\n status?: RsvpStatus\n}\n\nexport type LinkedEntity = {\n id: string\n type: 'company' | 'deal' | 'offer'\n label: string\n}\n\nexport type ScheduleActivityEditData = {\n id: string\n /** Record version for the OSS optimistic-lock header on edit (#2055). */\n updatedAt?: string | null\n /**\n * The activity's own linked person/company id, captured at edit time. Callers\n * that show activities from more than one entity (e.g. the deal detail page's\n * multi-entity activity list) must set this so `ScheduleActivityDialog` keeps\n * the edit payload's `entityId` pinned to the activity's actual record instead\n * of whichever entity happens to be selected in the host page's picker (#6050).\n */\n entityId?: string | null\n interactionType?: string\n title?: string | null\n body?: string | null\n scheduledAt?: string | null\n /**\n * Historical timestamp for completed activities (status `done`). Required for\n * the edit prefill to restore the original date/time instead of falling back\n * to \"today\" (#1807).\n */\n occurredAt?: string | null\n durationMinutes?: number | null\n /** Interaction priority column (0-100, nullable) backing the task priority control (#5943). */\n priority?: number | null\n location?: string | null\n allDay?: boolean | null\n recurrenceRule?: string | null\n recurrenceEnd?: string | null\n participants?: Array<{ userId?: string; name?: string; email?: string; status?: string }> | null\n reminderMinutes?: number | null\n visibility?: string | null\n linkedEntities?: Array<{ id: string; type: string; label: string }> | null\n guestPermissions?: { canInviteOthers?: boolean; canModify?: boolean; canSeeList?: boolean } | null\n}\n\nexport const PARTICIPANT_COLORS = [\n 'bg-chart-emerald',\n 'bg-chart-blue',\n 'bg-chart-orange',\n 'bg-chart-violet',\n 'bg-chart-pink',\n 'bg-chart-teal',\n]\n\n// Per-Figma defaults for the Reminder dropdown when the user picks an activity\n// type. Meeting/email keep the standard 15 min; tasks default to 1 day (1440 min)\n// because they're plan-ahead artefacts; calls default to 5 min as a stand-in for\n// the Figma \"After call ends\" treatment (which would need a non-numeric sentinel\n// in the API contract \u2014 tracked as a follow-up).\nconst DEFAULT_REMINDER_MINUTES: Record<ActivityType, number> = {\n meeting: 15,\n call: 5,\n task: 1440,\n email: 15,\n note: 15,\n}\n\n// Create-mode date/time defaults. A fixed morning slot made every activity opened\n// later in the day start in the past, so the seed is always computed forward from\n// \"now\" (#5940): tasks are plan-ahead artefacts and default to the end of the\n// working day, everything else to the next half-hour slot.\nconst DEFAULT_SLOT_MINUTES = 30\nconst TASK_DEFAULT_HOUR = 17\nconst NEXT_DAY_START_HOUR = 9\n\nfunction padDatePart(value: number): string {\n return String(value).padStart(2, '0')\n}\n\nfunction isSameLocalDay(left: Date, right: Date): boolean {\n return (\n left.getFullYear() === right.getFullYear() &&\n left.getMonth() === right.getMonth() &&\n left.getDate() === right.getDate()\n )\n}\n\nfunction nextSlotAfter(now: Date): Date {\n const next = new Date(now)\n next.setSeconds(0, 0)\n next.setMinutes(next.getMinutes() + (DEFAULT_SLOT_MINUTES - (next.getMinutes() % DEFAULT_SLOT_MINUTES)))\n if (!isSameLocalDay(next, now)) {\n next.setHours(NEXT_DAY_START_HOUR, 0, 0, 0)\n }\n return next\n}\n\n/**\n * Default start moment for a newly created activity of `type`, always strictly\n * after `now` so a brand-new record is never born overdue (#5940).\n */\nexport function resolveDefaultActivityStart(type: ActivityType, now: Date): Date {\n if (type === 'task') {\n const endOfWorkingDay = new Date(now)\n endOfWorkingDay.setHours(TASK_DEFAULT_HOUR, 0, 0, 0)\n if (endOfWorkingDay.getTime() > now.getTime()) return endOfWorkingDay\n }\n return nextSlotAfter(now)\n}\n\nfunction formatLocalDateInput(date: Date): string {\n return `${date.getFullYear()}-${padDatePart(date.getMonth() + 1)}-${padDatePart(date.getDate())}`\n}\n\nfunction formatLocalTimeInput(date: Date): string {\n return `${padDatePart(date.getHours())}:${padDatePart(date.getMinutes())}`\n}\n\ninterface UseScheduleFormStateParams {\n open: boolean\n editData: ScheduleActivityEditData | null | undefined\n}\n\nexport function useScheduleFormState({ open, editData }: UseScheduleFormStateParams) {\n // An empty `id` is the menu-driven \"New X\" convention \u2014 a create with a preset\n // type, not an edit. The save path already reads it this way (`isSaveEdit`), so\n // the seeding below must agree or new records inherit edit-mode fallbacks (#5940).\n const isEditing = Boolean(editData?.id)\n const [initialStart] = React.useState(() => resolveDefaultActivityStart('meeting', new Date()))\n const [activityType, setActivityType] = React.useState<ActivityType>('meeting')\n const [title, setTitle] = React.useState('')\n const [date, setDate] = React.useState(() => formatLocalDateInput(initialStart))\n const [startTime, setStartTime] = React.useState(() => formatLocalTimeInput(initialStart))\n const [duration, setDuration] = React.useState(30)\n const [allDay, setAllDay] = React.useState(false)\n const [description, setDescription] = React.useState('')\n const [markdownEnabled, setMarkdownEnabled] = React.useState(true)\n const [location, setLocation] = React.useState('')\n const [reminderMinutes, setReminderMinutes] = React.useState(15)\n const [visibility, setVisibility] = React.useState('team')\n const [participants, setParticipants] = React.useState<Participant[]>([])\n const [linkedEntities, setLinkedEntities] = React.useState<LinkedEntity[]>([])\n const [recurrenceEnabled, setRecurrenceEnabled] = React.useState(false)\n const [recurrenceDays, setRecurrenceDays] = React.useState<boolean[]>([true, false, true, false, false, false, false])\n const [recurrenceEndType, setRecurrenceEndType] = React.useState<'never' | 'count' | 'date'>('never')\n const [recurrenceCount, setRecurrenceCount] = React.useState(8)\n const [recurrenceEndDate, setRecurrenceEndDate] = React.useState('')\n const [conflict, setConflict] = React.useState<string | null>(null)\n const [saving, setSaving] = React.useState(false)\n const [guestPermissions, setGuestPermissions] = React.useState({ canInviteOthers: true, canModify: false, canSeeList: true })\n\n React.useEffect(() => {\n if (open) {\n if (editData) {\n // Edit mode: populate from existing interaction\n const resolvedType = (editData.interactionType as ActivityType) ?? 'meeting'\n setActivityType(resolvedType)\n setTitle(editData.title ?? '')\n // `scheduledAt` is the canonical term of anything that was ever planned, so it\n // wins whenever it is set: the save path recomputes `scheduledAt` from these\n // seeded date/time fields, and seeding from `occurredAt` first silently\n // overwrote a completed task's due date on unrelated edits (#5939).\n // `occurredAt` stays the fallback for purely historical entries (a logged call\n // or note) that never had a `scheduledAt`, so editing those still restores\n // their actual moment instead of falling back to \"today\" (#1807).\n // Keep seed values in the user's local timezone, matching the cluster-E\n // local-day convention.\n const sourceTimestamp = editData.scheduledAt ?? editData.occurredAt ?? null\n const seedDate = sourceTimestamp ? new Date(sourceTimestamp) : null\n const seedDateValid = seedDate !== null && !Number.isNaN(seedDate.getTime())\n // A real edit of an undated task must stay undated: falling back to a\n // computed default here would silently give a backlog item a due date on\n // the next save (#5941). Menu-driven \"New Task\" (no id yet, so `isEditing`\n // is false) still gets the create-mode default so #5940's forward-seeded\n // default keeps working.\n if (isEditing && !seedDateValid && !isDateRequired(resolvedType)) {\n setDate('')\n setStartTime('')\n } else {\n const dateForForm = seedDateValid ? (seedDate as Date) : resolveDefaultActivityStart(resolvedType, new Date())\n setDate(formatLocalDateInput(dateForForm))\n setStartTime(formatLocalTimeInput(dateForForm))\n }\n setDuration(editData.durationMinutes ?? 30)\n setAllDay(editData.allDay ?? false)\n setDescription(editData.body ?? '')\n setLocation(editData.location ?? '')\n // Use per-type default when the editData omits an explicit reminder\n // (the menu-driven \"New X\" flow opens the dialog with `reminderMinutes: null`).\n setReminderMinutes(editData.reminderMinutes ?? DEFAULT_REMINDER_MINUTES[resolvedType])\n setVisibility(editData.visibility ?? 'team')\n setParticipants(\n Array.isArray(editData.participants)\n ? editData.participants.map((p, i) => ({\n userId: p.userId,\n name: p.name ?? p.email ?? p.userId ?? '',\n email: p.email,\n color: PARTICIPANT_COLORS[i % PARTICIPANT_COLORS.length],\n status: (p.status ?? 'pending') as RsvpStatus,\n }))\n : [],\n )\n setLinkedEntities(\n Array.isArray(editData.linkedEntities)\n ? editData.linkedEntities.map((e) => ({ id: e.id, type: e.type as LinkedEntity['type'], label: e.label }))\n : [],\n )\n if (editData.recurrenceRule) {\n setRecurrenceEnabled(true)\n // Parse RRULE to set days and end type\n const rule = editData.recurrenceRule\n const byDayMatch = rule.match(/BYDAY=([A-Z,]+)/)\n if (byDayMatch) {\n const dayNames = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU']\n const activeDays = byDayMatch[1].split(',')\n setRecurrenceDays(dayNames.map((d) => activeDays.includes(d)))\n }\n const countMatch = rule.match(/COUNT=(\\d+)/)\n const untilMatch = rule.match(/UNTIL=(\\d{8})/)\n if (countMatch) {\n setRecurrenceEndType('count')\n setRecurrenceCount(Number(countMatch[1]))\n } else if (untilMatch) {\n setRecurrenceEndType('date')\n const raw = untilMatch[1]\n setRecurrenceEndDate(`${raw.slice(0, 4)}-${raw.slice(4, 6)}-${raw.slice(6, 8)}`)\n } else {\n setRecurrenceEndType('never')\n }\n } else {\n setRecurrenceEnabled(false)\n }\n if (editData.guestPermissions) {\n setGuestPermissions({\n canInviteOthers: editData.guestPermissions.canInviteOthers ?? true,\n canModify: editData.guestPermissions.canModify ?? false,\n canSeeList: editData.guestPermissions.canSeeList ?? true,\n })\n }\n } else {\n // Create mode: reset all fields\n const defaultStart = resolveDefaultActivityStart('meeting', new Date())\n setActivityType('meeting')\n setTitle('')\n setDate(formatLocalDateInput(defaultStart))\n setStartTime(formatLocalTimeInput(defaultStart))\n setDuration(30)\n setAllDay(false)\n setDescription('')\n setLocation('')\n setReminderMinutes(DEFAULT_REMINDER_MINUTES.meeting)\n setVisibility('team')\n setParticipants([])\n setLinkedEntities([])\n setRecurrenceEnabled(false)\n }\n setConflict(null)\n }\n return () => {\n // Safety net: restore body scroll if Radix Dialog fails to clean up\n document.body.style.removeProperty('overflow')\n document.body.style.removeProperty('pointer-events')\n }\n }, [open, editData, isEditing])\n\n // Update the Reminder default when the activity type changes in create mode.\n // Skipped in edit mode (the persisted value wins), and gated by `open` to\n // avoid flipping the default in a closed-but-mounted dialog.\n const lastReminderTypeRef = React.useRef<ActivityType>('meeting')\n React.useEffect(() => {\n if (!open || isEditing) {\n lastReminderTypeRef.current = activityType\n return\n }\n if (lastReminderTypeRef.current === activityType) return\n lastReminderTypeRef.current = activityType\n setReminderMinutes(DEFAULT_REMINDER_MINUTES[activityType])\n }, [activityType, isEditing, open])\n\n const removeParticipant = React.useCallback((index: number) => {\n setParticipants((prev) => prev.filter((_, i) => i !== index))\n }, [])\n\n const toggleRecurrenceDay = React.useCallback((index: number) => {\n setRecurrenceDays((prev) => {\n const next = [...prev]\n next[index] = !next[index]\n return next\n })\n }, [])\n\n return {\n activityType,\n setActivityType,\n title,\n setTitle,\n date,\n setDate,\n startTime,\n setStartTime,\n duration,\n setDuration,\n allDay,\n setAllDay,\n description,\n setDescription,\n markdownEnabled,\n setMarkdownEnabled,\n location,\n setLocation,\n reminderMinutes,\n setReminderMinutes,\n visibility,\n setVisibility,\n participants,\n setParticipants,\n linkedEntities,\n setLinkedEntities,\n recurrenceEnabled,\n setRecurrenceEnabled,\n recurrenceDays,\n setRecurrenceDays,\n recurrenceEndType,\n setRecurrenceEndType,\n recurrenceCount,\n setRecurrenceCount,\n recurrenceEndDate,\n setRecurrenceEndDate,\n conflict,\n setConflict,\n saving,\n setSaving,\n guestPermissions,\n setGuestPermissions,\n removeParticipant,\n toggleRecurrenceDay,\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;AAEvB,SAAS,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react'\nimport type { ActivityType } from './fieldConfig'\nimport { isDateRequired, resolveScheduleActivityType } from './fieldConfig'\n\nexport type RsvpStatus = 'pending' | 'accepted' | 'declined' | 'tentative'\n\nexport type Participant = {\n userId?: string\n name: string\n email?: string\n color?: string\n status?: RsvpStatus\n}\n\nexport type LinkedEntity = {\n id: string\n type: 'company' | 'deal' | 'offer'\n label: string\n}\n\nexport type ScheduleActivityEditData = {\n id: string\n /** Record version for the OSS optimistic-lock header on edit (#2055). */\n updatedAt?: string | null\n /**\n * The activity's own linked person/company id, captured at edit time. Callers\n * that show activities from more than one entity (e.g. the deal detail page's\n * multi-entity activity list) must set this so `ScheduleActivityDialog` keeps\n * the edit payload's `entityId` pinned to the activity's actual record instead\n * of whichever entity happens to be selected in the host page's picker (#6050).\n */\n entityId?: string | null\n interactionType?: string\n title?: string | null\n body?: string | null\n scheduledAt?: string | null\n /**\n * Historical timestamp for completed activities (status `done`). Required for\n * the edit prefill to restore the original date/time instead of falling back\n * to \"today\" (#1807).\n */\n occurredAt?: string | null\n durationMinutes?: number | null\n /** Interaction priority column (0-100, nullable) backing the task priority control (#5943). */\n priority?: number | null\n location?: string | null\n allDay?: boolean | null\n recurrenceRule?: string | null\n recurrenceEnd?: string | null\n participants?: Array<{ userId?: string; name?: string; email?: string; status?: string }> | null\n reminderMinutes?: number | null\n visibility?: string | null\n linkedEntities?: Array<{ id: string; type: string; label: string }> | null\n guestPermissions?: { canInviteOthers?: boolean; canModify?: boolean; canSeeList?: boolean } | null\n}\n\nexport const PARTICIPANT_COLORS = [\n 'bg-chart-emerald',\n 'bg-chart-blue',\n 'bg-chart-orange',\n 'bg-chart-violet',\n 'bg-chart-pink',\n 'bg-chart-teal',\n]\n\n// Per-Figma defaults for the Reminder dropdown when the user picks an activity\n// type. Meeting/email keep the standard 15 min; tasks default to 1 day (1440 min)\n// because they're plan-ahead artefacts; calls default to 5 min as a stand-in for\n// the Figma \"After call ends\" treatment (which would need a non-numeric sentinel\n// in the API contract \u2014 tracked as a follow-up).\nconst DEFAULT_REMINDER_MINUTES: Record<ActivityType, number> = {\n meeting: 15,\n call: 5,\n task: 1440,\n email: 15,\n note: 15,\n}\n\n// Create-mode date/time defaults. A fixed morning slot made every activity opened\n// later in the day start in the past, so the seed is always computed forward from\n// \"now\" (#5940): tasks are plan-ahead artefacts and default to the end of the\n// working day, everything else to the next half-hour slot.\nconst DEFAULT_SLOT_MINUTES = 30\nconst TASK_DEFAULT_HOUR = 17\nconst NEXT_DAY_START_HOUR = 9\n\nfunction padDatePart(value: number): string {\n return String(value).padStart(2, '0')\n}\n\nfunction isSameLocalDay(left: Date, right: Date): boolean {\n return (\n left.getFullYear() === right.getFullYear() &&\n left.getMonth() === right.getMonth() &&\n left.getDate() === right.getDate()\n )\n}\n\nfunction nextSlotAfter(now: Date): Date {\n const next = new Date(now)\n next.setSeconds(0, 0)\n next.setMinutes(next.getMinutes() + (DEFAULT_SLOT_MINUTES - (next.getMinutes() % DEFAULT_SLOT_MINUTES)))\n if (!isSameLocalDay(next, now)) {\n next.setHours(NEXT_DAY_START_HOUR, 0, 0, 0)\n }\n return next\n}\n\n/**\n * Default start moment for a newly created activity of `type`, always strictly\n * after `now` so a brand-new record is never born overdue (#5940).\n */\nexport function resolveDefaultActivityStart(type: ActivityType, now: Date): Date {\n if (type === 'task') {\n const endOfWorkingDay = new Date(now)\n endOfWorkingDay.setHours(TASK_DEFAULT_HOUR, 0, 0, 0)\n if (endOfWorkingDay.getTime() > now.getTime()) return endOfWorkingDay\n }\n return nextSlotAfter(now)\n}\n\nfunction formatLocalDateInput(date: Date): string {\n return `${date.getFullYear()}-${padDatePart(date.getMonth() + 1)}-${padDatePart(date.getDate())}`\n}\n\nfunction formatLocalTimeInput(date: Date): string {\n return `${padDatePart(date.getHours())}:${padDatePart(date.getMinutes())}`\n}\n\ninterface UseScheduleFormStateParams {\n open: boolean\n editData: ScheduleActivityEditData | null | undefined\n}\n\nexport function useScheduleFormState({ open, editData }: UseScheduleFormStateParams) {\n // An empty `id` is the menu-driven \"New X\" convention \u2014 a create with a preset\n // type, not an edit. The save path already reads it this way (`isSaveEdit`), so\n // the seeding below must agree or new records inherit edit-mode fallbacks (#5940).\n const isEditing = Boolean(editData?.id)\n const [initialStart] = React.useState(() => resolveDefaultActivityStart('meeting', new Date()))\n // Holds the raw persisted/selected interaction type \u2014 may be a built-in Event, a\n // custom dictionary key, or a historical key the type picker no longer offers\n // (#7486). Lookups into the five-kind presentation maps (`FIELD_VISIBILITY`,\n // `TYPE_CHROME`, `DEFAULT_REMINDER_MINUTES`) must resolve through\n // `resolveScheduleActivityType` first; this state is saved back verbatim.\n const [activityType, setActivityType] = React.useState<string>('meeting')\n const [title, setTitle] = React.useState('')\n const [date, setDate] = React.useState(() => formatLocalDateInput(initialStart))\n const [startTime, setStartTime] = React.useState(() => formatLocalTimeInput(initialStart))\n const [duration, setDuration] = React.useState(30)\n const [allDay, setAllDay] = React.useState(false)\n const [description, setDescription] = React.useState('')\n const [markdownEnabled, setMarkdownEnabled] = React.useState(true)\n const [location, setLocation] = React.useState('')\n const [reminderMinutes, setReminderMinutes] = React.useState(15)\n const [visibility, setVisibility] = React.useState('team')\n const [participants, setParticipants] = React.useState<Participant[]>([])\n const [linkedEntities, setLinkedEntities] = React.useState<LinkedEntity[]>([])\n const [recurrenceEnabled, setRecurrenceEnabled] = React.useState(false)\n const [recurrenceDays, setRecurrenceDays] = React.useState<boolean[]>([true, false, true, false, false, false, false])\n const [recurrenceEndType, setRecurrenceEndType] = React.useState<'never' | 'count' | 'date'>('never')\n const [recurrenceCount, setRecurrenceCount] = React.useState(8)\n const [recurrenceEndDate, setRecurrenceEndDate] = React.useState('')\n const [conflict, setConflict] = React.useState<string | null>(null)\n const [saving, setSaving] = React.useState(false)\n const [guestPermissions, setGuestPermissions] = React.useState({ canInviteOthers: true, canModify: false, canSeeList: true })\n\n React.useEffect(() => {\n if (open) {\n if (editData) {\n // Edit mode: populate from existing interaction\n const rawType = editData.interactionType ?? 'meeting'\n const resolvedType = resolveScheduleActivityType(rawType)\n setActivityType(rawType)\n setTitle(editData.title ?? '')\n // `scheduledAt` is the canonical term of anything that was ever planned, so it\n // wins whenever it is set: the save path recomputes `scheduledAt` from these\n // seeded date/time fields, and seeding from `occurredAt` first silently\n // overwrote a completed task's due date on unrelated edits (#5939).\n // `occurredAt` stays the fallback for purely historical entries (a logged call\n // or note) that never had a `scheduledAt`, so editing those still restores\n // their actual moment instead of falling back to \"today\" (#1807).\n // Keep seed values in the user's local timezone, matching the cluster-E\n // local-day convention.\n const sourceTimestamp = editData.scheduledAt ?? editData.occurredAt ?? null\n const seedDate = sourceTimestamp ? new Date(sourceTimestamp) : null\n const seedDateValid = seedDate !== null && !Number.isNaN(seedDate.getTime())\n // A real edit of an undated task must stay undated: falling back to a\n // computed default here would silently give a backlog item a due date on\n // the next save (#5941). Menu-driven \"New Task\" (no id yet, so `isEditing`\n // is false) still gets the create-mode default so #5940's forward-seeded\n // default keeps working.\n if (isEditing && !seedDateValid && !isDateRequired(resolvedType)) {\n setDate('')\n setStartTime('')\n } else {\n const dateForForm = seedDateValid ? (seedDate as Date) : resolveDefaultActivityStart(resolvedType, new Date())\n setDate(formatLocalDateInput(dateForForm))\n setStartTime(formatLocalTimeInput(dateForForm))\n }\n setDuration(editData.durationMinutes ?? 30)\n setAllDay(editData.allDay ?? false)\n setDescription(editData.body ?? '')\n setLocation(editData.location ?? '')\n // Use per-type default when the editData omits an explicit reminder\n // (the menu-driven \"New X\" flow opens the dialog with `reminderMinutes: null`).\n setReminderMinutes(editData.reminderMinutes ?? DEFAULT_REMINDER_MINUTES[resolvedType])\n setVisibility(editData.visibility ?? 'team')\n setParticipants(\n Array.isArray(editData.participants)\n ? editData.participants.map((p, i) => ({\n userId: p.userId,\n name: p.name ?? p.email ?? p.userId ?? '',\n email: p.email,\n color: PARTICIPANT_COLORS[i % PARTICIPANT_COLORS.length],\n status: (p.status ?? 'pending') as RsvpStatus,\n }))\n : [],\n )\n setLinkedEntities(\n Array.isArray(editData.linkedEntities)\n ? editData.linkedEntities.map((e) => ({ id: e.id, type: e.type as LinkedEntity['type'], label: e.label }))\n : [],\n )\n if (editData.recurrenceRule) {\n setRecurrenceEnabled(true)\n // Parse RRULE to set days and end type\n const rule = editData.recurrenceRule\n const byDayMatch = rule.match(/BYDAY=([A-Z,]+)/)\n if (byDayMatch) {\n const dayNames = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU']\n const activeDays = byDayMatch[1].split(',')\n setRecurrenceDays(dayNames.map((d) => activeDays.includes(d)))\n }\n const countMatch = rule.match(/COUNT=(\\d+)/)\n const untilMatch = rule.match(/UNTIL=(\\d{8})/)\n if (countMatch) {\n setRecurrenceEndType('count')\n setRecurrenceCount(Number(countMatch[1]))\n } else if (untilMatch) {\n setRecurrenceEndType('date')\n const raw = untilMatch[1]\n setRecurrenceEndDate(`${raw.slice(0, 4)}-${raw.slice(4, 6)}-${raw.slice(6, 8)}`)\n } else {\n setRecurrenceEndType('never')\n }\n } else {\n setRecurrenceEnabled(false)\n }\n if (editData.guestPermissions) {\n setGuestPermissions({\n canInviteOthers: editData.guestPermissions.canInviteOthers ?? true,\n canModify: editData.guestPermissions.canModify ?? false,\n canSeeList: editData.guestPermissions.canSeeList ?? true,\n })\n }\n } else {\n // Create mode: reset all fields\n const defaultStart = resolveDefaultActivityStart('meeting', new Date())\n setActivityType('meeting')\n setTitle('')\n setDate(formatLocalDateInput(defaultStart))\n setStartTime(formatLocalTimeInput(defaultStart))\n setDuration(30)\n setAllDay(false)\n setDescription('')\n setLocation('')\n setReminderMinutes(DEFAULT_REMINDER_MINUTES.meeting)\n setVisibility('team')\n setParticipants([])\n setLinkedEntities([])\n setRecurrenceEnabled(false)\n }\n setConflict(null)\n }\n return () => {\n // Safety net: restore body scroll if Radix Dialog fails to clean up\n document.body.style.removeProperty('overflow')\n document.body.style.removeProperty('pointer-events')\n }\n }, [open, editData, isEditing])\n\n // Update the Reminder default when the activity type changes in create mode.\n // Skipped in edit mode (the persisted value wins), and gated by `open` to\n // avoid flipping the default in a closed-but-mounted dialog.\n const lastReminderTypeRef = React.useRef<string>('meeting')\n React.useEffect(() => {\n if (!open || isEditing) {\n lastReminderTypeRef.current = activityType\n return\n }\n if (lastReminderTypeRef.current === activityType) return\n lastReminderTypeRef.current = activityType\n setReminderMinutes(DEFAULT_REMINDER_MINUTES[resolveScheduleActivityType(activityType)])\n }, [activityType, isEditing, open])\n\n const removeParticipant = React.useCallback((index: number) => {\n setParticipants((prev) => prev.filter((_, i) => i !== index))\n }, [])\n\n const toggleRecurrenceDay = React.useCallback((index: number) => {\n setRecurrenceDays((prev) => {\n const next = [...prev]\n next[index] = !next[index]\n return next\n })\n }, [])\n\n return {\n activityType,\n setActivityType,\n title,\n setTitle,\n date,\n setDate,\n startTime,\n setStartTime,\n duration,\n setDuration,\n allDay,\n setAllDay,\n description,\n setDescription,\n markdownEnabled,\n setMarkdownEnabled,\n location,\n setLocation,\n reminderMinutes,\n setReminderMinutes,\n visibility,\n setVisibility,\n participants,\n setParticipants,\n linkedEntities,\n setLinkedEntities,\n recurrenceEnabled,\n setRecurrenceEnabled,\n recurrenceDays,\n setRecurrenceDays,\n recurrenceEndType,\n setRecurrenceEndType,\n recurrenceCount,\n setRecurrenceCount,\n recurrenceEndDate,\n setRecurrenceEndDate,\n conflict,\n setConflict,\n saving,\n setSaving,\n guestPermissions,\n setGuestPermissions,\n removeParticipant,\n toggleRecurrenceDay,\n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9D,GAAG,CAAC,CAAC;AAEL,QAAM,sBAAsB,MAAM,YAAY,CAAC,UAAkB;AAC/D,sBAAkB,CAAC,SAAS;AAC1B,YAAM,OAAO,CAAC,GAAG,IAAI;AACrB,WAAK,KAAK,IAAI,CAAC,KAAK,KAAK;AACzB,aAAO;AAAA,IACT,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -885,7 +885,7 @@ function assertClaimUpdateFields(claim, input) {
|
|
|
885
885
|
}
|
|
886
886
|
function applyClaimUpdate(claim, input, customerName, orderNumber) {
|
|
887
887
|
if (hasOwn(input, "customerId")) claim.customerId = input.customerId ?? null;
|
|
888
|
-
if (hasOwn(input, "customerName")) claim.customerName = customerName;
|
|
888
|
+
if (hasOwn(input, "customerId") || hasOwn(input, "customerName")) claim.customerName = customerName;
|
|
889
889
|
if (hasOwn(input, "orderId")) {
|
|
890
890
|
claim.orderId = input.orderId ?? null;
|
|
891
891
|
claim.orderNumber = orderNumber;
|
|
@@ -1106,7 +1106,7 @@ const updateClaimCommand = {
|
|
|
1106
1106
|
await assertOrderBelongsToCustomer(em, scope, effectiveOrderId, effectiveCustomerId);
|
|
1107
1107
|
const customerChanged = hasOwn(input, "customerId") && (input.customerId ?? null) !== (claim.customerId ?? null);
|
|
1108
1108
|
const shouldRefreshCustomerName = hasOwn(input, "customerId") || hasOwn(input, "customerName");
|
|
1109
|
-
const customerName = shouldRefreshCustomerName ? await resolveCustomerName(ctx,
|
|
1109
|
+
const customerName = shouldRefreshCustomerName ? await resolveCustomerName(ctx, effectiveCustomerId, scope, customerChanged ? input.customerName : input.customerName ?? claim.customerName, { strict: customerChanged }) : claim.customerName ?? null;
|
|
1110
1110
|
const orderNumber = hasOwn(input, "orderId") ? await resolveOrderNumber(ctx, input.orderId, scope, (input.orderId ?? null) === (claim.orderId ?? null) ? claim.orderNumber : null) : claim.orderNumber ?? null;
|
|
1111
1111
|
await withAtomicFlush(em, [
|
|
1112
1112
|
async () => {
|