@trii/components 2.0.31 → 2.0.34

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 (21) hide show
  1. package/dist/cjs/index.js +53 -55
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/components/EditContactModal/components/Section/AddressInformation/AddressInformation.d.ts +2 -1
  4. package/dist/cjs/types/components/EditContactModal/components/Section/General/General.d.ts +1 -0
  5. package/dist/cjs/types/components/EditContactModal/hooks/useEditContact/types/UseEditContact.d.ts +0 -3
  6. package/dist/cjs/types/components/EditContactModal/shared/BusinessInfoLabel/BusinessInfoLabel.d.ts +2 -1
  7. package/dist/cjs/types/components/EditContactModal/shared/ContactInfoLabel/ContactInfoLabel.d.ts +1 -0
  8. package/dist/cjs/types/components/EditContactModal/shared/ContactInfoLabel/components/index.d.ts +0 -1
  9. package/dist/cjs/types/components/EditContactModal/shared/EntityCustomFieldLabel/EntityCustomFieldLabel.d.ts +2 -1
  10. package/dist/cjs/types/components/EditContactModal/shared/EntityInfoLabel/EntityInfoLabel.d.ts +1 -0
  11. package/dist/esm/index.js +53 -55
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/types/components/EditContactModal/components/Section/AddressInformation/AddressInformation.d.ts +2 -1
  14. package/dist/esm/types/components/EditContactModal/components/Section/General/General.d.ts +1 -0
  15. package/dist/esm/types/components/EditContactModal/hooks/useEditContact/types/UseEditContact.d.ts +0 -3
  16. package/dist/esm/types/components/EditContactModal/shared/BusinessInfoLabel/BusinessInfoLabel.d.ts +2 -1
  17. package/dist/esm/types/components/EditContactModal/shared/ContactInfoLabel/ContactInfoLabel.d.ts +1 -0
  18. package/dist/esm/types/components/EditContactModal/shared/ContactInfoLabel/components/index.d.ts +0 -1
  19. package/dist/esm/types/components/EditContactModal/shared/EntityCustomFieldLabel/EntityCustomFieldLabel.d.ts +2 -1
  20. package/dist/esm/types/components/EditContactModal/shared/EntityInfoLabel/EntityInfoLabel.d.ts +1 -0
  21. package/package.json +1 -1
@@ -5,6 +5,7 @@ export type AddressInformationProps = {
5
5
  baseUrl?: string;
6
6
  spaceId?: string;
7
7
  t: (key: string) => string;
8
+ onEntityUpdated?: (entity: unknown) => void;
8
9
  };
9
- declare const AddressInformation: ({ entityType, entityData, baseUrl, spaceId, t }: AddressInformationProps) => import("react/jsx-runtime").JSX.Element;
10
+ declare const AddressInformation: ({ entityType, entityData, baseUrl, spaceId, t, onEntityUpdated, }: AddressInformationProps) => import("react/jsx-runtime").JSX.Element;
10
11
  export default AddressInformation;
@@ -9,6 +9,7 @@ export interface GeneralProps {
9
9
  spaceId?: string;
10
10
  t: (key: string) => string;
11
11
  currentUser?: UserTrii | null;
12
+ onEntityUpdated?: (entity: unknown) => void;
12
13
  }
13
14
  declare const General: (props: GeneralProps) => import("react/jsx-runtime").JSX.Element;
14
15
  export default General;
@@ -7,7 +7,6 @@ import type { UseMultipleSelectReturnType } from '../../useMultipleSelect';
7
7
  import type { ILabel } from '@trii/types/dist/Contacts';
8
8
  import type { ChannelType } from '@trii/types/dist/Common/Channels';
9
9
  import type { Dayjs } from 'dayjs';
