@trii/components 2.0.47 → 2.0.50
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/dist/cjs/index.js +365 -118
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/EditContactModal/components/TagsEditor/TagsEditor.d.ts +4 -1
- package/dist/cjs/types/components/EditContactModal/context/EditContactApiContext.d.ts +10 -0
- package/dist/cjs/types/components/EditContactModal/hooks/useEditBusiness/useEditBusiness.d.ts +1 -1
- package/dist/cjs/types/components/EditContactModal/hooks/useEditContact/useEditContact.d.ts +1 -1
- package/dist/cjs/types/components/EditContactModal/hooks/useModalCloseHandler.d.ts +1 -1
- package/dist/cjs/types/components/EditContactModal/hooks/useTagsEditorController.d.ts +3 -0
- package/dist/cjs/types/components/EditContactModal/layout/Section.d.ts +1 -1
- package/dist/cjs/types/components/EditContactModal/services/api.d.ts +14 -6
- package/dist/esm/index.js +365 -118
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/EditContactModal/components/TagsEditor/TagsEditor.d.ts +4 -1
- package/dist/esm/types/components/EditContactModal/context/EditContactApiContext.d.ts +10 -0
- package/dist/esm/types/components/EditContactModal/hooks/useEditBusiness/useEditBusiness.d.ts +1 -1
- package/dist/esm/types/components/EditContactModal/hooks/useEditContact/useEditContact.d.ts +1 -1
- package/dist/esm/types/components/EditContactModal/hooks/useModalCloseHandler.d.ts +1 -1
- package/dist/esm/types/components/EditContactModal/hooks/useTagsEditorController.d.ts +3 -0
- package/dist/esm/types/components/EditContactModal/layout/Section.d.ts +1 -1
- package/dist/esm/types/components/EditContactModal/services/api.d.ts +14 -6
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -7402,21 +7402,21 @@ var styleFunctionSx = /*#__PURE__*/Object.freeze({
|
|
|
7402
7402
|
|
|
7403
7403
|
var require$$8 = /*@__PURE__*/getAugmentedNamespace(styleFunctionSx);
|
|
7404
7404
|
|
|
7405
|
-
var _interopRequireDefault$
|
|
7405
|
+
var _interopRequireDefault$j = interopRequireDefaultExports;
|
|
7406
7406
|
Object.defineProperty(createStyled$3, "__esModule", {
|
|
7407
7407
|
value: true
|
|
7408
7408
|
});
|
|
7409
7409
|
var _default = createStyled$3.default = createStyled$1;
|
|
7410
7410
|
var shouldForwardProp_1 = createStyled$3.shouldForwardProp = shouldForwardProp$1;
|
|
7411
7411
|
createStyled$3.systemDefaultTheme = void 0;
|
|
7412
|
-
var _extends2 = _interopRequireDefault$
|
|
7413
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault$
|
|
7412
|
+
var _extends2 = _interopRequireDefault$j(require_extends());
|
|
7413
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault$j(requireObjectWithoutPropertiesLoose());
|
|
7414
7414
|
var _styledEngine$1 = _interopRequireWildcard$2(require$$1$1);
|
|
7415
7415
|
var _deepmerge = require$$4;
|
|
7416
|
-
var _capitalize = _interopRequireDefault$
|
|
7417
|
-
var _getDisplayName = _interopRequireDefault$
|
|
7418
|
-
var _createTheme = _interopRequireDefault$
|
|
7419
|
-
var _styleFunctionSx = _interopRequireDefault$
|
|
7416
|
+
var _capitalize = _interopRequireDefault$j(require$$5);
|
|
7417
|
+
var _getDisplayName = _interopRequireDefault$j(require$$6);
|
|
7418
|
+
var _createTheme = _interopRequireDefault$j(require$$7);
|
|
7419
|
+
var _styleFunctionSx = _interopRequireDefault$j(require$$8);
|
|
7420
7420
|
const _excluded$1v = ["ownerState"],
|
|
7421
7421
|
_excluded2$d = ["variants"],
|
|
7422
7422
|
_excluded3$4 = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
|
|
@@ -7686,7 +7686,7 @@ var require$$1 = /*@__PURE__*/getAugmentedNamespace(formatMuiErrorMessage$1);
|
|
|
7686
7686
|
|
|
7687
7687
|
var require$$2 = /*@__PURE__*/getAugmentedNamespace(clamp);
|
|
7688
7688
|
|
|
7689
|
-
var _interopRequireDefault$
|
|
7689
|
+
var _interopRequireDefault$i = interopRequireDefaultExports;
|
|
7690
7690
|
Object.defineProperty(colorManipulator, "__esModule", {
|
|
7691
7691
|
value: true
|
|
7692
7692
|
});
|
|
@@ -7708,8 +7708,8 @@ colorManipulator.private_safeEmphasize = private_safeEmphasize;
|
|
|
7708
7708
|
colorManipulator.private_safeLighten = private_safeLighten;
|
|
7709
7709
|
colorManipulator.recomposeColor = recomposeColor$1;
|
|
7710
7710
|
colorManipulator.rgbToHex = rgbToHex;
|
|
7711
|
-
var _formatMuiErrorMessage2 = _interopRequireDefault$
|
|
7712
|
-
var _clamp = _interopRequireDefault$
|
|
7711
|
+
var _formatMuiErrorMessage2 = _interopRequireDefault$i(require$$1);
|
|
7712
|
+
var _clamp = _interopRequireDefault$i(require$$2);
|
|
7713
7713
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
7714
7714
|
|
|
7715
7715
|
/**
|
|
@@ -9075,27 +9075,27 @@ function requireCreateSvgIcon () {
|
|
|
9075
9075
|
return createSvgIcon;
|
|
9076
9076
|
}
|
|
9077
9077
|
|
|
9078
|
-
var _interopRequireDefault$
|
|
9078
|
+
var _interopRequireDefault$h = interopRequireDefaultExports;
|
|
9079
9079
|
Object.defineProperty(ArrowForward, "__esModule", {
|
|
9080
9080
|
value: true
|
|
9081
9081
|
});
|
|
9082
|
-
var default_1$
|
|
9083
|
-
var _createSvgIcon$
|
|
9084
|
-
var _jsxRuntime$
|
|
9085
|
-
default_1$
|
|
9082
|
+
var default_1$i = ArrowForward.default = void 0;
|
|
9083
|
+
var _createSvgIcon$h = _interopRequireDefault$h(requireCreateSvgIcon());
|
|
9084
|
+
var _jsxRuntime$h = jsxRuntimeExports;
|
|
9085
|
+
default_1$i = ArrowForward.default = (0, _createSvgIcon$h.default)( /*#__PURE__*/(0, _jsxRuntime$h.jsx)("path", {
|
|
9086
9086
|
d: "m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"
|
|
9087
9087
|
}), 'ArrowForward');
|
|
9088
9088
|
|
|
9089
9089
|
var Message = {};
|
|
9090
9090
|
|
|
9091
|
-
var _interopRequireDefault$
|
|
9091
|
+
var _interopRequireDefault$g = interopRequireDefaultExports;
|
|
9092
9092
|
Object.defineProperty(Message, "__esModule", {
|
|
9093
9093
|
value: true
|
|
9094
9094
|
});
|
|
9095
|
-
var default_1$
|
|
9096
|
-
var _createSvgIcon$
|
|
9097
|
-
var _jsxRuntime$
|
|
9098
|
-
default_1$
|
|
9095
|
+
var default_1$h = Message.default = void 0;
|
|
9096
|
+
var _createSvgIcon$g = _interopRequireDefault$g(requireCreateSvgIcon());
|
|
9097
|
+
var _jsxRuntime$g = jsxRuntimeExports;
|
|
9098
|
+
default_1$h = Message.default = (0, _createSvgIcon$g.default)( /*#__PURE__*/(0, _jsxRuntime$g.jsx)("path", {
|
|
9099
9099
|
d: "M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2m-2 12H6v-2h12zm0-3H6V9h12zm0-3H6V6h12z"
|
|
9100
9100
|
}), 'Message');
|
|
9101
9101
|
|
|
@@ -9175,7 +9175,7 @@ const Header$1 = ({ imgUrl, name, contactId, navigate, isLoading = false, onErro
|
|
|
9175
9175
|
handleNavigateToContacts(e);
|
|
9176
9176
|
onClose();
|
|
9177
9177
|
}
|
|
9178
|
-
}, disabled: !contactId, "aria-label": "View contact details", children: jsxRuntimeExports.jsx(default_1$
|
|
9178
|
+
}, disabled: !contactId, "aria-label": "View contact details", children: jsxRuntimeExports.jsx(default_1$i, { fontSize: "small" }) }), jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: (e) => {
|
|
9179
9179
|
handleNavigateToConversations(e);
|
|
9180
9180
|
onClose();
|
|
9181
9181
|
}, onMouseDown: (e) => {
|
|
@@ -9184,7 +9184,7 @@ const Header$1 = ({ imgUrl, name, contactId, navigate, isLoading = false, onErro
|
|
|
9184
9184
|
handleNavigateToConversations(e);
|
|
9185
9185
|
onClose();
|
|
9186
9186
|
}
|
|
9187
|
-
}, "aria-label": "Go to conversations", children: jsxRuntimeExports.jsx(default_1$
|
|
9187
|
+
}, "aria-label": "Go to conversations", children: jsxRuntimeExports.jsx(default_1$h, { fontSize: "small" }) })] }), isLoading ? (jsxRuntimeExports.jsx(LoadingContainer, { children: jsxRuntimeExports.jsx(CircularProgress$2, { size: 24 }) })) : (jsxRuntimeExports.jsx(ContactAvatar, { src: imgUrl, alt: avatarAlt, onError: () => onError?.(new Error('Failed to load avatar')) })), jsxRuntimeExports.jsx(ContactName$1, { variant: "h6", title: displayName, children: displayName })] }));
|
|
9188
9188
|
};
|
|
9189
9189
|
|
|
9190
9190
|
const Container$1 = styled$5(Box$2)({
|
|
@@ -15278,14 +15278,23 @@ var business$1 = "Business";
|
|
|
15278
15278
|
var businessMembers$1 = "Business Members";
|
|
15279
15279
|
var properties$1 = "Properties";
|
|
15280
15280
|
var view$1 = "View";
|
|
15281
|
-
var email$1 = "Email";
|
|
15282
15281
|
var tags$1 = "Tags";
|
|
15283
15282
|
var global$2 = {
|
|
15283
|
+
add: "Add",
|
|
15284
|
+
note: "Note",
|
|
15285
|
+
number: "Number",
|
|
15286
|
+
email: "Email",
|
|
15287
|
+
phones: "Phones",
|
|
15288
|
+
close: "Close",
|
|
15284
15289
|
back: "Back",
|
|
15290
|
+
createNew: "Create new",
|
|
15291
|
+
"delete": "Delete",
|
|
15292
|
+
cancel: "Cancel",
|
|
15285
15293
|
save: "Save",
|
|
15286
15294
|
noOptions: "No options",
|
|
15287
15295
|
noValue: "No value",
|
|
15288
|
-
birthdate: "Birthdate"
|
|
15296
|
+
birthdate: "Birthdate",
|
|
15297
|
+
country: "Country"
|
|
15289
15298
|
};
|
|
15290
15299
|
var avatar$1 = {
|
|
15291
15300
|
upload: "Upload photo",
|
|
@@ -15326,7 +15335,6 @@ var en = {
|
|
|
15326
15335
|
businessMembers: businessMembers$1,
|
|
15327
15336
|
properties: properties$1,
|
|
15328
15337
|
view: view$1,
|
|
15329
|
-
email: email$1,
|
|
15330
15338
|
tags: tags$1,
|
|
15331
15339
|
global: global$2,
|
|
15332
15340
|
avatar: avatar$1,
|
|
@@ -15340,14 +15348,23 @@ var business = "Empresa";
|
|
|
15340
15348
|
var businessMembers = "Miembros de la empresa";
|
|
15341
15349
|
var properties = "Propiedades";
|
|
15342
15350
|
var view = "Ver";
|
|
15343
|
-
var email = "Correo Electrónico";
|
|
15344
15351
|
var tags = "Etiquetas";
|
|
15345
15352
|
var global$1 = {
|
|
15353
|
+
add: "Agregar",
|
|
15354
|
+
note: "Nota",
|
|
15355
|
+
number: "Número",
|
|
15356
|
+
email: "Correo Electrónico",
|
|
15357
|
+
close: "Cerrar",
|
|
15358
|
+
phones: "Teléfonos",
|
|
15359
|
+
"delete": "Eliminar",
|
|
15360
|
+
cancel: "Cancelar",
|
|
15361
|
+
createNew: "Crear nuevo",
|
|
15346
15362
|
back: "Atrás",
|
|
15347
15363
|
save: "Guardar",
|
|
15348
15364
|
noOptions: "Sin opciones",
|
|
15349
15365
|
noValue: "Sin valor",
|
|
15350
|
-
birthdate: "Fecha de nacimiento"
|
|
15366
|
+
birthdate: "Fecha de nacimiento",
|
|
15367
|
+
country: "País"
|
|
15351
15368
|
};
|
|
15352
15369
|
var avatar = {
|
|
15353
15370
|
upload: "Subir foto",
|
|
@@ -15388,7 +15405,6 @@ var es = {
|
|
|
15388
15405
|
businessMembers: businessMembers,
|
|
15389
15406
|
properties: properties,
|
|
15390
15407
|
view: view,
|
|
15391
|
-
email: email,
|
|
15392
15408
|
tags: tags,
|
|
15393
15409
|
global: global$1,
|
|
15394
15410
|
avatar: avatar,
|
|
@@ -15500,6 +15516,19 @@ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl,
|
|
|
15500
15516
|
return (jsxRuntimeExports.jsx(Popper$2, { sx: { zIndex: 1300 }, open: open, anchorEl: anchorEl, placement: "bottom-start", "data-popper-child": "true", children: jsxRuntimeExports.jsx(ClickAwayListener, { onClickAway: onClose, children: jsxRuntimeExports.jsx(PopupContainer, { children: jsxRuntimeExports.jsxs(CardContent, { children: [jsxRuntimeExports.jsx(Header$1, { navigate: navigate, contactId: contactData?.id, imgUrl: avatarImgUrl, name: contactData?.name, onClose: onClose, isBusiness: dataIsBusiness }), jsxRuntimeExports.jsx(LabelsSection, { contactData: contactData, title: t('labels') }), dataIsContact && jsxRuntimeExports.jsx(BusinessSection, { contactData: contactData, title: t('business') }), dataIsBusiness && (jsxRuntimeExports.jsx(MembersSection, { contactData: contactData, title: t('businessMembers'), navigate: navigate })), contactMethods.map((method, index) => (jsxRuntimeExports.jsx(ContactMethod$1, { icon: method.icon, title: method.title, contactList: method.contactList, showTitle: method.showTitle }, index))), jsxRuntimeExports.jsx(Properties, { properties: contactData?.properties, title: t('properties') })] }) }) }) }));
|
|
15501
15517
|
};
|
|
15502
15518
|
|
|
15519
|
+
var Close = {};
|
|
15520
|
+
|
|
15521
|
+
var _interopRequireDefault$f = interopRequireDefaultExports;
|
|
15522
|
+
Object.defineProperty(Close, "__esModule", {
|
|
15523
|
+
value: true
|
|
15524
|
+
});
|
|
15525
|
+
var default_1$g = Close.default = void 0;
|
|
15526
|
+
var _createSvgIcon$f = _interopRequireDefault$f(requireCreateSvgIcon());
|
|
15527
|
+
var _jsxRuntime$f = jsxRuntimeExports;
|
|
15528
|
+
default_1$g = Close.default = (0, _createSvgIcon$f.default)( /*#__PURE__*/(0, _jsxRuntime$f.jsx)("path", {
|
|
15529
|
+
d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
|
|
15530
|
+
}), 'Close');
|
|
15531
|
+
|
|
15503
15532
|
var Edit = {};
|
|
15504
15533
|
|
|
15505
15534
|
var _interopRequireDefault$e = interopRequireDefaultExports;
|
|
@@ -15564,7 +15593,6 @@ const Tags = ({ tags, onEditTags }) => {
|
|
|
15564
15593
|
justifyContent: 'center',
|
|
15565
15594
|
}, children: [jsxRuntimeExports.jsxs(Box$2, { sx: {
|
|
15566
15595
|
maxWidth: 320,
|
|
15567
|
-
pr: 4,
|
|
15568
15596
|
position: 'relative',
|
|
15569
15597
|
'&:hover .tags-action, &:focus-within .tags-action': {
|
|
15570
15598
|
opacity: 1,
|
|
@@ -15578,7 +15606,8 @@ const Tags = ({ tags, onEditTags }) => {
|
|
|
15578
15606
|
},
|
|
15579
15607
|
} }, tag.id))), hiddenCount > 0 ? (jsxRuntimeExports.jsx(Chip$2, { label: `+${hiddenCount}`, size: "small", variant: "outlined", onClick: handleOpen, sx: { borderRadius: 999 } })) : null] }), jsxRuntimeExports.jsx(IconButton$2, { className: "tags-action", size: "small", "aria-label": safeTags.length ? t('tags.edit') : t('tags.add'), onClick: onEditTags, sx: {
|
|
15580
15608
|
position: 'absolute',
|
|
15581
|
-
|
|
15609
|
+
left: '100%',
|
|
15610
|
+
ml: 1,
|
|
15582
15611
|
top: '50%',
|
|
15583
15612
|
transform: 'translateY(-50%)',
|
|
15584
15613
|
color: 'text.secondary',
|
|
@@ -15589,7 +15618,7 @@ const Tags = ({ tags, onEditTags }) => {
|
|
|
15589
15618
|
bgcolor: 'action.hover',
|
|
15590
15619
|
color: 'text.primary',
|
|
15591
15620
|
},
|
|
15592
|
-
}, children: safeTags.length ?
|
|
15621
|
+
}, children: safeTags.length ? jsxRuntimeExports.jsx(default_1$f, { fontSize: "small" }) : jsxRuntimeExports.jsx(default_1$e, { fontSize: "small" }) })] }), jsxRuntimeExports.jsx(Popover$2, { open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }, children: jsxRuntimeExports.jsxs(Box$2, { sx: { p: 1.5, maxWidth: 320, maxHeight: 240, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(Typography$2, { variant: "subtitle2", sx: { mb: 1 }, children: t('tags') }), jsxRuntimeExports.jsx(Stack$2, { direction: "row", spacing: 1, useFlexGap: true, flexWrap: "wrap", children: safeTags.map((tag) => (jsxRuntimeExports.jsx(Chip$2, { label: tag.name, size: "small", variant: "outlined", sx: {
|
|
15593
15622
|
borderRadius: 999,
|
|
15594
15623
|
maxWidth: 160,
|
|
15595
15624
|
'& .MuiChip-label': {
|
|
@@ -15616,8 +15645,13 @@ const NameWrapper = styled$5(Box$2)({
|
|
|
15616
15645
|
display: 'flex',
|
|
15617
15646
|
alignItems: 'center',
|
|
15618
15647
|
justifyContent: 'center',
|
|
15619
|
-
gap: '8px',
|
|
15620
15648
|
width: '100%',
|
|
15649
|
+
});
|
|
15650
|
+
const NameContainer = styled$5(Box$2)({
|
|
15651
|
+
position: 'relative',
|
|
15652
|
+
display: 'flex',
|
|
15653
|
+
justifyContent: 'center',
|
|
15654
|
+
maxWidth: '100%',
|
|
15621
15655
|
'&:hover .edit-icon': {
|
|
15622
15656
|
opacity: 1,
|
|
15623
15657
|
visibility: 'visible',
|
|
@@ -15627,6 +15661,10 @@ const EditButton = styled$5(IconButton$2)({
|
|
|
15627
15661
|
opacity: 0,
|
|
15628
15662
|
visibility: 'hidden',
|
|
15629
15663
|
transition: 'all 0.2s',
|
|
15664
|
+
position: 'absolute',
|
|
15665
|
+
left: '100%',
|
|
15666
|
+
top: '50%',
|
|
15667
|
+
transform: 'translateY(-50%)',
|
|
15630
15668
|
});
|
|
15631
15669
|
const ContactName = ({ displayName, contactType, firstName, lastName, name, entityId, onEntityUpdated, }) => {
|
|
15632
15670
|
const api = useEditContactApi();
|
|
@@ -15677,7 +15715,7 @@ const ContactName = ({ displayName, contactType, firstName, lastName, name, enti
|
|
|
15677
15715
|
if (isEditing) {
|
|
15678
15716
|
return (jsxRuntimeExports.jsxs(Box$2, { sx: { display: 'flex', alignItems: 'center', gap: 1, mt: 1 }, children: [contactType === 'contact' ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(TextField$1, { value: values.firstName, onChange: (e) => setValues({ ...values, firstName: e.target.value }), size: "small", placeholder: "First Name", sx: { width: 140 } }), jsxRuntimeExports.jsx(TextField$1, { value: values.lastName, onChange: (e) => setValues({ ...values, lastName: e.target.value }), size: "small", placeholder: "Last Name", sx: { width: 140 } })] })) : (jsxRuntimeExports.jsx(TextField$1, { value: values.name, onChange: (e) => setValues({ ...values, name: e.target.value }), size: "small", placeholder: "Name", sx: { width: 280 } })), jsxRuntimeExports.jsx(IconButton$2, { onClick: handleSave, disabled: loading, color: "primary", children: loading ? jsxRuntimeExports.jsx(CircularProgress$2, { size: 24 }) : jsxRuntimeExports.jsx(Save$1, {}) })] }));
|
|
15679
15717
|
}
|
|
15680
|
-
return (jsxRuntimeExports.
|
|
15718
|
+
return (jsxRuntimeExports.jsx(NameWrapper, { children: jsxRuntimeExports.jsxs(NameContainer, { children: [jsxRuntimeExports.jsx(NameText, { variant: "h6", title: displayName, children: displayName }), showEdit && (jsxRuntimeExports.jsx(EditButton, { size: "small", onClick: () => setIsEditing(true), className: "edit-icon", sx: { ml: 1 }, children: jsxRuntimeExports.jsx(Edit$1, { fontSize: "small" }) }))] }) }));
|
|
15681
15719
|
};
|
|
15682
15720
|
|
|
15683
15721
|
var Delete = {};
|
|
@@ -24789,10 +24827,11 @@ Grow.muiSupportAuto = true;
|
|
|
24789
24827
|
var Grow$1 = Grow;
|
|
24790
24828
|
|
|
24791
24829
|
const PAGE_SIZE = 20;
|
|
24792
|
-
const AutocompletePopper =
|
|
24793
|
-
|
|
24794
|
-
}));
|
|
24795
|
-
|
|
24830
|
+
const AutocompletePopper = (props) => {
|
|
24831
|
+
const { popperContainer, ...rest } = props;
|
|
24832
|
+
return (jsxRuntimeExports.jsx(MuiPopper, { ...rest, container: popperContainer ?? rest.container, style: { ...(rest.style ?? {}), zIndex: 20000 } }));
|
|
24833
|
+
};
|
|
24834
|
+
const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving, onCreateNew, isCreatingNew, popperContainer, }) => {
|
|
24796
24835
|
const t = useTranslationContext();
|
|
24797
24836
|
const [searchValue, setSearchValue] = useState('');
|
|
24798
24837
|
const [limit, setLimit] = useState(PAGE_SIZE);
|
|
@@ -24808,10 +24847,19 @@ const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving }) => {
|
|
|
24808
24847
|
if (nearBottom)
|
|
24809
24848
|
setLimit((l) => l + PAGE_SIZE);
|
|
24810
24849
|
};
|
|
24811
|
-
|
|
24850
|
+
const CustomNoOptionsMessage = () => {
|
|
24851
|
+
const trimmedSearchValue = String(searchValue ?? '').trim();
|
|
24852
|
+
const isDisabled = !trimmedSearchValue || isSaving || isCreatingNew;
|
|
24853
|
+
return (jsxRuntimeExports.jsxs(Box$2, { sx: {
|
|
24854
|
+
display: 'flex',
|
|
24855
|
+
justifyContent: 'space-between',
|
|
24856
|
+
alignItems: 'center',
|
|
24857
|
+
}, children: [t('global.noOptions'), jsxRuntimeExports.jsx(LoadingButton$1, { onClick: () => onCreateNew(trimmedSearchValue), loading: isCreatingNew, disabled: isDisabled, variant: "contained", size: "small", sx: { marginTop: 1.3 }, children: t('global.createNew') })] }));
|
|
24858
|
+
};
|
|
24859
|
+
return (jsxRuntimeExports.jsxs(Box$2, { sx: { width: '100%' }, children: [jsxRuntimeExports.jsxs(Stack$2, { direction: "row", alignItems: "center", spacing: 1, sx: { mb: 2 }, children: [jsxRuntimeExports.jsx(IconButton$2, { size: "small", onClick: onBack, "aria-label": t('global.back'), disabled: isSaving, children: jsxRuntimeExports.jsx(default_1$b, { fontSize: "small" }) }), jsxRuntimeExports.jsx(Typography$2, { variant: "subtitle1", children: t('tags') }), jsxRuntimeExports.jsx(Box$2, { sx: { flex: 1 } }), jsxRuntimeExports.jsx(LoadingButton$1, { variant: "contained", size: "small", startIcon: jsxRuntimeExports.jsx(default_1$a, {}), onClick: onSave, loading: isSaving, disabled: isSaving, children: t('global.save') })] }), jsxRuntimeExports.jsx(Autocomplete, { multiple: true, disablePortal: false, value: value, onChange: (_, newValue) => onChange(newValue), options: visibleOptions, filterOptions: (x) => x, inputValue: searchValue, onInputChange: handleSearchChange, getOptionLabel: (option) => option?.name ?? '', isOptionEqualToValue: (o, v) => String(o?.id) === String(v?.id), PopperComponent: (props) => (jsxRuntimeExports.jsx(AutocompletePopper, { ...props, popperContainer: popperContainer })), renderOption: (props, option) => jsxRuntimeExports.jsx("li", { ...props, children: option.name ?? '' }), renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => (jsxRuntimeExports.jsx(Chip$2, { label: option.name ?? '', ...getTagProps({ index }) }))), size: "small", renderInput: (params) => jsxRuntimeExports.jsx(TextField$1, { ...params, size: "small" }), ListboxProps: {
|
|
24812
24860
|
onScroll: onListboxScroll,
|
|
24813
24861
|
sx: { maxHeight: 280, overflowY: 'auto' },
|
|
24814
|
-
}, noOptionsText:
|
|
24862
|
+
}, noOptionsText: jsxRuntimeExports.jsx(CustomNoOptionsMessage, {}), sx: { width: '100%' } })] }));
|
|
24815
24863
|
};
|
|
24816
24864
|
|
|
24817
24865
|
class ApiError extends Error {
|
|
@@ -24885,17 +24933,22 @@ async function fetchLabels({ baseUrl, spaceId, signal }) {
|
|
|
24885
24933
|
const url = joinUrl(urls.CONTACTS, '/labels');
|
|
24886
24934
|
return requestJson({ url, signal });
|
|
24887
24935
|
}
|
|
24936
|
+
async function createLabel({ baseUrl, spaceId, name, signal }) {
|
|
24937
|
+
const urls = getApiUrls(baseUrl, spaceId);
|
|
24938
|
+
const url = joinUrl(urls.CONTACTS, '/labels');
|
|
24939
|
+
return requestJson({ url, method: 'POST', body: { name }, signal });
|
|
24940
|
+
}
|
|
24888
24941
|
async function fetchContact({ baseUrl, spaceId, contactId, signal }) {
|
|
24889
24942
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24890
24943
|
const url = joinUrl(urls.CONTACTS, `/contacts/${encodeURIComponent(contactId)}`);
|
|
24891
24944
|
return requestJson({ url, signal });
|
|
24892
24945
|
}
|
|
24893
|
-
async function fetchContactFields({ baseUrl, spaceId, forType, signal }) {
|
|
24946
|
+
async function fetchContactFields({ baseUrl, spaceId, forType, signal, }) {
|
|
24894
24947
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24895
24948
|
const url = `${joinUrl(urls.CONTACTS, '/ContactFields')}?filter=custom&for=${encodeURIComponent(forType)}`;
|
|
24896
24949
|
return requestJson({ url, signal });
|
|
24897
24950
|
}
|
|
24898
|
-
async function updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal }) {
|
|
24951
|
+
async function updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal, }) {
|
|
24899
24952
|
const path = entityType === 'business'
|
|
24900
24953
|
? `/business/${encodeURIComponent(entityId)}`
|
|
24901
24954
|
: `/contacts/${encodeURIComponent(entityId)}`;
|
|
@@ -24908,7 +24961,7 @@ async function deleteAddress({ baseUrl, spaceId, data, signal }) {
|
|
|
24908
24961
|
const url = joinUrl(urls.CONTACTS, '/contactAddresses');
|
|
24909
24962
|
return requestJson({ url, method: 'DELETE', body: data, signal });
|
|
24910
24963
|
}
|
|
24911
|
-
async function checkContactAddress({ baseUrl, spaceId, data, signal }) {
|
|
24964
|
+
async function checkContactAddress({ baseUrl, spaceId, data, signal, }) {
|
|
24912
24965
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24913
24966
|
const url = joinUrl(urls.CONTACTS, '/contactAddresses/check');
|
|
24914
24967
|
return requestJson({ url, method: 'POST', body: data, signal });
|
|
@@ -24918,7 +24971,7 @@ async function setContactAddress({ baseUrl, spaceId, data, signal }) {
|
|
|
24918
24971
|
const url = joinUrl(urls.CONTACTS, '/contactAddresses/set');
|
|
24919
24972
|
return requestJson({ url, method: 'POST', body: data, signal });
|
|
24920
24973
|
}
|
|
24921
|
-
async function updateContactAddress({ baseUrl, spaceId, data, signal }) {
|
|
24974
|
+
async function updateContactAddress({ baseUrl, spaceId, data, signal, }) {
|
|
24922
24975
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24923
24976
|
const url = joinUrl(urls.CONTACTS, `/contactAddresses/${encodeURIComponent(data.contactAddressId)}`);
|
|
24924
24977
|
return requestJson({ url, method: 'PUT', body: data, signal });
|
|
@@ -24933,12 +24986,12 @@ async function fetchUsers({ baseUrl, spaceId, signal }) {
|
|
|
24933
24986
|
const url = joinUrl(urls.SETTINGS, `/users`);
|
|
24934
24987
|
return requestJson({ url, signal });
|
|
24935
24988
|
}
|
|
24936
|
-
async function fetchUserTriiById({ baseUrl, spaceId, signal, userId }) {
|
|
24989
|
+
async function fetchUserTriiById({ baseUrl, spaceId, signal, userId, }) {
|
|
24937
24990
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24938
24991
|
const url = joinUrl(urls.SETTINGS, `/usersInfor/${userId}`);
|
|
24939
24992
|
return requestJson({ url, signal });
|
|
24940
24993
|
}
|
|
24941
|
-
async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal }) {
|
|
24994
|
+
async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal, }) {
|
|
24942
24995
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24943
24996
|
const fd = new FormData();
|
|
24944
24997
|
fd.append('file', file, file.name);
|
|
@@ -24947,6 +25000,7 @@ async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal }) {
|
|
|
24947
25000
|
}
|
|
24948
25001
|
const createEditContactApi = (baseUrl, spaceId) => ({
|
|
24949
25002
|
fetchLabels: ({ signal } = {}) => fetchLabels({ baseUrl, spaceId, signal }),
|
|
25003
|
+
createLabel: ({ name, signal }) => createLabel({ baseUrl, spaceId, name, signal }),
|
|
24950
25004
|
fetchContact: ({ contactId, signal }) => fetchContact({ baseUrl, spaceId, contactId, signal }),
|
|
24951
25005
|
fetchContactFields: ({ forType, signal }) => fetchContactFields({ baseUrl, spaceId, forType, signal }),
|
|
24952
25006
|
updateEntity: ({ entityType, entityId, body, signal }) => updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal }),
|
|
@@ -25753,6 +25807,7 @@ var editContactHelper = { getEditedField, getAddressesWithUpdatedValues };
|
|
|
25753
25807
|
|
|
25754
25808
|
const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, }) => {
|
|
25755
25809
|
const [isDeletingAddress, setIsDeletingAddress] = useState(false);
|
|
25810
|
+
const [initialSnapshot, setInitialSnapshot] = useState(() => initial);
|
|
25756
25811
|
const [imsFacebooks, setImsFacebooks] = useState(initial?.ims_facebook || []);
|
|
25757
25812
|
const [imsMercadolibre, setImsMercadolibre] = useState(initial?.ims_mercadolibre || []);
|
|
25758
25813
|
const [imsWebchats, setImsWebchats] = useState(initial?.ims_webchat || []);
|
|
@@ -25784,6 +25839,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25784
25839
|
const addWhatsappVerified = (newWhatsapp) => {
|
|
25785
25840
|
const updatedWhatsapps = [...imsWhatsapp, newWhatsapp];
|
|
25786
25841
|
setImsWhatsApp(updatedWhatsapps);
|
|
25842
|
+
setInitialSnapshot((prev) => ({
|
|
25843
|
+
...(prev ?? {}),
|
|
25844
|
+
ims_whatsapp: updatedWhatsapps,
|
|
25845
|
+
}));
|
|
25787
25846
|
};
|
|
25788
25847
|
const replaceAddress = (addressId, newAddress) => {
|
|
25789
25848
|
if (!newAddress) {
|
|
@@ -25797,6 +25856,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25797
25856
|
return email;
|
|
25798
25857
|
});
|
|
25799
25858
|
setEmails(newEmails);
|
|
25859
|
+
setInitialSnapshot((prev) => ({
|
|
25860
|
+
...(prev ?? {}),
|
|
25861
|
+
emails: newEmails,
|
|
25862
|
+
}));
|
|
25800
25863
|
}
|
|
25801
25864
|
if (newAddress.channelType === 5) {
|
|
25802
25865
|
const newPhoneNumbers = phoneNumbers.map((phoneNumber) => {
|
|
@@ -25806,6 +25869,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25806
25869
|
return phoneNumber;
|
|
25807
25870
|
});
|
|
25808
25871
|
setPhoneNumbers(newPhoneNumbers);
|
|
25872
|
+
setInitialSnapshot((prev) => ({
|
|
25873
|
+
...(prev ?? {}),
|
|
25874
|
+
phones: newPhoneNumbers,
|
|
25875
|
+
}));
|
|
25809
25876
|
}
|
|
25810
25877
|
if (newAddress.channelType === 13) {
|
|
25811
25878
|
const newImsWhatsapp = imsWhatsapp.map((item) => {
|
|
@@ -25815,6 +25882,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25815
25882
|
return item;
|
|
25816
25883
|
});
|
|
25817
25884
|
setImsWhatsApp(newImsWhatsapp);
|
|
25885
|
+
setInitialSnapshot((prev) => ({
|
|
25886
|
+
...(prev ?? {}),
|
|
25887
|
+
ims_whatsapp: newImsWhatsapp,
|
|
25888
|
+
}));
|
|
25818
25889
|
}
|
|
25819
25890
|
if (newAddress.channelType === 21) {
|
|
25820
25891
|
const newImsRCS = imsRCS.map((item) => {
|
|
@@ -25824,6 +25895,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25824
25895
|
return item;
|
|
25825
25896
|
});
|
|
25826
25897
|
setImsRCS(newImsRCS);
|
|
25898
|
+
setInitialSnapshot((prev) => ({
|
|
25899
|
+
...(prev ?? {}),
|
|
25900
|
+
ims_rcs: newImsRCS,
|
|
25901
|
+
}));
|
|
25827
25902
|
}
|
|
25828
25903
|
if (newAddress.channelType === 41) {
|
|
25829
25904
|
const newImsMercadolibre = imsMercadolibre.map((item) => {
|
|
@@ -25833,6 +25908,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25833
25908
|
return item;
|
|
25834
25909
|
});
|
|
25835
25910
|
setImsMercadolibre(newImsMercadolibre);
|
|
25911
|
+
setInitialSnapshot((prev) => ({
|
|
25912
|
+
...(prev ?? {}),
|
|
25913
|
+
ims_mercadolibre: newImsMercadolibre,
|
|
25914
|
+
}));
|
|
25836
25915
|
}
|
|
25837
25916
|
};
|
|
25838
25917
|
const handleAddressFieldChange = async (e, fieldId, type) => {
|
|
@@ -25985,49 +26064,82 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25985
26064
|
case 3:
|
|
25986
26065
|
const newEmails = emails.filter((email) => email.id !== fieldId);
|
|
25987
26066
|
setEmails(newEmails);
|
|
26067
|
+
setInitialSnapshot((prev) => ({
|
|
26068
|
+
...(prev ?? {}),
|
|
26069
|
+
emails: newEmails,
|
|
26070
|
+
}));
|
|
25988
26071
|
break;
|
|
25989
26072
|
case 5:
|
|
25990
26073
|
const newPhoneNumbers = phoneNumbers.filter((phoneNumber) => phoneNumber.id !== fieldId);
|
|
25991
26074
|
setPhoneNumbers(newPhoneNumbers);
|
|
26075
|
+
setInitialSnapshot((prev) => ({
|
|
26076
|
+
...(prev ?? {}),
|
|
26077
|
+
phones: newPhoneNumbers,
|
|
26078
|
+
}));
|
|
25992
26079
|
break;
|
|
25993
26080
|
case 13:
|
|
25994
26081
|
const newImsWhatsapp = imsWhatsapp.filter((item) => item.id !== fieldId);
|
|
25995
26082
|
setImsWhatsApp(newImsWhatsapp);
|
|
26083
|
+
setInitialSnapshot((prev) => ({
|
|
26084
|
+
...(prev ?? {}),
|
|
26085
|
+
ims_whatsapp: newImsWhatsapp,
|
|
26086
|
+
}));
|
|
25996
26087
|
break;
|
|
25997
26088
|
case 21:
|
|
25998
26089
|
const newImsRCS = imsRCS.filter((item) => item.id !== fieldId);
|
|
25999
26090
|
setImsRCS(newImsRCS);
|
|
26091
|
+
setInitialSnapshot((prev) => ({
|
|
26092
|
+
...(prev ?? {}),
|
|
26093
|
+
ims_rcs: newImsRCS,
|
|
26094
|
+
}));
|
|
26000
26095
|
break;
|
|
26001
26096
|
case 41:
|
|
26002
26097
|
const newImsMercadolibre = imsMercadolibre.filter((item) => item.id !== fieldId);
|
|
26003
26098
|
setImsMercadolibre(newImsMercadolibre);
|
|
26099
|
+
setInitialSnapshot((prev) => ({
|
|
26100
|
+
...(prev ?? {}),
|
|
26101
|
+
ims_mercadolibre: newImsMercadolibre,
|
|
26102
|
+
}));
|
|
26004
26103
|
break;
|
|
26005
26104
|
case 14:
|
|
26006
26105
|
const newImsFacebooks = imsFacebooks.filter((item) => item.id !== fieldId);
|
|
26007
26106
|
setImsFacebooks(newImsFacebooks);
|
|
26107
|
+
setInitialSnapshot((prev) => ({
|
|
26108
|
+
...(prev ?? {}),
|
|
26109
|
+
ims_facebook: newImsFacebooks,
|
|
26110
|
+
}));
|
|
26008
26111
|
break;
|
|
26009
26112
|
case 20:
|
|
26010
26113
|
const newImsWebchats = imsWebchats.filter((item) => item.id !== fieldId);
|
|
26011
26114
|
setImsWebchats(newImsWebchats);
|
|
26115
|
+
setInitialSnapshot((prev) => ({
|
|
26116
|
+
...(prev ?? {}),
|
|
26117
|
+
ims_webchat: newImsWebchats,
|
|
26118
|
+
}));
|
|
26012
26119
|
break;
|
|
26013
26120
|
case 16:
|
|
26014
26121
|
const newImsInstagrams = imsInstagrams.filter((item) => item.id !== fieldId);
|
|
26015
26122
|
setImsInstagrams(newImsInstagrams);
|
|
26123
|
+
setInitialSnapshot((prev) => ({
|
|
26124
|
+
...(prev ?? {}),
|
|
26125
|
+
ims_instagram: newImsInstagrams,
|
|
26126
|
+
}));
|
|
26016
26127
|
break;
|
|
26017
26128
|
}
|
|
26018
26129
|
}
|
|
26019
26130
|
};
|
|
26020
26131
|
function resetToInitialContactInformation() {
|
|
26021
|
-
setImsFacebooks(
|
|
26022
|
-
setImsMercadolibre(
|
|
26023
|
-
setImsWebchats(
|
|
26024
|
-
setImsInstagrams(
|
|
26025
|
-
setImsWhatsApp(
|
|
26026
|
-
setImsRCS(
|
|
26027
|
-
setEmails(
|
|
26028
|
-
setPhoneNumbers(
|
|
26132
|
+
setImsFacebooks(initialSnapshot?.ims_facebook || []);
|
|
26133
|
+
setImsMercadolibre(initialSnapshot?.ims_mercadolibre || []);
|
|
26134
|
+
setImsWebchats(initialSnapshot?.ims_webchat || []);
|
|
26135
|
+
setImsInstagrams(initialSnapshot?.ims_instagram || []);
|
|
26136
|
+
setImsWhatsApp(initialSnapshot?.ims_whatsapp || []);
|
|
26137
|
+
setImsRCS(initialSnapshot?.ims_rcs || []);
|
|
26138
|
+
setEmails(initialSnapshot?.emails || []);
|
|
26139
|
+
setPhoneNumbers(initialSnapshot?.phones || []);
|
|
26029
26140
|
}
|
|
26030
26141
|
useEffect(() => {
|
|
26142
|
+
setInitialSnapshot(initial);
|
|
26031
26143
|
if (initial?.emails && initial?.phones) {
|
|
26032
26144
|
setEmails(initial.emails);
|
|
26033
26145
|
setPhoneNumbers(initial.phones);
|
|
@@ -26092,7 +26204,7 @@ const useMultipleSelect = ({ initialState = [], } = {}) => {
|
|
|
26092
26204
|
};
|
|
26093
26205
|
};
|
|
26094
26206
|
|
|
26095
|
-
const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) => {
|
|
26207
|
+
const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId, }) => {
|
|
26096
26208
|
const apiDeleteAddress = useMemo(() => async (payload) => {
|
|
26097
26209
|
if (!baseUrl || !spaceId)
|
|
26098
26210
|
return;
|
|
@@ -26132,8 +26244,7 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
|
|
|
26132
26244
|
const country = useField$1('text', business?.address1?.country || '');
|
|
26133
26245
|
const secondaryCountry = useField$1('text', business?.address2?.country || '');
|
|
26134
26246
|
const getEditedField = (key, originalValue, editedValue) => {
|
|
26135
|
-
if (originalValue !== editedValue &&
|
|
26136
|
-
!(originalValue === null && editedValue === '')) {
|
|
26247
|
+
if (originalValue !== editedValue && !(originalValue === null && editedValue === '')) {
|
|
26137
26248
|
return { [key]: editedValue };
|
|
26138
26249
|
}
|
|
26139
26250
|
return {};
|
|
@@ -26160,9 +26271,7 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
|
|
|
26160
26271
|
id: business.id,
|
|
26161
26272
|
...getEditedField('owner', business.owner, contactPropietary.attributes.value),
|
|
26162
26273
|
...getEditedField('name', business.name, name.attributes.value),
|
|
26163
|
-
imageUrl: contactImage.imageUrl
|
|
26164
|
-
? contactImage.removeParams(contactImage.imageUrl)
|
|
26165
|
-
: null,
|
|
26274
|
+
imageUrl: contactImage.imageUrl ? contactImage.removeParams(contactImage.imageUrl) : null,
|
|
26166
26275
|
tags: labelMultipleSelect.attributes.value,
|
|
26167
26276
|
properties: customProperties,
|
|
26168
26277
|
members: selectedContacts,
|
|
@@ -26177,26 +26286,23 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
|
|
|
26177
26286
|
function resetCustomProperty(nameKey) {
|
|
26178
26287
|
if (!business)
|
|
26179
26288
|
return;
|
|
26180
|
-
const
|
|
26289
|
+
const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
|
|
26290
|
+
const defaultProperty = business.properties.find((property) => property.nameKey === nameKey) ??
|
|
26291
|
+
business.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(nameKey));
|
|
26181
26292
|
if (!defaultProperty) {
|
|
26182
26293
|
console.error(`No se encontró una propiedad con nameKey: ${nameKey}`);
|
|
26183
26294
|
return; // Salir de la función si no se encuentra la propiedad
|
|
26184
26295
|
}
|
|
26185
|
-
const updatedProperties = customProperties.map((property) => property.nameKey === nameKey
|
|
26186
|
-
? { ...property, value: defaultProperty.value }
|
|
26187
|
-
: property);
|
|
26296
|
+
const updatedProperties = customProperties.map((property) => property.nameKey === nameKey ? { ...property, value: defaultProperty.value } : property);
|
|
26188
26297
|
setCustomProperties(updatedProperties);
|
|
26189
26298
|
}
|
|
26190
|
-
function replaceSpacesWithHyphen(input) {
|
|
26191
|
-
const result = input.replace(/ /g, '-');
|
|
26192
|
-
return result;
|
|
26193
|
-
}
|
|
26194
26299
|
const getFilteredCustomProperties = () => {
|
|
26195
26300
|
if (!business)
|
|
26196
26301
|
return [];
|
|
26197
26302
|
return customContactFields.map((customField) => {
|
|
26198
|
-
const
|
|
26199
|
-
const existingBusinessProperty = business.properties.find((property) => property.nameKey ===
|
|
26303
|
+
const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
|
|
26304
|
+
const existingBusinessProperty = business.properties.find((property) => property.nameKey === customField.nameKey) ??
|
|
26305
|
+
business.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(customField.nameKey));
|
|
26200
26306
|
if (existingBusinessProperty) {
|
|
26201
26307
|
return {
|
|
26202
26308
|
...existingBusinessProperty,
|
|
@@ -26281,7 +26387,7 @@ var dayjs_min = {exports: {}};
|
|
|
26281
26387
|
var dayjs_minExports = dayjs_min.exports;
|
|
26282
26388
|
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
26283
26389
|
|
|
26284
|
-
const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
|
|
26390
|
+
const useEditContact = ({ contact, customContactFields, baseUrl, spaceId, }) => {
|
|
26285
26391
|
const apiDeleteAddress = useMemo(() => async (payload) => {
|
|
26286
26392
|
if (!baseUrl || !spaceId)
|
|
26287
26393
|
return;
|
|
@@ -26365,9 +26471,7 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
|
|
|
26365
26471
|
phones: modifiedPhones,
|
|
26366
26472
|
// ims_whatsapp: modifiedImsWhatsapp,
|
|
26367
26473
|
tags: modifiedTags,
|
|
26368
|
-
imageUrl: contactImage.imageUrl
|
|
26369
|
-
? contactImage.removeParams(contactImage.imageUrl)
|
|
26370
|
-
: null,
|
|
26474
|
+
imageUrl: contactImage.imageUrl ? contactImage.removeParams(contactImage.imageUrl) : null,
|
|
26371
26475
|
properties: customProperties,
|
|
26372
26476
|
// businessId: selectedBusiness[0]?.businessId || '',
|
|
26373
26477
|
// businessName: selectedBusiness[0]?.businessName || '',
|
|
@@ -26393,27 +26497,23 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
|
|
|
26393
26497
|
function resetCustomProperty(nameKey) {
|
|
26394
26498
|
if (!contact)
|
|
26395
26499
|
return;
|
|
26396
|
-
const
|
|
26500
|
+
const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
|
|
26501
|
+
const defaultProperty = contact.properties.find((property) => property.nameKey === nameKey) ??
|
|
26502
|
+
contact.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(nameKey));
|
|
26397
26503
|
if (!defaultProperty) {
|
|
26398
26504
|
console.error(`No se encontró una propiedad con nameKey: ${nameKey}`);
|
|
26399
26505
|
return; // Salir de la función si no se encuentra la propiedad
|
|
26400
26506
|
}
|
|
26401
|
-
const updatedProperties = customProperties.map((property) => property.nameKey === nameKey
|
|
26402
|
-
? { ...property, value: defaultProperty.value }
|
|
26403
|
-
: property);
|
|
26507
|
+
const updatedProperties = customProperties.map((property) => property.nameKey === nameKey ? { ...property, value: defaultProperty.value } : property);
|
|
26404
26508
|
setCustomProperties(updatedProperties);
|
|
26405
26509
|
}
|
|
26406
|
-
// Utils
|
|
26407
|
-
function replaceSpacesWithHyphen(input) {
|
|
26408
|
-
const result = input.replace(/ /g, '-');
|
|
26409
|
-
return result;
|
|
26410
|
-
}
|
|
26411
26510
|
const getFilteredCustomProperties = () => {
|
|
26412
26511
|
if (!contact)
|
|
26413
26512
|
return [];
|
|
26414
26513
|
return customContactFields.map((customField) => {
|
|
26415
|
-
const
|
|
26416
|
-
const existingProperty = contact.properties.find((property) => property.nameKey ===
|
|
26514
|
+
const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
|
|
26515
|
+
const existingProperty = contact.properties.find((property) => property.nameKey === customField.nameKey) ??
|
|
26516
|
+
contact.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(customField.nameKey));
|
|
26417
26517
|
if (existingProperty) {
|
|
26418
26518
|
return {
|
|
26419
26519
|
...existingProperty,
|
|
@@ -26545,7 +26645,7 @@ const Section = ({ title, children }) => {
|
|
|
26545
26645
|
borderRadius: 2,
|
|
26546
26646
|
p: 2,
|
|
26547
26647
|
mb: 2,
|
|
26548
|
-
}, children: [jsxRuntimeExports.jsx(Typography$2, { variant: "subtitle1",
|
|
26648
|
+
}, children: [jsxRuntimeExports.jsx(Typography$2, { variant: "subtitle1", children: title }), jsxRuntimeExports.jsx(Divider, { sx: { my: 1.5 } }), children] }));
|
|
26549
26649
|
};
|
|
26550
26650
|
|
|
26551
26651
|
const SectionContent = ({ children, ...boxProps }) => {
|
|
@@ -52693,7 +52793,7 @@ function SelectBusinessLabel({ value, displayValue, businessId }) {
|
|
|
52693
52793
|
}
|
|
52694
52794
|
setAnchorEl(targetElement);
|
|
52695
52795
|
};
|
|
52696
|
-
return (jsxRuntimeExports.jsxs(Box$2, { display: "flex", alignItems: "center", children: [jsxRuntimeExports.jsx(Typography$2, { onClick: handleOpenInfoPopover, fontWeight: '600', sx: {
|
|
52796
|
+
return (jsxRuntimeExports.jsxs(Box$2, { display: "flex", alignItems: "center", children: [jsxRuntimeExports.jsx(Typography$2, { onClick: handleOpenInfoPopover, variant: "body2", fontWeight: '600', sx: {
|
|
52697
52797
|
padding: 1,
|
|
52698
52798
|
cursor: 'pointer',
|
|
52699
52799
|
}, color: (theme) => theme.palette.text.primary, children: displayValue || (typeof value === 'string' && value) || '-' }), businessData && (jsxRuntimeExports.jsx(ContactInfoPopup, { contactData: businessData, open: Boolean(anchorEl), anchorEl: anchorEl, onClose: () => setAnchorEl(null), navigate: navigate, avatarImgUrl: userImage.imageUrl })), isLoadingData && (jsxRuntimeExports.jsx(Box$2, { display: "flex", alignItems: "center", justifyContent: "center", p: 1, children: jsxRuntimeExports.jsx(CircularProgress$2, { size: 20 }) }))] }));
|
|
@@ -52722,11 +52822,38 @@ const EntityInfoLabel = (props) => {
|
|
|
52722
52822
|
const inputType = props.inputType ?? 'text';
|
|
52723
52823
|
const [isEditing, setIsEditing] = useState(false);
|
|
52724
52824
|
const [isSaving, setIsSaving] = useState(false);
|
|
52825
|
+
const titleRef = useRef(null);
|
|
52826
|
+
const [isTitleTruncated, setIsTitleTruncated] = useState(false);
|
|
52725
52827
|
const [inputValue, setInputValue] = useState(() => {
|
|
52726
52828
|
if (props.entityType === 'business')
|
|
52727
52829
|
return value;
|
|
52728
52830
|
return typeof value === 'string' ? value : undefined;
|
|
52729
52831
|
});
|
|
52832
|
+
useEffect(() => {
|
|
52833
|
+
const el = titleRef.current;
|
|
52834
|
+
if (!el)
|
|
52835
|
+
return;
|
|
52836
|
+
const check = () => {
|
|
52837
|
+
const next = el.scrollWidth > el.clientWidth;
|
|
52838
|
+
setIsTitleTruncated(next);
|
|
52839
|
+
};
|
|
52840
|
+
check();
|
|
52841
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
52842
|
+
const ro = new ResizeObserver(() => {
|
|
52843
|
+
check();
|
|
52844
|
+
});
|
|
52845
|
+
ro.observe(el);
|
|
52846
|
+
return () => {
|
|
52847
|
+
ro.disconnect();
|
|
52848
|
+
};
|
|
52849
|
+
}
|
|
52850
|
+
if (typeof window === 'undefined')
|
|
52851
|
+
return;
|
|
52852
|
+
window.addEventListener('resize', check);
|
|
52853
|
+
return () => {
|
|
52854
|
+
window.removeEventListener('resize', check);
|
|
52855
|
+
};
|
|
52856
|
+
}, [title, isEditing]);
|
|
52730
52857
|
useEffect(() => {
|
|
52731
52858
|
if (props.entityType === 'business') {
|
|
52732
52859
|
setInputValue(value);
|
|
@@ -52831,12 +52958,17 @@ const EntityInfoLabel = (props) => {
|
|
|
52831
52958
|
'&:hover .edit-icon': {
|
|
52832
52959
|
opacity: 1,
|
|
52833
52960
|
},
|
|
52834
|
-
}, children: [jsxRuntimeExports.jsxs(Box$2, { display: "flex", position: "relative", minHeight: '25px', children: [
|
|
52961
|
+
}, children: [jsxRuntimeExports.jsxs(Box$2, { display: "flex", position: "relative", minHeight: '25px', children: [isTitleTruncated ? (jsxRuntimeExports.jsx(Tooltip, { title: title, arrow: true, children: jsxRuntimeExports.jsx(Typography$2, { ref: titleRef, component: "span", variant: "body2", letterSpacing: -0.5, fontWeight: '600', alignSelf: 'center', flexGrow: isEditing ? 1 : 0, color: (theme) => theme.palette.text.primary, noWrap: true, sx: {
|
|
52962
|
+
minWidth: 0,
|
|
52963
|
+
overflow: 'hidden',
|
|
52964
|
+
textOverflow: 'ellipsis',
|
|
52965
|
+
whiteSpace: 'nowrap',
|
|
52966
|
+
}, children: title }) })) : (jsxRuntimeExports.jsx(Typography$2, { ref: titleRef, component: "span", variant: "body2", letterSpacing: -0.5, fontWeight: '600', alignSelf: 'center', flexGrow: isEditing ? 1 : 0, color: (theme) => theme.palette.text.primary, noWrap: true, sx: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: title })), isNotEditable ? null : isEditing ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(StyledSaveCancelButton$1, { size: "small", onClick: handleSave, children: isSaving ? jsxRuntimeExports.jsx(CircularProgress$2, { size: 24 }) : jsxRuntimeExports.jsx(default_1$a, {}) }), jsxRuntimeExports.jsx(StyledSaveCancelButton$1, { size: "small", onClick: handleCancel, children: jsxRuntimeExports.jsx(default_1$8, {}) })] })) : (jsxRuntimeExports.jsx(StyledIconButton$3, { className: "edit-icon", size: "small", onClick: handleEditClick, children: jsxRuntimeExports.jsx(default_1$f, {}) }))] }), jsxRuntimeExports.jsx(Box$2, { width: isEditing ? '100%' : '50%', position: "relative", children: isEditing && inputType === 'text' ? (jsxRuntimeExports.jsx(TextField$1, { value: textValue, onChange: handleInputChange, variant: "standard", size: "small", sx: { width: '100%' } })) : isEditing && (inputType === 'select' || inputType === 'selectMembers') ? (jsxRuntimeExports.jsxs(Select$2, { value: selectValue, onChange: handleSelectChange, variant: "standard", size: "small", sx: { width: '100%' }, children: [props.entityType === 'contact' ? (jsxRuntimeExports.jsx(MenuItem$2, { value: "", children: t('conversations.contactDetails.contactInfo.emptySelection') })) : null, options.map((option, index) => (jsxRuntimeExports.jsx(MenuItem$2, { value: option.id, children: props.entityType === 'contact'
|
|
52835
52967
|
? option.name?.trim() || (isUserInfo(option) ? option.email : '') || 'Sin nombre'
|
|
52836
52968
|
: option.name?.trim() || option.email || 'Sin nombre' }, index)))] })) : isEditing && isContactBirthdayProps(props) ? (jsxRuntimeExports.jsx(DateSelect, { birthDate: props.contact.field.birthDate, setBirthDate: props.contact.action.setBirthDate, dateFormat: props.dateFormat })) : !isEditing &&
|
|
52837
52969
|
props.entityType === 'contact' &&
|
|
52838
52970
|
inputType === 'selectBusiness' &&
|
|
52839
|
-
props.businessId ? (jsxRuntimeExports.jsx(SelectBusinessLabel, { value: value, displayValue: displayValue, businessId: props.businessId })) : (jsxRuntimeExports.jsx(Typography$2, { fontWeight: '400', sx: { padding: '2.5px 14px 8.5px 0px' }, color: (theme) => theme.palette.text.primary, children: displayValue || (typeof value === 'string' && value) || '-' })) })] }));
|
|
52971
|
+
props.businessId ? (jsxRuntimeExports.jsx(SelectBusinessLabel, { value: String(value ?? ''), displayValue: String(displayValue ?? ''), businessId: props.businessId })) : (jsxRuntimeExports.jsx(Typography$2, { variant: "body2", fontWeight: '400', sx: { padding: '2.5px 14px 8.5px 0px' }, color: (theme) => theme.palette.text.primary, children: displayValue || (typeof value === 'string' && value) || '-' })) })] }));
|
|
52840
52972
|
};
|
|
52841
52973
|
|
|
52842
52974
|
const ContactInfoLabel = (props) => {
|
|
@@ -54668,13 +54800,19 @@ const ContactBox = styled$5(Box$2)(({ theme }) => ({
|
|
|
54668
54800
|
}));
|
|
54669
54801
|
const FieldName = styled$5(Typography$2)(({ theme }) => ({
|
|
54670
54802
|
fontWeight: 600,
|
|
54803
|
+
fontSize: '0.875rem',
|
|
54671
54804
|
alignSelf: 'center',
|
|
54672
54805
|
color: theme.palette.text.primary,
|
|
54673
54806
|
letterSpacing: -0.5,
|
|
54674
54807
|
padding: 0,
|
|
54808
|
+
whiteSpace: 'nowrap',
|
|
54809
|
+
overflow: 'hidden',
|
|
54810
|
+
textOverflow: 'ellipsis',
|
|
54811
|
+
minWidth: 0,
|
|
54675
54812
|
}));
|
|
54676
54813
|
const FieldValue = styled$5(Typography$2)(({ theme }) => ({
|
|
54677
54814
|
fontWeight: 400,
|
|
54815
|
+
fontSize: '0.875rem',
|
|
54678
54816
|
padding: '2.5px 14px 8.5px 0px',
|
|
54679
54817
|
color: theme.palette.text.primary,
|
|
54680
54818
|
wordWrap: 'break-word',
|
|
@@ -54687,6 +54825,8 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
|
|
|
54687
54825
|
const { setCustomProperties } = entity.action;
|
|
54688
54826
|
const [isEditing, setIsEditing] = useState(false);
|
|
54689
54827
|
const [isSaving, setIsSaving] = useState(false);
|
|
54828
|
+
const titleRef = useRef(null);
|
|
54829
|
+
const [isTitleTruncated, setIsTitleTruncated] = useState(false);
|
|
54690
54830
|
const userDateFormat = (userTrii?.regCon_dateFormat || 'YYYY/MM/DD').toUpperCase();
|
|
54691
54831
|
const userTimeFormat = userTrii?.regCon_timeFormat || '24';
|
|
54692
54832
|
// Determina si el tipo de campo es numérico
|
|
@@ -54792,6 +54932,42 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
|
|
|
54792
54932
|
const foundField = customContactFields.find((field) => field.nameKey === propertyNameKey);
|
|
54793
54933
|
return foundField?.name || propertyNameKey;
|
|
54794
54934
|
};
|
|
54935
|
+
useEffect(() => {
|
|
54936
|
+
const el = titleRef.current;
|
|
54937
|
+
if (!el)
|
|
54938
|
+
return;
|
|
54939
|
+
const check = () => {
|
|
54940
|
+
const next = el.scrollWidth > el.clientWidth;
|
|
54941
|
+
setIsTitleTruncated((prev) => (prev === next ? prev : next));
|
|
54942
|
+
};
|
|
54943
|
+
check();
|
|
54944
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
54945
|
+
let rafId = 0;
|
|
54946
|
+
const ro = new ResizeObserver(() => {
|
|
54947
|
+
if (typeof window === 'undefined') {
|
|
54948
|
+
check();
|
|
54949
|
+
return;
|
|
54950
|
+
}
|
|
54951
|
+
if (rafId)
|
|
54952
|
+
window.cancelAnimationFrame(rafId);
|
|
54953
|
+
rafId = window.requestAnimationFrame(() => {
|
|
54954
|
+
check();
|
|
54955
|
+
});
|
|
54956
|
+
});
|
|
54957
|
+
ro.observe(el);
|
|
54958
|
+
return () => {
|
|
54959
|
+
if (typeof window !== 'undefined' && rafId)
|
|
54960
|
+
window.cancelAnimationFrame(rafId);
|
|
54961
|
+
ro.disconnect();
|
|
54962
|
+
};
|
|
54963
|
+
}
|
|
54964
|
+
if (typeof window === 'undefined')
|
|
54965
|
+
return;
|
|
54966
|
+
window.addEventListener('resize', check);
|
|
54967
|
+
return () => {
|
|
54968
|
+
window.removeEventListener('resize', check);
|
|
54969
|
+
};
|
|
54970
|
+
}, [customContactFields, property.nameKey]);
|
|
54795
54971
|
const handleInputChange = (name, value) => {
|
|
54796
54972
|
const updatedValue = property.type === Contacts.ContactField_type.DATERANGE
|
|
54797
54973
|
? Array.isArray(value) && value[0] && value[1]
|
|
@@ -54844,7 +55020,7 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
|
|
|
54844
55020
|
else
|
|
54845
55021
|
return (jsxRuntimeExports.jsx(CustomPropertyInput, { type: type, nameKey: nameKey, value: value, onChange: handleInputChange }));
|
|
54846
55022
|
};
|
|
54847
|
-
return (jsxRuntimeExports.jsxs(ContactBox, { className: `fadein ${property.type === Contacts.ContactField_type.LONGTEXT ? 'contacts-col-12' : 'contacts-col-5'}`, children: [jsxRuntimeExports.jsxs(Box$2, { display: "flex", position: "relative", minHeight: "25px", children: [jsxRuntimeExports.jsx(FieldName, { flexGrow:
|
|
55023
|
+
return (jsxRuntimeExports.jsxs(ContactBox, { className: `fadein ${property.type === Contacts.ContactField_type.LONGTEXT ? 'contacts-col-12' : 'contacts-col-5'}`, children: [jsxRuntimeExports.jsxs(Box$2, { display: "flex", position: "relative", minHeight: "25px", alignItems: "center", children: [isTitleTruncated ? (jsxRuntimeExports.jsx(Tooltip, { title: getPropertyName(property.nameKey), arrow: true, children: jsxRuntimeExports.jsx(FieldName, { ref: titleRef, flexGrow: 1, noWrap: true, children: getPropertyName(property.nameKey) }) })) : (jsxRuntimeExports.jsx(FieldName, { ref: titleRef, flexGrow: 1, noWrap: true, children: getPropertyName(property.nameKey) })), isEditing ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(StyledSaveCancelButton, { size: "small", onClick: handleSave, children: isSaving ? jsxRuntimeExports.jsx(CircularProgress$2, { size: 24 }) : jsxRuntimeExports.jsx(default_1$a, {}) }), jsxRuntimeExports.jsx(StyledSaveCancelButton, { size: "small", onClick: handleCancel, children: jsxRuntimeExports.jsx(default_1$8, {}) })] })) : (jsxRuntimeExports.jsx(StyledIconButton$2, { className: "edit-icon", size: "small", onClick: toggleEdit, children: jsxRuntimeExports.jsx(default_1$f, {}) }))] }), jsxRuntimeExports.jsx(Box$2, { width: isEditing || property.type === Contacts.ContactField_type.LONGTEXT ? '100%' : '50%', position: "relative", children: isEditing ? (EditField()) : (jsxRuntimeExports.jsx(FieldValue, { children: hasValue(property?.value)
|
|
54848
55024
|
? property.type === Contacts.ContactField_type.DATERANGE
|
|
54849
55025
|
? (() => {
|
|
54850
55026
|
if (typeof property.value === 'string') {
|
|
@@ -56500,7 +56676,6 @@ const StyledBox = styled$5(Box$2)(({ theme }) => ({
|
|
|
56500
56676
|
const StyledTypography = styled$5(Typography$2)(({}) => ({
|
|
56501
56677
|
letterSpacing: -0.5,
|
|
56502
56678
|
fontSize: 14,
|
|
56503
|
-
fontWeight: 600,
|
|
56504
56679
|
}));
|
|
56505
56680
|
const HeaderBox = styled$5(Box$2)(({}) => ({
|
|
56506
56681
|
display: 'flex',
|
|
@@ -57311,7 +57486,7 @@ const AddressInformation = ({ entityType, entityData, baseUrl, spaceId, onEntity
|
|
|
57311
57486
|
onEntityUpdated,
|
|
57312
57487
|
};
|
|
57313
57488
|
const t = useTranslationContext();
|
|
57314
|
-
const AddressGroup = ({ addressNumber, title, }) => (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 rounded-xl p-4", children: [jsxRuntimeExports.jsx(Typography$2, { variant: "
|
|
57489
|
+
const AddressGroup = ({ addressNumber, title, }) => (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 rounded-xl p-4", children: [jsxRuntimeExports.jsx(Typography$2, { variant: "body2", children: title }), jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-x-4 gap-y-3", children: [jsxRuntimeExports.jsx("div", { className: "col-span-2", children: jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: entityType, title: t('conversations.contactDetails.street'), value: entityData[addressNumber]?.street ?? '', ...commonProps, constructUpdateObject: (value) => ({
|
|
57315
57490
|
[addressNumber]: { street: value },
|
|
57316
57491
|
}), minWidth: "100%" }) }), jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: entityType, title: t('conversations.contactDetails.city'), value: entityData[addressNumber]?.city ?? '', ...commonProps, constructUpdateObject: (value) => ({
|
|
57317
57492
|
[addressNumber]: { city: value },
|
|
@@ -57351,11 +57526,31 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
|
|
|
57351
57526
|
const [draftLabels, setDraftLabels] = useState([]);
|
|
57352
57527
|
const [tagsEditorInitialized, setTagsEditorInitialized] = useState(false);
|
|
57353
57528
|
const [isSaving, setIsSaving] = useState(false);
|
|
57529
|
+
const [createdLabels, setCreatedLabels] = useState([]);
|
|
57530
|
+
const [isCreatingLabel, setIsCreatingLabel] = useState(false);
|
|
57531
|
+
const labelsOptions = useMemo(() => {
|
|
57532
|
+
const safeLabels = labels ?? [];
|
|
57533
|
+
const safeCreated = createdLabels ?? [];
|
|
57534
|
+
const byId = new Map();
|
|
57535
|
+
for (const label of safeLabels) {
|
|
57536
|
+
if (!label?.id)
|
|
57537
|
+
continue;
|
|
57538
|
+
byId.set(String(label.id), label);
|
|
57539
|
+
}
|
|
57540
|
+
for (const label of safeCreated) {
|
|
57541
|
+
if (!label?.id)
|
|
57542
|
+
continue;
|
|
57543
|
+
byId.set(String(label.id), label);
|
|
57544
|
+
}
|
|
57545
|
+
return Array.from(byId.values());
|
|
57546
|
+
}, [labels, createdLabels]);
|
|
57354
57547
|
const reset = useCallback(() => {
|
|
57355
57548
|
setView('main');
|
|
57356
57549
|
setDraftLabels([]);
|
|
57357
57550
|
setTagsEditorInitialized(false);
|
|
57358
57551
|
setIsSaving(false);
|
|
57552
|
+
setCreatedLabels([]);
|
|
57553
|
+
setIsCreatingLabel(false);
|
|
57359
57554
|
}, []);
|
|
57360
57555
|
useEffect(() => {
|
|
57361
57556
|
if (!open) {
|
|
@@ -57369,13 +57564,61 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
|
|
|
57369
57564
|
}
|
|
57370
57565
|
if (tagsEditorInitialized)
|
|
57371
57566
|
return;
|
|
57372
|
-
if (!
|
|
57567
|
+
if (!labelsOptions.length)
|
|
57373
57568
|
return;
|
|
57374
57569
|
const selectedTagIds = new Set(selectedTags.map((t) => String(t.id)));
|
|
57375
|
-
const initialDraft =
|
|
57570
|
+
const initialDraft = labelsOptions.filter((l) => selectedTagIds.has(String(l?.id)));
|
|
57376
57571
|
setDraftLabels(initialDraft);
|
|
57377
57572
|
setTagsEditorInitialized(true);
|
|
57378
|
-
}, [view, tagsEditorInitialized,
|
|
57573
|
+
}, [view, tagsEditorInitialized, labelsOptions, selectedTags]);
|
|
57574
|
+
const handleCreateLabel = useCallback(async (name) => {
|
|
57575
|
+
if (isCreatingLabel)
|
|
57576
|
+
return;
|
|
57577
|
+
if (!baseUrl || !spaceId)
|
|
57578
|
+
return;
|
|
57579
|
+
const trimmedName = String(name ?? '').trim();
|
|
57580
|
+
if (!trimmedName)
|
|
57581
|
+
return;
|
|
57582
|
+
const normalizedName = trimmedName.toLowerCase();
|
|
57583
|
+
const existing = labelsOptions.find((l) => String(l?.name ?? '')
|
|
57584
|
+
.trim()
|
|
57585
|
+
.toLowerCase() === normalizedName);
|
|
57586
|
+
if (existing?.id) {
|
|
57587
|
+
setDraftLabels((prev) => {
|
|
57588
|
+
const safePrev = prev ?? [];
|
|
57589
|
+
const existsInDraft = safePrev.some((p) => String(p?.id) === String(existing.id));
|
|
57590
|
+
if (existsInDraft)
|
|
57591
|
+
return safePrev;
|
|
57592
|
+
return [...safePrev, existing];
|
|
57593
|
+
});
|
|
57594
|
+
return;
|
|
57595
|
+
}
|
|
57596
|
+
setIsCreatingLabel(true);
|
|
57597
|
+
try {
|
|
57598
|
+
const created = await createLabel({ baseUrl, spaceId, name: trimmedName });
|
|
57599
|
+
setCreatedLabels((prev) => {
|
|
57600
|
+
const safePrev = prev ?? [];
|
|
57601
|
+
if (!created?.id)
|
|
57602
|
+
return safePrev;
|
|
57603
|
+
const existsInCreated = safePrev.some((p) => String(p?.id) === String(created.id));
|
|
57604
|
+
if (existsInCreated)
|
|
57605
|
+
return safePrev;
|
|
57606
|
+
return [...safePrev, created];
|
|
57607
|
+
});
|
|
57608
|
+
setDraftLabels((prev) => {
|
|
57609
|
+
const safePrev = prev ?? [];
|
|
57610
|
+
if (!created?.id)
|
|
57611
|
+
return safePrev;
|
|
57612
|
+
const existsInDraft = safePrev.some((p) => String(p?.id) === String(created.id));
|
|
57613
|
+
if (existsInDraft)
|
|
57614
|
+
return safePrev;
|
|
57615
|
+
return [...safePrev, created];
|
|
57616
|
+
});
|
|
57617
|
+
}
|
|
57618
|
+
finally {
|
|
57619
|
+
setIsCreatingLabel(false);
|
|
57620
|
+
}
|
|
57621
|
+
}, [isCreatingLabel, baseUrl, spaceId, labelsOptions]);
|
|
57379
57622
|
const handleSaveTags = useCallback(async () => {
|
|
57380
57623
|
if (isSaving)
|
|
57381
57624
|
return;
|
|
@@ -57409,21 +57652,18 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
|
|
|
57409
57652
|
setView,
|
|
57410
57653
|
draftLabels,
|
|
57411
57654
|
setDraftLabels,
|
|
57655
|
+
labelsOptions,
|
|
57412
57656
|
isSaving,
|
|
57657
|
+
isCreatingLabel,
|
|
57658
|
+
handleCreateLabel,
|
|
57413
57659
|
handleSaveTags,
|
|
57414
57660
|
};
|
|
57415
57661
|
};
|
|
57416
57662
|
|
|
57417
57663
|
const useModalCloseHandler = ({ onClose }) => {
|
|
57418
|
-
const handleClose = useCallback((
|
|
57664
|
+
const handleClose = useCallback((_event, reason) => {
|
|
57419
57665
|
if (reason === 'escapeKeyDown') {
|
|
57420
|
-
|
|
57421
|
-
if (typeof maybeEvent?.stopPropagation === 'function') {
|
|
57422
|
-
maybeEvent.stopPropagation();
|
|
57423
|
-
}
|
|
57424
|
-
if (typeof maybeEvent?.preventDefault === 'function') {
|
|
57425
|
-
maybeEvent.preventDefault();
|
|
57426
|
-
}
|
|
57666
|
+
return;
|
|
57427
57667
|
}
|
|
57428
57668
|
onClose();
|
|
57429
57669
|
}, [onClose]);
|
|
@@ -57432,6 +57672,7 @@ const useModalCloseHandler = ({ onClose }) => {
|
|
|
57432
57672
|
|
|
57433
57673
|
const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, language = 'en', navigate, }) => {
|
|
57434
57674
|
const { t: i18nT, i18n } = useTranslation();
|
|
57675
|
+
const modalContentRef = useRef(null);
|
|
57435
57676
|
useEffect(() => {
|
|
57436
57677
|
if (language) {
|
|
57437
57678
|
i18n.changeLanguage(language);
|
|
@@ -57453,7 +57694,7 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, lang
|
|
|
57453
57694
|
entity: state.contactData,
|
|
57454
57695
|
setEntity: (next) => actions.setContactData(next ?? undefined),
|
|
57455
57696
|
});
|
|
57456
|
-
const { view, setView, draftLabels, setDraftLabels, isSaving: isSavingTags, handleSaveTags, } = useTagsEditorController({
|
|
57697
|
+
const { view, setView, draftLabels, setDraftLabels, labelsOptions, isSaving: isSavingTags, isCreatingLabel, handleCreateLabel, handleSaveTags, } = useTagsEditorController({
|
|
57457
57698
|
open,
|
|
57458
57699
|
baseUrl,
|
|
57459
57700
|
spaceId,
|
|
@@ -57490,23 +57731,29 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, lang
|
|
|
57490
57731
|
boxShadow: 24,
|
|
57491
57732
|
outline: 0,
|
|
57492
57733
|
p: 3,
|
|
57493
|
-
overflow: '
|
|
57734
|
+
overflow: 'visible',
|
|
57494
57735
|
};
|
|
57495
57736
|
const mergedSx = Array.isArray(sx) ? [baseSx, ...sx] : sx ? [baseSx, sx] : baseSx;
|
|
57496
|
-
return (jsxRuntimeExports.jsx(EditContactApiProvider, { value: api, children: jsxRuntimeExports.jsx(TranslationProvider, { t: t, children: jsxRuntimeExports.jsx(NavigateProvider, { navigate: navigate, children: jsxRuntimeExports.jsx(Modal$2, { open: open, onClose: handleClose, closeAfterTransition: true, slots: { backdrop: Backdrop$2 }, slotProps: { backdrop: { timeout: 200 } }, children: jsxRuntimeExports.jsx(Fade$2, { in: open, timeout: 200, children: jsxRuntimeExports.
|
|
57497
|
-
|
|
57498
|
-
|
|
57499
|
-
|
|
57500
|
-
|
|
57501
|
-
|
|
57502
|
-
|
|
57503
|
-
|
|
57504
|
-
|
|
57505
|
-
|
|
57506
|
-
|
|
57507
|
-
|
|
57508
|
-
|
|
57509
|
-
|
|
57737
|
+
return (jsxRuntimeExports.jsx(EditContactApiProvider, { value: api, children: jsxRuntimeExports.jsx(TranslationProvider, { t: t, children: jsxRuntimeExports.jsx(NavigateProvider, { navigate: navigate, children: jsxRuntimeExports.jsx(Modal$2, { open: open, onClose: handleClose, closeAfterTransition: true, slots: { backdrop: Backdrop$2 }, slotProps: { backdrop: { timeout: 200 } }, children: jsxRuntimeExports.jsx(Fade$2, { in: open, timeout: 200, children: jsxRuntimeExports.jsxs(Box$2, { sx: mergedSx, ref: modalContentRef, children: [jsxRuntimeExports.jsx(IconButton$2, { "aria-label": "close", onClick: handleClose, sx: {
|
|
57738
|
+
position: 'absolute',
|
|
57739
|
+
right: 5,
|
|
57740
|
+
top: 5,
|
|
57741
|
+
color: (theme) => theme.palette.grey[500],
|
|
57742
|
+
zIndex: 1,
|
|
57743
|
+
}, size: "small", children: jsxRuntimeExports.jsx(default_1$g, { sx: { fontSize: 20 } }) }), state.isLoading && !state.contactData ? (jsxRuntimeExports.jsx(Box$2, { sx: {
|
|
57744
|
+
display: 'flex',
|
|
57745
|
+
justifyContent: 'center',
|
|
57746
|
+
alignItems: 'center',
|
|
57747
|
+
minHeight: 220,
|
|
57748
|
+
}, children: jsxRuntimeExports.jsx(CircularProgress$2, {}) })) : state.error ? (jsxRuntimeExports.jsx(Box$2, { sx: { mb: 2 }, children: "Failed to load contact" })) : state.contactData ? (jsxRuntimeExports.jsx(EditEntityProvider, { entityType: selectors.contactType === 'business' ? 'business' : 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, children: jsxRuntimeExports.jsxs(Box$2, { sx: { position: 'relative', height: '100%' }, children: [jsxRuntimeExports.jsx(Fade$2, { in: view === 'main', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsxs(Box$2, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(Header, { imgUrl: image.imageUrl, displayName: selectors.displayName, tags: selectors.tags, onEditTags: () => {
|
|
57749
|
+
setView('tags');
|
|
57750
|
+
}, onUploadPhoto: image.action.uploadImage, onPhotoFileChange: image.inputAtributes.onChange, photoInputRef: image.inputAtributes.ref, isUploadingPhoto: image.isUploading, onDeletePhoto: image.action.deleteImage, isDeletingPhoto: image.isDeleting, contactType: selectors.contactType, entityId: state.contactData?.id, firstName: selectors.isContact ? state.contactData.firstName : undefined, lastName: selectors.isContact ? state.contactData.lastName : undefined, name: selectors.isBusiness ? state.contactData.name : undefined, onEntityUpdated: handleEntityUpdated }), 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' ||
|
|
57751
|
+
selectors.contactType === 'business'
|
|
57752
|
+
? selectors.contactType
|
|
57753
|
+
: 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated, currentUser: selectors.userTrii }), jsxRuntimeExports.jsx(AddressInformation, { entityType: selectors.contactType === 'contact' ||
|
|
57754
|
+
selectors.contactType === 'business'
|
|
57755
|
+
? selectors.contactType
|
|
57756
|
+
: 'contact', entityData: state.contactData, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated }), jsxRuntimeExports.jsx(ContactInformation, { ownerData: state.contactData })] })] }) }), 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: labelsOptions, onChange: setDraftLabels, onBack: () => setView('main'), onSave: handleSaveTags, isSaving: isSavingTags, onCreateNew: handleCreateLabel, isCreatingNew: isCreatingLabel, popperContainer: modalContentRef.current }) }) })] }) })) : null] }) }) }) }) }) }));
|
|
57510
57757
|
};
|
|
57511
57758
|
|
|
57512
57759
|
export { ContactInfoPopup, EditContactModal };
|