@open-mercato/core 0.10.1-develop.7668.1.3aa8463bd8 → 0.10.1-develop.7670.1.7b5ad74924

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.
@@ -3,7 +3,7 @@ export { ParticipantsField } from './ParticipantsField'
3
3
  export { LocationField } from './LocationField'
4
4
  export { FooterFields } from './FooterFields'
5
5
  export { LinkedEntitiesField } from './LinkedEntitiesField'
6
- export { isVisible, isDateRequired, isTimeRequired, getFieldLabel, FIELD_VISIBILITY, FIELD_LABEL_OVERRIDES } from './fieldConfig'
6
+ export { isVisible, isDateRequired, isTimeRequired, getFieldLabel, resolveScheduleActivityType, FIELD_VISIBILITY, FIELD_LABEL_OVERRIDES } from './fieldConfig'
7
7
  export type { ActivityType, ScheduleFieldId } from './fieldConfig'
8
8
  export { useScheduleFormState, PARTICIPANT_COLORS } from './useScheduleFormState'
9
9
  export type { Participant, LinkedEntity, RsvpStatus, ScheduleActivityEditData } from './useScheduleFormState'
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react'
2
2
  import type { ActivityType } from './fieldConfig'
3
- import { isDateRequired } from './fieldConfig'
3
+ import { isDateRequired, resolveScheduleActivityType } from './fieldConfig'
4
4
 
5
5
  export type RsvpStatus = 'pending' | 'accepted' | 'declined' | 'tentative'
6
6
 
@@ -138,7 +138,12 @@ export function useScheduleFormState({ open, editData }: UseScheduleFormStatePar
138
138
  // the seeding below must agree or new records inherit edit-mode fallbacks (#5940).
139
139
  const isEditing = Boolean(editData?.id)
140
140
  const [initialStart] = React.useState(() => resolveDefaultActivityStart('meeting', new Date()))
141
- const [activityType, setActivityType] = React.useState<ActivityType>('meeting')
141
+ // Holds the raw persisted/selected interaction type — may be a built-in Event, a
142
+ // custom dictionary key, or a historical key the type picker no longer offers
143
+ // (#7486). Lookups into the five-kind presentation maps (`FIELD_VISIBILITY`,
144
+ // `TYPE_CHROME`, `DEFAULT_REMINDER_MINUTES`) must resolve through
145
+ // `resolveScheduleActivityType` first; this state is saved back verbatim.
146
+ const [activityType, setActivityType] = React.useState<string>('meeting')
142
147
  const [title, setTitle] = React.useState('')
143
148
  const [date, setDate] = React.useState(() => formatLocalDateInput(initialStart))
144
149
  const [startTime, setStartTime] = React.useState(() => formatLocalTimeInput(initialStart))
@@ -164,8 +169,9 @@ export function useScheduleFormState({ open, editData }: UseScheduleFormStatePar
164
169
  if (open) {
165
170
  if (editData) {
166
171
  // Edit mode: populate from existing interaction
167
- const resolvedType = (editData.interactionType as ActivityType) ?? 'meeting'
168
- setActivityType(resolvedType)
172
+ const rawType = editData.interactionType ?? 'meeting'
173
+ const resolvedType = resolveScheduleActivityType(rawType)
174
+ setActivityType(rawType)
169
175
  setTitle(editData.title ?? '')
170
176
  // `scheduledAt` is the canonical term of anything that was ever planned, so it
171
177
  // wins whenever it is set: the save path recomputes `scheduledAt` from these
@@ -277,7 +283,7 @@ export function useScheduleFormState({ open, editData }: UseScheduleFormStatePar
277
283
  // Update the Reminder default when the activity type changes in create mode.
278
284
  // Skipped in edit mode (the persisted value wins), and gated by `open` to
279
285
  // avoid flipping the default in a closed-but-mounted dialog.
280
- const lastReminderTypeRef = React.useRef<ActivityType>('meeting')
286
+ const lastReminderTypeRef = React.useRef<string>('meeting')
281
287
  React.useEffect(() => {
282
288
  if (!open || isEditing) {
283
289
  lastReminderTypeRef.current = activityType
@@ -285,7 +291,7 @@ export function useScheduleFormState({ open, editData }: UseScheduleFormStatePar
285
291
  }
286
292
  if (lastReminderTypeRef.current === activityType) return
287
293
  lastReminderTypeRef.current = activityType
288
- setReminderMinutes(DEFAULT_REMINDER_MINUTES[activityType])
294
+ setReminderMinutes(DEFAULT_REMINDER_MINUTES[resolveScheduleActivityType(activityType)])
289
295
  }, [activityType, isEditing, open])
290
296
 
291
297
  const removeParticipant = React.useCallback((index: number) => {