10
- import type { SimplifiedBusiness } from '../../../shared/ContactInfoLabel/components/BusinessSelect/types';
11
10
  type UseEditContact = {
12
11
  field: {
13
12
  imsMercadolibre: IContactAddress[];
@@ -35,7 +34,6 @@ type UseEditContact = {
35
34
  secondaryCountry: UseFieldType;
36
35
  customProperties: Property[];
37
36
  labelMultipleSelect: UseMultipleSelectReturnType<ILabel[]>;
38
- selectedBusiness: SimplifiedBusiness[];
39
37
  };
40
38
  action: {
41
39
  setCustomProperties: (customProperties: Property[]) => void;
@@ -50,7 +48,6 @@ type UseEditContact = {
50
48
  replaceAddress: (addressId: string, newAddress: IContactAddress) => void;
51
49
  addWhatsappVerified: (newAddress: IContactAddress) => void;
52
50
  setBirthDate: (date: Dayjs | null) => void;
53
- setSelectedBusiness: (business: SimplifiedBusiness[]) => void;
54
51
  resetToInitialContactInformation: () => void;
55
52
  resetSelectedBusiness: () => void;
56
53
  resetBirthDate: () => void;
@@ -10,6 +10,7 @@ type Props = {
10
10
  baseUrl?: string;
11
11
  spaceId?: string;
12
12
  businessId?: string;
13
+ onEntityUpdated?: (entity: unknown) => void;
13
14
  };
14
- declare const BusinessInfoLabel: ({ title, value, isNotEditable, inputType, options, displayValue, constructUpdateObject, baseUrl, spaceId, businessId, }: Props) => import("react/jsx-runtime").JSX.Element;
15
+ declare const BusinessInfoLabel: ({ title, value, isNotEditable, inputType, options, displayValue, constructUpdateObject, baseUrl, spaceId, businessId, onEntityUpdated, }: Props) => import("react/jsx-runtime").JSX.Element;
15
16
  export default BusinessInfoLabel;
@@ -13,6 +13,7 @@ type BaseProps = {
13
13
  spaceId?: string;
14
14
  contactId?: string;
15
15
  t: (key: string) => string;
16
+ onEntityUpdated?: (entity: unknown) => void;
16
17
  };
17
18
  type BirthdayProps = BaseProps & {
18
19
  inputType: 'birthday';
@@ -1,2 +1 @@
1
- export { default as BusinessSelect } from './BusinessSelect';
2
1
  export { default as DateSelect } from './DateSelect';
@@ -13,6 +13,7 @@ type Props = {
13
13
  baseUrl?: string;
14
14
  spaceId?: string;
15
15
  t: (key: string) => string;
16
+ onEntityUpdated?: (entity: unknown) => void;
16
17
  };
17
- declare const EntityCustomFieldLabel: ({ property, entity, entityType, entityId, customContactFields, userTrii, baseUrl, spaceId, t, }: Props) => import("react/jsx-runtime").JSX.Element;
18
+ declare const EntityCustomFieldLabel: ({ property, entity, entityType, entityId, customContactFields, userTrii, baseUrl, spaceId, t, onEntityUpdated, }: Props) => import("react/jsx-runtime").JSX.Element;
18
19
  export default EntityCustomFieldLabel;
@@ -9,6 +9,7 @@ type SharedProps = {
9
9
  baseUrl?: string;
10
10
  spaceId?: string;
11
11
  minWidth?: string | number;
12
+ onEntityUpdated?: (entity: unknown) => void;
12
13
  };
13
14
  type ContactBaseProps = SharedProps & {
14
15
  entityType: 'contact';
package/dist/esm/index.js CHANGED
@@ -4,12 +4,6 @@ import { styled as styled$4, Box as Box$2, IconButton as IconButton$2, Avatar, T
4
4
  import { withEmotionCache, ThemeContext, CacheProvider, Global, css, keyframes } from '@emotion/react';
5
5
  import * as ReactDOM from 'react-dom';
6
6
  import ReactDOM__default from 'react-dom';
7
- import 'react-i18next';
8
- import 'features/Views/BusinessCreate/hooks/useCreateBusiness/useCreateBusiness';
9
- import 'react-redux';
10
- import 'hooks/useAppDispatch';
11
- import 'ReduxToolkit/features/businessSlice/businessSlice';
12
- import 'ReduxToolkit/features/contactsSlice/contactsSlice';
13
7
 
14
8
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
15
9
 
@@ -25838,7 +25832,7 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
25838
25832
  const apiDispatch = async (maybePromise) => maybePromise;
25839
25833
  const { getEditedField } = editContactHelper;
25840
25834
  const [customProperties, setCustomProperties] = useState([]);
25841
- const [selectedBusiness, setSelectedBusiness] = useState([]);
25835
+ // const [selectedBusiness, setSelectedBusiness] = useState<SimplifiedBusiness[]>([]);
25842
25836
  const contactFirstname = useField$1('text', contact?.firstName || '');
25843
25837
  const contactLastname = useField$1('text', contact?.lastName || '');
25844
25838
  const contactImage = useImage({
@@ -25917,8 +25911,8 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
25917
25911
  ? contactImage.removeParams(contactImage.imageUrl)
25918
25912
  : null,
25919
25913
  properties: customProperties,
25920
- businessId: selectedBusiness[0]?.businessId || '',
25921
- businessName: selectedBusiness[0]?.businessName || '',
25914
+ // businessId: selectedBusiness[0]?.businessId || '',
25915
+ // businessName: selectedBusiness[0]?.businessName || '',
25922
25916
  birthDate: birthDate?.toDate(),
25923
25917
  };
25924
25918
  return editedContact;
@@ -25928,12 +25922,12 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
25928
25922
  if (!contact)
25929
25923
  return;
25930
25924
  if (!contact.businessId || !contact.businessName) {
25931
- setSelectedBusiness([]);
25925
+ // setSelectedBusiness([]);
25932
25926
  return;
25933
25927
  }
25934
- setSelectedBusiness([
25935
- { businessId: contact.businessId, businessName: contact.businessName },
25936
- ]);
25928
+ // setSelectedBusiness([
25929
+ // { businessId: contact.businessId, businessName: contact.businessName },
25930
+ // ]);
25937
25931
  }
25938
25932
  function resetBirthDate() {
25939
25933
  setBirthDate(contact?.birthDate ? dayjs(contact.birthDate) : null);
@@ -25987,14 +25981,7 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
25987
25981
  if (contact?.tags) {
25988
25982
  labelMultipleSelect.actions.setValue(contact.tags);
25989
25983
  }
25990
- if (contact?.businessId && contact.businessName) {
25991
- setSelectedBusiness([
25992
- { businessId: contact.businessId, businessName: contact.businessName },
25993
- ]);
25994
- }
25995
- else {
25996
- setSelectedBusiness([]);
25997
- }
25984
+ if (contact?.businessId && contact.businessName) ;
25998
25985
  }, [contact]);
25999
25986
  return {
26000
25987
  field: {
@@ -26023,7 +26010,7 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
26023
26010
  secondaryCountry,
26024
26011
  customProperties,
26025
26012
  labelMultipleSelect,
26026
- selectedBusiness,
26013
+ // selectedBusiness,
26027
26014
  },
26028
26015
  action: {
26029
26016
  setBirthDate,
@@ -26037,7 +26024,7 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
26037
26024
  addWhatsapp,
26038
26025
  addRCS,
26039
26026
  replaceAddress,
26040
- setSelectedBusiness,
26027
+ // setSelectedBusiness,
26041
26028
  addWhatsappVerified,
26042
26029
  resetToInitialContactInformation,
26043
26030
  resetSelectedBusiness,
@@ -26060,13 +26047,6 @@ const resolveUserLabel = ({ userId, users, currentUser, }) => {
26060
26047
  return fromUsers?.name?.trim() || fromUsers?.email || null;
26061
26048
  };
26062
26049
 
26063
- styled$4('div')({
26064
- display: 'flex',
26065
- alignItems: 'center',
26066
- justifyContent: 'space-around',
26067
- padding: '16px',
26068
- });
26069
-
26070
26050
  var weekOfYear = {exports: {}};
26071
26051
 
26072
26052
  (function (module, exports) {
@@ -52182,7 +52162,7 @@ const StyledSaveCancelButton$1 = styled$4(IconButton$2)({
52182
52162
  },
52183
52163
  });
52184
52164
  const EntityInfoLabel = (props) => {
52185
- const { title, value, isNotEditable, displayValue, baseUrl, spaceId, minWidth, } = props;
52165
+ const { title, value, isNotEditable, displayValue, baseUrl, spaceId, minWidth, onEntityUpdated, } = props;
52186
52166
  const inputType = props.inputType ?? 'text';
52187
52167
  const [isEditing, setIsEditing] = useState(false);
52188
52168
  const [isSaving, setIsSaving] = useState(false);
@@ -52248,13 +52228,14 @@ const EntityInfoLabel = (props) => {
52248
52228
  if (!entityId) {
52249
52229
  throw new Error('Missing contactId for updateEntity');
52250
52230
  }
52251
- await updateEntity({
52231
+ const updated = await updateEntity({
52252
52232
  baseUrl,
52253
52233
  spaceId,
52254
52234
  entityType: 'contact',
52255
52235
  entityId,
52256
52236
  body: updatedContactData,
52257
52237
  });
52238
+ onEntityUpdated?.(updated);
52258
52239
  }
52259
52240
  else {
52260
52241
  const updatedBusinessData = props.constructUpdateObject(inputValue);
@@ -52262,13 +52243,14 @@ const EntityInfoLabel = (props) => {
52262
52243
  if (!entityId) {
52263
52244
  throw new Error('Missing businessId for updateEntity');
52264
52245
  }
52265
- await updateEntity({
52246
+ const updated = await updateEntity({
52266
52247
  baseUrl,
52267
52248
  spaceId,
52268
52249
  entityType: 'business',
52269
52250
  entityId,
52270
52251
  body: updatedBusinessData,
52271
52252
  });
52253
+ onEntityUpdated?.(updated);
52272
52254
  }
52273
52255
  }
52274
52256
  finally {
@@ -52299,12 +52281,12 @@ const EntityInfoLabel = (props) => {
52299
52281
  };
52300
52282
 
52301
52283
  const ContactInfoLabel = (props) => {
52302
- const { title, value, isNotEditable, options = [], displayValue, constructUpdateObject, businessId, baseUrl, spaceId, contactId, t, } = props;
52284
+ const { title, value, isNotEditable, options = [], displayValue, constructUpdateObject, businessId, baseUrl, spaceId, contactId, t, onEntityUpdated, } = props;
52303
52285
  if (props.inputType === 'birthday') {
52304
- return (jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: "contact", entityId: contactId, title: title, value: value, isNotEditable: isNotEditable, inputType: "birthday", options: options, displayValue: displayValue, constructUpdateObject: constructUpdateObject, contact: props.contact, businessId: businessId, baseUrl: baseUrl, spaceId: spaceId, t: t, dateFormat: props.dateFormat }));
52286
+ return (jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: "contact", entityId: contactId, title: title, value: value, isNotEditable: isNotEditable, inputType: "birthday", options: options, displayValue: displayValue, constructUpdateObject: constructUpdateObject, contact: props.contact, businessId: businessId, baseUrl: baseUrl, spaceId: spaceId, t: t, dateFormat: props.dateFormat, onEntityUpdated: onEntityUpdated }));
52305
52287
  }
52306
52288
  const inputType = props.inputType ?? 'text';
52307
- return (jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: "contact", entityId: contactId, title: title, value: value, isNotEditable: isNotEditable, inputType: inputType, options: options, displayValue: displayValue, constructUpdateObject: constructUpdateObject, businessId: businessId, baseUrl: baseUrl, spaceId: spaceId, t: t }));
52289
+ return (jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: "contact", entityId: contactId, title: title, value: value, isNotEditable: isNotEditable, inputType: inputType, options: options, displayValue: displayValue, constructUpdateObject: constructUpdateObject, businessId: businessId, baseUrl: baseUrl, spaceId: spaceId, t: t, onEntityUpdated: onEntityUpdated }));
52308
52290
  };
52309
52291
 
52310
52292
  const CustomPropertyInput = ({ nameKey, value, onChange, type, }) => {
@@ -54140,7 +54122,7 @@ const FieldValue = styled$4(Typography$2)(({ theme }) => ({
54140
54122
  overflow: 'auto',
54141
54123
  whiteSpace: 'break-spaces',
54142
54124
  }));
54143
- const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, customContactFields, userTrii, baseUrl, spaceId, t, }) => {
54125
+ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, customContactFields, userTrii, baseUrl, spaceId, t, onEntityUpdated, }) => {
54144
54126
  const { customProperties } = entity.field;
54145
54127
  const { setCustomProperties } = entity.action;
54146
54128
  const [isEditing, setIsEditing] = useState(false);
@@ -54225,13 +54207,22 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
54225
54207
  ],
54226
54208
  };
54227
54209
  try {
54228
- await updateEntity({
54210
+ const updated = await updateEntity({
54229
54211
  baseUrl,
54230
54212
  spaceId,
54231
54213
  entityType,
54232
54214
  entityId,
54233
54215
  body: updatedContactData,
54234
54216
  });
54217
+ const nextProperties = customProperties.map((p) => p.nameKey === nameKey
54218
+ ? {
54219
+ ...p,
54220
+ type: effectiveType,
54221
+ value: finalValue,
54222
+ }
54223
+ : p);
54224
+ setCustomProperties(nextProperties);
54225
+ onEntityUpdated?.(updated);
54235
54226
  }
54236
54227
  finally {
54237
54228
  setIsSaving(false);
@@ -54350,7 +54341,7 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
54350
54341
  };
54351
54342
 
54352
54343
  const ContactGeneral = (props) => {
54353
- const { dateFormat, entityData, customContactFields, baseUrl, spaceId, t, currentUser } = props;
54344
+ const { dateFormat, entityData, customContactFields, baseUrl, spaceId, t, currentUser, onEntityUpdated } = props;
54354
54345
  const [users, setUsers] = useState([]);
54355
54346
  const [owner, setOwner] = useState(null);
54356
54347
  const [updatedBy, setUpdatedBy] = useState(null);
@@ -54432,9 +54423,9 @@ const ContactGeneral = (props) => {
54432
54423
  };
54433
54424
  return (jsxRuntimeExports.jsx(Section, { title: "General", children: jsxRuntimeExports.jsxs(SectionContent, { children: [jsxRuntimeExports.jsx(ContactInfoLabel, { title: t('contactDetails.contactOwner'), displayValue: owner || '-', value: entityData.owner, inputType: "select", options: users, constructUpdateObject: (value) => ({
54434
54425
  owner: typeof value === 'string' ? value : '',
54435
- }), contact: editContact, baseUrl: baseUrl, spaceId: spaceId, contactId: entityData.id, t: t }), jsxRuntimeExports.jsx(ContactInfoLabel, { title: t('contactDetails.business'), displayValue: entityData.businessName || '-', value: entityData.businessId, inputType: "selectBusiness", businessId: entityData.businessId, contact: editContact, baseUrl: baseUrl, spaceId: spaceId, contactId: entityData.id, t: t }), jsxRuntimeExports.jsx(ContactInfoLabel, { title: t('contactDetails.createdBy'), value: createdBy || '-', isNotEditable: true, contact: editContact, baseUrl: baseUrl, spaceId: spaceId, contactId: entityData.id, t: t }), jsxRuntimeExports.jsx(ContactInfoLabel, { title: t('contactDetails.modifiedBy'), value: updatedBy || '-', isNotEditable: true, contact: editContact, baseUrl: baseUrl, spaceId: spaceId, contactId: entityData.id, t: t }), jsxRuntimeExports.jsx(ContactInfoLabel, { title: t('global.birthdate'), inputType: "birthday", displayValue: birthDate ? `${dateOnlyString} (${calculateAge(birthDate.toDate())})` : '-', value: birthDate ? birthDate.toISOString() : '', constructUpdateObject: (value) => ({
54426
+ }), contact: editContact, baseUrl: baseUrl, spaceId: spaceId, contactId: entityData.id, t: t, onEntityUpdated: onEntityUpdated }), jsxRuntimeExports.jsx(ContactInfoLabel, { title: t('contactDetails.business'), displayValue: entityData.businessName || '-', value: entityData.businessId, inputType: "selectBusiness", businessId: entityData.businessId, contact: editContact, baseUrl: baseUrl, spaceId: spaceId, contactId: entityData.id, t: t, onEntityUpdated: onEntityUpdated }), jsxRuntimeExports.jsx(ContactInfoLabel, { title: t('contactDetails.createdBy'), value: createdBy || '-', isNotEditable: true, contact: editContact, baseUrl: baseUrl, spaceId: spaceId, contactId: entityData.id, t: t }), jsxRuntimeExports.jsx(ContactInfoLabel, { title: t('contactDetails.modifiedBy'), value: updatedBy || '-', isNotEditable: true, contact: editContact, baseUrl: baseUrl, spaceId: spaceId, contactId: entityData.id, t: t }), jsxRuntimeExports.jsx(ContactInfoLabel, { title: t('global.birthdate'), inputType: "birthday", displayValue: birthDate ? `${dateOnlyString} (${calculateAge(birthDate.toDate())})` : '-', value: birthDate ? birthDate.toISOString() : '', constructUpdateObject: (value) => ({
54436
54427
  birthDate: value,
54437
- }), contact: editContact, baseUrl: baseUrl, spaceId: spaceId, contactId: entityData.id, t: t, dateFormat: dateFormat }), editContact.field.customProperties.map((property) => (jsxRuntimeExports.jsx(EntityCustomFieldLabel, { property: property, entity: editContact, entityType: "contact", entityId: String(entityData.id), customContactFields: customContactFields, userTrii: currentUser, baseUrl: baseUrl, spaceId: spaceId, t: t }, property.nameKey)))] }) }));
54428
+ }), contact: editContact, baseUrl: baseUrl, spaceId: spaceId, contactId: entityData.id, t: t, dateFormat: dateFormat, onEntityUpdated: onEntityUpdated }), editContact.field.customProperties.map((property) => (jsxRuntimeExports.jsx(EntityCustomFieldLabel, { property: property, entity: editContact, entityType: "contact", entityId: String(entityData.id), customContactFields: customContactFields, userTrii: currentUser, baseUrl: baseUrl, spaceId: spaceId, t: t, onEntityUpdated: onEntityUpdated }, property.nameKey)))] }) }));
54438
54429
  };
54439
54430
 
54440
54431
  const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) => {
@@ -54617,12 +54608,12 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
54617
54608
  };
54618
54609
  };
54619
54610
 
54620
- const BusinessInfoLabel = ({ title, value, isNotEditable, inputType = 'text', options = [], displayValue, constructUpdateObject, baseUrl, spaceId, businessId, }) => {
54621
- return (jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: "business", entityId: businessId, title: title, value: value, isNotEditable: isNotEditable, inputType: inputType, options: options, displayValue: displayValue, constructUpdateObject: constructUpdateObject, baseUrl: baseUrl, spaceId: spaceId }));
54611
+ const BusinessInfoLabel = ({ title, value, isNotEditable, inputType = 'text', options = [], displayValue, constructUpdateObject, baseUrl, spaceId, businessId, onEntityUpdated, }) => {
54612
+ return (jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: "business", entityId: businessId, title: title, value: value, isNotEditable: isNotEditable, inputType: inputType, options: options, displayValue: displayValue, constructUpdateObject: constructUpdateObject, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: onEntityUpdated }));
54622
54613
  };
54623
54614
 
54624
54615
  const BusinessGeneral = (props) => {
54625
- const { entityData, customContactFields, baseUrl, spaceId, t, currentUser } = props;
54616
+ const { entityData, customContactFields, baseUrl, spaceId, t, currentUser, onEntityUpdated } = props;
54626
54617
  const [users, setUsers] = useState([]);
54627
54618
  const [owner, setOwner] = useState(null);
54628
54619
  const [updatedBy, setUpdatedBy] = useState(null);
@@ -54692,7 +54683,7 @@ const BusinessGeneral = (props) => {
54692
54683
  }, [entityData, users, currentUser, baseUrl, spaceId]);
54693
54684
  return (jsxRuntimeExports.jsx(Section, { title: "General", children: jsxRuntimeExports.jsxs(SectionContent, { children: [jsxRuntimeExports.jsx(BusinessInfoLabel, { title: t('businessDetails.businessOwner'), value: entityData.owner, displayValue: owner || '-', inputType: "select", options: users, constructUpdateObject: (value) => ({
54694
54685
  owner: typeof value === 'string' ? value : '',
54695
- }), baseUrl: baseUrl, spaceId: spaceId, businessId: entityData.id }), jsxRuntimeExports.jsx(BusinessInfoLabel, { title: t('contactDetails.createdBy'), value: createdBy || '-', isNotEditable: true }), jsxRuntimeExports.jsx(BusinessInfoLabel, { title: t('contactDetails.modifiedBy'), value: updatedBy || '-', isNotEditable: true }), editBusiness.field.customProperties.map((property) => (jsxRuntimeExports.jsx(EntityCustomFieldLabel, { property: property, entity: editBusiness, entityType: "business", entityId: String(entityData.id), customContactFields: customContactFields, userTrii: currentUser, baseUrl: baseUrl, spaceId: spaceId, t: t }, property.nameKey)))] }) }));
54686
+ }), baseUrl: baseUrl, spaceId: spaceId, businessId: entityData.id, onEntityUpdated: onEntityUpdated }), jsxRuntimeExports.jsx(BusinessInfoLabel, { title: t('contactDetails.createdBy'), value: createdBy || '-', isNotEditable: true }), jsxRuntimeExports.jsx(BusinessInfoLabel, { title: t('contactDetails.modifiedBy'), value: updatedBy || '-', isNotEditable: true }), editBusiness.field.customProperties.map((property) => (jsxRuntimeExports.jsx(EntityCustomFieldLabel, { property: property, entity: editBusiness, entityType: "business", entityId: String(entityData.id), customContactFields: customContactFields, userTrii: currentUser, baseUrl: baseUrl, spaceId: spaceId, t: t, onEntityUpdated: onEntityUpdated }, property.nameKey)))] }) }));
54696
54687
  };
54697
54688
 
54698
54689
  const General = (props) => {
@@ -54705,11 +54696,12 @@ const General = (props) => {
54705
54696
  return normalizedEntityType === 'contact' ? (jsxRuntimeExports.jsx(ContactGeneral, { ...props, entityData: entityData, entityType: "contact" })) : (jsxRuntimeExports.jsx(BusinessGeneral, { ...props, entityData: entityData, entityType: "business" }));
54706
54697
  };
54707
54698
 
54708
- const AddressInformation = ({ entityType, entityData, baseUrl, spaceId, t }) => {
54699
+ const AddressInformation = ({ entityType, entityData, baseUrl, spaceId, t, onEntityUpdated, }) => {
54709
54700
  const commonProps = {
54710
54701
  baseUrl,
54711
54702
  spaceId,
54712
54703
  entityId: String(entityData.id),
54704
+ onEntityUpdated,
54713
54705
  };
54714
54706
  const maybeTitle = t('contactDetails.addressInformation');
54715
54707
  const sectionTitle = maybeTitle === 'contactDetails.addressInformation' ? 'Address Information' : maybeTitle;
@@ -54773,6 +54765,18 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, t, }
54773
54765
  setTagsEditorInitialized(false);
54774
54766
  setIsSavingTags(false);
54775
54767
  }, []);
54768
+ const handleEntityUpdated = useCallback((entity) => {
54769
+ if (!entity || typeof entity !== 'object')
54770
+ return;
54771
+ const hasId = 'id' in entity;
54772
+ if (hasId) {
54773
+ actions.setContactData(entity);
54774
+ return;
54775
+ }
54776
+ if (state.contactData) {
54777
+ actions.setContactData({ ...state.contactData, ...entity });
54778
+ }
54779
+ }, [actions, state.contactData]);
54776
54780
  const image = useImage({
54777
54781
  baseUrl,
54778
54782
  spaceId,
@@ -54781,13 +54785,7 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, t, }
54781
54785
  : undefined,
54782
54786
  entityId: state.contactData ? String(state.contactData.id) : undefined,
54783
54787
  initialImageUrl: state.contactData?.imageUrl,
54784
- onEntityUpdated: (entity) => {
54785
- if (!entity || typeof entity !== 'object')
54786
- return;
54787
- if (!state.contactData)
54788
- return;
54789
- actions.setContactData({ ...state.contactData, ...entity });
54790
- },
54788
+ onEntityUpdated: handleEntityUpdated,
54791
54789
  });
54792
54790
  useEffect(() => {
54793
54791
  if (!open) {
@@ -54878,9 +54876,9 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, t, }
54878
54876
  setView('tags');
54879
54877
  }, onUploadPhoto: image.action.uploadImage, onPhotoFileChange: image.inputAtributes.onChange, photoInputRef: image.inputAtributes.ref, isUploadingPhoto: image.isUploading, onDeletePhoto: image.action.deleteImage, isDeletingPhoto: image.isDeleting }), jsxRuntimeExports.jsxs(Box$2, { sx: { px: 1, pb: 2 }, children: [jsxRuntimeExports.jsx(General, { dateFormat: selectors.userTrii?.regCon_dateFormat || 'MM/dd/yyyy', entityType: selectors.contactType === 'contact' || selectors.contactType === 'business'
54880
54878
  ? selectors.contactType
54881
- : 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, t: t, currentUser: selectors.userTrii }), jsxRuntimeExports.jsx(AddressInformation, { entityType: selectors.contactType === 'contact' || selectors.contactType === 'business'
54879
+ : 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated, t: t, currentUser: selectors.userTrii }), jsxRuntimeExports.jsx(AddressInformation, { entityType: selectors.contactType === 'contact' || selectors.contactType === 'business'
54882
54880
  ? selectors.contactType
54883
- : 'contact', entityData: state.contactData, baseUrl: baseUrl, spaceId: spaceId, t: t }), jsxRuntimeExports.jsx(Section, { title: "Contact Information", children: "C" })] })] }) }), jsxRuntimeExports.jsx(Fade$2, { in: view === 'tags', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsx(Box$2, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: jsxRuntimeExports.jsx(TagsEditor, { value: draftLabels, options: selectors.labels, onChange: setDraftLabels, onBack: () => setView('main'), onSave: handleSaveTags, isSaving: isSavingTags, t: t }) }) })] }) })) : null }) }) }));
54881
+ : 'contact', entityData: state.contactData, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated, t: t }), jsxRuntimeExports.jsx(Section, { title: "Contact Information", children: "C" })] })] }) }), jsxRuntimeExports.jsx(Fade$2, { in: view === 'tags', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsx(Box$2, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: jsxRuntimeExports.jsx(TagsEditor, { value: draftLabels, options: selectors.labels, onChange: setDraftLabels, onBack: () => setView('main'), onSave: handleSaveTags, isSaving: isSavingTags, t: t }) }) })] }) })) : null }) }) }));
54884
54882
  };
54885
54883
 
54886
54884
  export { ContactInfoPopup, EditContactModal };