@trii/components 2.0.47 → 2.0.48
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 +346 -107
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/EditContactModal/components/TagsEditor/TagsEditor.d.ts +3 -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 +346 -107
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/EditContactModal/components/TagsEditor/TagsEditor.d.ts +3 -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/cjs/index.js
CHANGED
|
@@ -7421,21 +7421,21 @@ var styleFunctionSx = /*#__PURE__*/Object.freeze({
|
|
|
7421
7421
|
|
|
7422
7422
|
var require$$8 = /*@__PURE__*/getAugmentedNamespace(styleFunctionSx);
|
|
7423
7423
|
|
|
7424
|
-
var _interopRequireDefault$
|
|
7424
|
+
var _interopRequireDefault$j = interopRequireDefaultExports;
|
|
7425
7425
|
Object.defineProperty(createStyled$3, "__esModule", {
|
|
7426
7426
|
value: true
|
|
7427
7427
|
});
|
|
7428
7428
|
var _default = createStyled$3.default = createStyled$1;
|
|
7429
7429
|
var shouldForwardProp_1 = createStyled$3.shouldForwardProp = shouldForwardProp$1;
|
|
7430
7430
|
createStyled$3.systemDefaultTheme = void 0;
|
|
7431
|
-
var _extends2 = _interopRequireDefault$
|
|
7432
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault$
|
|
7431
|
+
var _extends2 = _interopRequireDefault$j(require_extends());
|
|
7432
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault$j(requireObjectWithoutPropertiesLoose());
|
|
7433
7433
|
var _styledEngine$1 = _interopRequireWildcard$2(require$$1$1);
|
|
7434
7434
|
var _deepmerge = require$$4;
|
|
7435
|
-
var _capitalize = _interopRequireDefault$
|
|
7436
|
-
var _getDisplayName = _interopRequireDefault$
|
|
7437
|
-
var _createTheme = _interopRequireDefault$
|
|
7438
|
-
var _styleFunctionSx = _interopRequireDefault$
|
|
7435
|
+
var _capitalize = _interopRequireDefault$j(require$$5);
|
|
7436
|
+
var _getDisplayName = _interopRequireDefault$j(require$$6);
|
|
7437
|
+
var _createTheme = _interopRequireDefault$j(require$$7);
|
|
7438
|
+
var _styleFunctionSx = _interopRequireDefault$j(require$$8);
|
|
7439
7439
|
const _excluded$1v = ["ownerState"],
|
|
7440
7440
|
_excluded2$d = ["variants"],
|
|
7441
7441
|
_excluded3$4 = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
|
|
@@ -7705,7 +7705,7 @@ var require$$1 = /*@__PURE__*/getAugmentedNamespace(formatMuiErrorMessage$1);
|
|
|
7705
7705
|
|
|
7706
7706
|
var require$$2 = /*@__PURE__*/getAugmentedNamespace(clamp);
|
|
7707
7707
|
|
|
7708
|
-
var _interopRequireDefault$
|
|
7708
|
+
var _interopRequireDefault$i = interopRequireDefaultExports;
|
|
7709
7709
|
Object.defineProperty(colorManipulator, "__esModule", {
|
|
7710
7710
|
value: true
|
|
7711
7711
|
});
|
|
@@ -7727,8 +7727,8 @@ colorManipulator.private_safeEmphasize = private_safeEmphasize;
|
|
|
7727
7727
|
colorManipulator.private_safeLighten = private_safeLighten;
|
|
7728
7728
|
colorManipulator.recomposeColor = recomposeColor$1;
|
|
7729
7729
|
colorManipulator.rgbToHex = rgbToHex;
|
|
7730
|
-
var _formatMuiErrorMessage2 = _interopRequireDefault$
|
|
7731
|
-
var _clamp = _interopRequireDefault$
|
|
7730
|
+
var _formatMuiErrorMessage2 = _interopRequireDefault$i(require$$1);
|
|
7731
|
+
var _clamp = _interopRequireDefault$i(require$$2);
|
|
7732
7732
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
7733
7733
|
|
|
7734
7734
|
/**
|
|
@@ -9094,27 +9094,27 @@ function requireCreateSvgIcon () {
|
|
|
9094
9094
|
return createSvgIcon;
|
|
9095
9095
|
}
|
|
9096
9096
|
|
|
9097
|
-
var _interopRequireDefault$
|
|
9097
|
+
var _interopRequireDefault$h = interopRequireDefaultExports;
|
|
9098
9098
|
Object.defineProperty(ArrowForward, "__esModule", {
|
|
9099
9099
|
value: true
|
|
9100
9100
|
});
|
|
9101
|
-
var default_1$
|
|
9102
|
-
var _createSvgIcon$
|
|
9103
|
-
var _jsxRuntime$
|
|
9104
|
-
default_1$
|
|
9101
|
+
var default_1$i = ArrowForward.default = void 0;
|
|
9102
|
+
var _createSvgIcon$h = _interopRequireDefault$h(requireCreateSvgIcon());
|
|
9103
|
+
var _jsxRuntime$h = jsxRuntimeExports;
|
|
9104
|
+
default_1$i = ArrowForward.default = (0, _createSvgIcon$h.default)( /*#__PURE__*/(0, _jsxRuntime$h.jsx)("path", {
|
|
9105
9105
|
d: "m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"
|
|
9106
9106
|
}), 'ArrowForward');
|
|
9107
9107
|
|
|
9108
9108
|
var Message = {};
|
|
9109
9109
|
|
|
9110
|
-
var _interopRequireDefault$
|
|
9110
|
+
var _interopRequireDefault$g = interopRequireDefaultExports;
|
|
9111
9111
|
Object.defineProperty(Message, "__esModule", {
|
|
9112
9112
|
value: true
|
|
9113
9113
|
});
|
|
9114
|
-
var default_1$
|
|
9115
|
-
var _createSvgIcon$
|
|
9116
|
-
var _jsxRuntime$
|
|
9117
|
-
default_1$
|
|
9114
|
+
var default_1$h = Message.default = void 0;
|
|
9115
|
+
var _createSvgIcon$g = _interopRequireDefault$g(requireCreateSvgIcon());
|
|
9116
|
+
var _jsxRuntime$g = jsxRuntimeExports;
|
|
9117
|
+
default_1$h = Message.default = (0, _createSvgIcon$g.default)( /*#__PURE__*/(0, _jsxRuntime$g.jsx)("path", {
|
|
9118
9118
|
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"
|
|
9119
9119
|
}), 'Message');
|
|
9120
9120
|
|
|
@@ -9194,7 +9194,7 @@ const Header$1 = ({ imgUrl, name, contactId, navigate, isLoading = false, onErro
|
|
|
9194
9194
|
handleNavigateToContacts(e);
|
|
9195
9195
|
onClose();
|
|
9196
9196
|
}
|
|
9197
|
-
}, disabled: !contactId, "aria-label": "View contact details", children: jsxRuntimeExports.jsx(default_1$
|
|
9197
|
+
}, disabled: !contactId, "aria-label": "View contact details", children: jsxRuntimeExports.jsx(default_1$i, { fontSize: "small" }) }), jsxRuntimeExports.jsx(SmallIconButton, { color: "info", size: "small", onClick: (e) => {
|
|
9198
9198
|
handleNavigateToConversations(e);
|
|
9199
9199
|
onClose();
|
|
9200
9200
|
}, onMouseDown: (e) => {
|
|
@@ -9203,7 +9203,7 @@ const Header$1 = ({ imgUrl, name, contactId, navigate, isLoading = false, onErro
|
|
|
9203
9203
|
handleNavigateToConversations(e);
|
|
9204
9204
|
onClose();
|
|
9205
9205
|
}
|
|
9206
|
-
}, "aria-label": "Go to conversations", children: jsxRuntimeExports.jsx(default_1$
|
|
9206
|
+
}, "aria-label": "Go to conversations", children: jsxRuntimeExports.jsx(default_1$h, { fontSize: "small" }) })] }), isLoading ? (jsxRuntimeExports.jsx(LoadingContainer, { children: jsxRuntimeExports.jsx(material.CircularProgress, { 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 })] }));
|
|
9207
9207
|
};
|
|
9208
9208
|
|
|
9209
9209
|
const Container$1 = material.styled(material.Box)({
|
|
@@ -15291,11 +15291,16 @@ const MembersSection = ({ contactData, title, navigate }) => {
|
|
|
15291
15291
|
return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(SectionTitle, { gutterBottom: true, mt: 2, variant: "subtitle1", children: title }), contactData?.members.map((member) => (jsxRuntimeExports.jsx(MemberItem, { memberId: String(member.id), name: member.name, navigate: navigate }, member.id)))] }));
|
|
15292
15292
|
};
|
|
15293
15293
|
|
|
15294
|
+
var add$1 = "Add";
|
|
15295
|
+
var close$1 = "Close";
|
|
15294
15296
|
var labels$1 = "Labels";
|
|
15295
15297
|
var phone$1 = "Phone";
|
|
15298
|
+
var phones$1 = "Phones";
|
|
15299
|
+
var number$1 = "Number";
|
|
15296
15300
|
var business$1 = "Business";
|
|
15297
15301
|
var businessMembers$1 = "Business Members";
|
|
15298
15302
|
var properties$1 = "Properties";
|
|
15303
|
+
var note$1 = "Note";
|
|
15299
15304
|
var view$1 = "View";
|
|
15300
15305
|
var email$1 = "Email";
|
|
15301
15306
|
var tags$1 = "Tags";
|
|
@@ -15339,11 +15344,16 @@ var conversations$1 = {
|
|
|
15339
15344
|
}
|
|
15340
15345
|
};
|
|
15341
15346
|
var en = {
|
|
15347
|
+
add: add$1,
|
|
15348
|
+
close: close$1,
|
|
15342
15349
|
labels: labels$1,
|
|
15343
15350
|
phone: phone$1,
|
|
15351
|
+
phones: phones$1,
|
|
15352
|
+
number: number$1,
|
|
15344
15353
|
business: business$1,
|
|
15345
15354
|
businessMembers: businessMembers$1,
|
|
15346
15355
|
properties: properties$1,
|
|
15356
|
+
note: note$1,
|
|
15347
15357
|
view: view$1,
|
|
15348
15358
|
email: email$1,
|
|
15349
15359
|
tags: tags$1,
|
|
@@ -15353,11 +15363,16 @@ var en = {
|
|
|
15353
15363
|
conversations: conversations$1
|
|
15354
15364
|
};
|
|
15355
15365
|
|
|
15366
|
+
var add = "Agregar";
|
|
15367
|
+
var close = "Cerrar";
|
|
15356
15368
|
var labels = "Etiquetas";
|
|
15357
15369
|
var phone = "Teléfono";
|
|
15370
|
+
var phones = "Teléfonos";
|
|
15371
|
+
var number = "Número";
|
|
15358
15372
|
var business = "Empresa";
|
|
15359
15373
|
var businessMembers = "Miembros de la empresa";
|
|
15360
15374
|
var properties = "Propiedades";
|
|
15375
|
+
var note = "Nota";
|
|
15361
15376
|
var view = "Ver";
|
|
15362
15377
|
var email = "Correo Electrónico";
|
|
15363
15378
|
var tags = "Etiquetas";
|
|
@@ -15401,11 +15416,16 @@ var conversations = {
|
|
|
15401
15416
|
}
|
|
15402
15417
|
};
|
|
15403
15418
|
var es = {
|
|
15419
|
+
add: add,
|
|
15420
|
+
close: close,
|
|
15404
15421
|
labels: labels,
|
|
15405
15422
|
phone: phone,
|
|
15423
|
+
phones: phones,
|
|
15424
|
+
number: number,
|
|
15406
15425
|
business: business,
|
|
15407
15426
|
businessMembers: businessMembers,
|
|
15408
15427
|
properties: properties,
|
|
15428
|
+
note: note,
|
|
15409
15429
|
view: view,
|
|
15410
15430
|
email: email,
|
|
15411
15431
|
tags: tags,
|
|
@@ -15519,6 +15539,19 @@ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl,
|
|
|
15519
15539
|
return (jsxRuntimeExports.jsx(material.Popper, { sx: { zIndex: 1300 }, open: open, anchorEl: anchorEl, placement: "bottom-start", "data-popper-child": "true", children: jsxRuntimeExports.jsx(material.ClickAwayListener, { onClickAway: onClose, children: jsxRuntimeExports.jsx(PopupContainer, { children: jsxRuntimeExports.jsxs(material.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') })] }) }) }) }));
|
|
15520
15540
|
};
|
|
15521
15541
|
|
|
15542
|
+
var Close = {};
|
|
15543
|
+
|
|
15544
|
+
var _interopRequireDefault$f = interopRequireDefaultExports;
|
|
15545
|
+
Object.defineProperty(Close, "__esModule", {
|
|
15546
|
+
value: true
|
|
15547
|
+
});
|
|
15548
|
+
var default_1$g = Close.default = void 0;
|
|
15549
|
+
var _createSvgIcon$f = _interopRequireDefault$f(requireCreateSvgIcon());
|
|
15550
|
+
var _jsxRuntime$f = jsxRuntimeExports;
|
|
15551
|
+
default_1$g = Close.default = (0, _createSvgIcon$f.default)( /*#__PURE__*/(0, _jsxRuntime$f.jsx)("path", {
|
|
15552
|
+
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"
|
|
15553
|
+
}), 'Close');
|
|
15554
|
+
|
|
15522
15555
|
var Edit = {};
|
|
15523
15556
|
|
|
15524
15557
|
var _interopRequireDefault$e = interopRequireDefaultExports;
|
|
@@ -15583,7 +15616,6 @@ const Tags = ({ tags, onEditTags }) => {
|
|
|
15583
15616
|
justifyContent: 'center',
|
|
15584
15617
|
}, children: [jsxRuntimeExports.jsxs(material.Box, { sx: {
|
|
15585
15618
|
maxWidth: 320,
|
|
15586
|
-
pr: 4,
|
|
15587
15619
|
position: 'relative',
|
|
15588
15620
|
'&:hover .tags-action, &:focus-within .tags-action': {
|
|
15589
15621
|
opacity: 1,
|
|
@@ -15597,7 +15629,8 @@ const Tags = ({ tags, onEditTags }) => {
|
|
|
15597
15629
|
},
|
|
15598
15630
|
} }, tag.id))), hiddenCount > 0 ? (jsxRuntimeExports.jsx(material.Chip, { label: `+${hiddenCount}`, size: "small", variant: "outlined", onClick: handleOpen, sx: { borderRadius: 999 } })) : null] }), jsxRuntimeExports.jsx(material.IconButton, { className: "tags-action", size: "small", "aria-label": safeTags.length ? t('tags.edit') : t('tags.add'), onClick: onEditTags, sx: {
|
|
15599
15631
|
position: 'absolute',
|
|
15600
|
-
|
|
15632
|
+
left: '100%',
|
|
15633
|
+
ml: 1,
|
|
15601
15634
|
top: '50%',
|
|
15602
15635
|
transform: 'translateY(-50%)',
|
|
15603
15636
|
color: 'text.secondary',
|
|
@@ -15608,7 +15641,7 @@ const Tags = ({ tags, onEditTags }) => {
|
|
|
15608
15641
|
bgcolor: 'action.hover',
|
|
15609
15642
|
color: 'text.primary',
|
|
15610
15643
|
},
|
|
15611
|
-
}, children: safeTags.length ?
|
|
15644
|
+
}, children: safeTags.length ? jsxRuntimeExports.jsx(default_1$f, { fontSize: "small" }) : jsxRuntimeExports.jsx(default_1$e, { fontSize: "small" }) })] }), jsxRuntimeExports.jsx(material.Popover, { open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }, children: jsxRuntimeExports.jsxs(material.Box, { sx: { p: 1.5, maxWidth: 320, maxHeight: 240, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle2", sx: { mb: 1 }, children: t('tags') }), jsxRuntimeExports.jsx(material.Stack, { direction: "row", spacing: 1, useFlexGap: true, flexWrap: "wrap", children: safeTags.map((tag) => (jsxRuntimeExports.jsx(material.Chip, { label: tag.name, size: "small", variant: "outlined", sx: {
|
|
15612
15645
|
borderRadius: 999,
|
|
15613
15646
|
maxWidth: 160,
|
|
15614
15647
|
'& .MuiChip-label': {
|
|
@@ -15635,8 +15668,13 @@ const NameWrapper = material.styled(material.Box)({
|
|
|
15635
15668
|
display: 'flex',
|
|
15636
15669
|
alignItems: 'center',
|
|
15637
15670
|
justifyContent: 'center',
|
|
15638
|
-
gap: '8px',
|
|
15639
15671
|
width: '100%',
|
|
15672
|
+
});
|
|
15673
|
+
const NameContainer = material.styled(material.Box)({
|
|
15674
|
+
position: 'relative',
|
|
15675
|
+
display: 'flex',
|
|
15676
|
+
justifyContent: 'center',
|
|
15677
|
+
maxWidth: '100%',
|
|
15640
15678
|
'&:hover .edit-icon': {
|
|
15641
15679
|
opacity: 1,
|
|
15642
15680
|
visibility: 'visible',
|
|
@@ -15646,6 +15684,10 @@ const EditButton = material.styled(material.IconButton)({
|
|
|
15646
15684
|
opacity: 0,
|
|
15647
15685
|
visibility: 'hidden',
|
|
15648
15686
|
transition: 'all 0.2s',
|
|
15687
|
+
position: 'absolute',
|
|
15688
|
+
left: '100%',
|
|
15689
|
+
top: '50%',
|
|
15690
|
+
transform: 'translateY(-50%)',
|
|
15649
15691
|
});
|
|
15650
15692
|
const ContactName = ({ displayName, contactType, firstName, lastName, name, entityId, onEntityUpdated, }) => {
|
|
15651
15693
|
const api = useEditContactApi();
|
|
@@ -15696,7 +15738,7 @@ const ContactName = ({ displayName, contactType, firstName, lastName, name, enti
|
|
|
15696
15738
|
if (isEditing) {
|
|
15697
15739
|
return (jsxRuntimeExports.jsxs(material.Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, mt: 1 }, children: [contactType === 'contact' ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(material.TextField, { value: values.firstName, onChange: (e) => setValues({ ...values, firstName: e.target.value }), size: "small", placeholder: "First Name", sx: { width: 140 } }), jsxRuntimeExports.jsx(material.TextField, { value: values.lastName, onChange: (e) => setValues({ ...values, lastName: e.target.value }), size: "small", placeholder: "Last Name", sx: { width: 140 } })] })) : (jsxRuntimeExports.jsx(material.TextField, { value: values.name, onChange: (e) => setValues({ ...values, name: e.target.value }), size: "small", placeholder: "Name", sx: { width: 280 } })), jsxRuntimeExports.jsx(material.IconButton, { onClick: handleSave, disabled: loading, color: "primary", children: loading ? jsxRuntimeExports.jsx(material.CircularProgress, { size: 24 }) : jsxRuntimeExports.jsx(Save$1, {}) })] }));
|
|
15698
15740
|
}
|
|
15699
|
-
return (jsxRuntimeExports.
|
|
15741
|
+
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" }) }))] }) }));
|
|
15700
15742
|
};
|
|
15701
15743
|
|
|
15702
15744
|
var Delete = {};
|
|
@@ -24811,7 +24853,7 @@ const PAGE_SIZE = 20;
|
|
|
24811
24853
|
const AutocompletePopper = styled$3(MuiPopper)(({ theme }) => ({
|
|
24812
24854
|
zIndex: theme.zIndex.modal + 1,
|
|
24813
24855
|
}));
|
|
24814
|
-
const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving }) => {
|
|
24856
|
+
const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving, onCreateNew, isCreatingNew, }) => {
|
|
24815
24857
|
const t = useTranslationContext();
|
|
24816
24858
|
const [searchValue, setSearchValue] = React$1.useState('');
|
|
24817
24859
|
const [limit, setLimit] = React$1.useState(PAGE_SIZE);
|
|
@@ -24827,10 +24869,19 @@ const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving }) => {
|
|
|
24827
24869
|
if (nearBottom)
|
|
24828
24870
|
setLimit((l) => l + PAGE_SIZE);
|
|
24829
24871
|
};
|
|
24830
|
-
|
|
24872
|
+
const CustomNoOptionsMessage = () => {
|
|
24873
|
+
const trimmedSearchValue = String(searchValue ?? '').trim();
|
|
24874
|
+
const isDisabled = !trimmedSearchValue || isSaving || isCreatingNew;
|
|
24875
|
+
return (jsxRuntimeExports.jsxs(material.Box, { sx: {
|
|
24876
|
+
display: 'flex',
|
|
24877
|
+
justifyContent: 'space-between',
|
|
24878
|
+
alignItems: 'center',
|
|
24879
|
+
}, 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') })] }));
|
|
24880
|
+
};
|
|
24881
|
+
return (jsxRuntimeExports.jsxs(material.Box, { sx: { width: '100%' }, children: [jsxRuntimeExports.jsxs(material.Stack, { direction: "row", alignItems: "center", spacing: 1, sx: { mb: 2 }, children: [jsxRuntimeExports.jsx(material.IconButton, { size: "small", onClick: onBack, "aria-label": t('global.back'), disabled: isSaving, children: jsxRuntimeExports.jsx(default_1$b, { fontSize: "small" }) }), jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle1", children: t('tags') }), jsxRuntimeExports.jsx(material.Box, { 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(material.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: AutocompletePopper, renderOption: (props, option) => jsxRuntimeExports.jsx("li", { ...props, children: option.name ?? '' }), renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => (jsxRuntimeExports.jsx(material.Chip, { label: option.name ?? '', ...getTagProps({ index }) }))), size: "small", renderInput: (params) => jsxRuntimeExports.jsx(material.TextField, { ...params, size: "small" }), ListboxProps: {
|
|
24831
24882
|
onScroll: onListboxScroll,
|
|
24832
24883
|
sx: { maxHeight: 280, overflowY: 'auto' },
|
|
24833
|
-
}, noOptionsText:
|
|
24884
|
+
}, noOptionsText: jsxRuntimeExports.jsx(CustomNoOptionsMessage, {}), sx: { width: '100%' } })] }));
|
|
24834
24885
|
};
|
|
24835
24886
|
|
|
24836
24887
|
class ApiError extends Error {
|
|
@@ -24904,17 +24955,22 @@ async function fetchLabels({ baseUrl, spaceId, signal }) {
|
|
|
24904
24955
|
const url = joinUrl(urls.CONTACTS, '/labels');
|
|
24905
24956
|
return requestJson({ url, signal });
|
|
24906
24957
|
}
|
|
24958
|
+
async function createLabel({ baseUrl, spaceId, name, signal }) {
|
|
24959
|
+
const urls = getApiUrls(baseUrl, spaceId);
|
|
24960
|
+
const url = joinUrl(urls.CONTACTS, '/labels');
|
|
24961
|
+
return requestJson({ url, method: 'POST', body: { name }, signal });
|
|
24962
|
+
}
|
|
24907
24963
|
async function fetchContact({ baseUrl, spaceId, contactId, signal }) {
|
|
24908
24964
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24909
24965
|
const url = joinUrl(urls.CONTACTS, `/contacts/${encodeURIComponent(contactId)}`);
|
|
24910
24966
|
return requestJson({ url, signal });
|
|
24911
24967
|
}
|
|
24912
|
-
async function fetchContactFields({ baseUrl, spaceId, forType, signal }) {
|
|
24968
|
+
async function fetchContactFields({ baseUrl, spaceId, forType, signal, }) {
|
|
24913
24969
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24914
24970
|
const url = `${joinUrl(urls.CONTACTS, '/ContactFields')}?filter=custom&for=${encodeURIComponent(forType)}`;
|
|
24915
24971
|
return requestJson({ url, signal });
|
|
24916
24972
|
}
|
|
24917
|
-
async function updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal }) {
|
|
24973
|
+
async function updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal, }) {
|
|
24918
24974
|
const path = entityType === 'business'
|
|
24919
24975
|
? `/business/${encodeURIComponent(entityId)}`
|
|
24920
24976
|
: `/contacts/${encodeURIComponent(entityId)}`;
|
|
@@ -24927,7 +24983,7 @@ async function deleteAddress({ baseUrl, spaceId, data, signal }) {
|
|
|
24927
24983
|
const url = joinUrl(urls.CONTACTS, '/contactAddresses');
|
|
24928
24984
|
return requestJson({ url, method: 'DELETE', body: data, signal });
|
|
24929
24985
|
}
|
|
24930
|
-
async function checkContactAddress({ baseUrl, spaceId, data, signal }) {
|
|
24986
|
+
async function checkContactAddress({ baseUrl, spaceId, data, signal, }) {
|
|
24931
24987
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24932
24988
|
const url = joinUrl(urls.CONTACTS, '/contactAddresses/check');
|
|
24933
24989
|
return requestJson({ url, method: 'POST', body: data, signal });
|
|
@@ -24937,7 +24993,7 @@ async function setContactAddress({ baseUrl, spaceId, data, signal }) {
|
|
|
24937
24993
|
const url = joinUrl(urls.CONTACTS, '/contactAddresses/set');
|
|
24938
24994
|
return requestJson({ url, method: 'POST', body: data, signal });
|
|
24939
24995
|
}
|
|
24940
|
-
async function updateContactAddress({ baseUrl, spaceId, data, signal }) {
|
|
24996
|
+
async function updateContactAddress({ baseUrl, spaceId, data, signal, }) {
|
|
24941
24997
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24942
24998
|
const url = joinUrl(urls.CONTACTS, `/contactAddresses/${encodeURIComponent(data.contactAddressId)}`);
|
|
24943
24999
|
return requestJson({ url, method: 'PUT', body: data, signal });
|
|
@@ -24952,12 +25008,12 @@ async function fetchUsers({ baseUrl, spaceId, signal }) {
|
|
|
24952
25008
|
const url = joinUrl(urls.SETTINGS, `/users`);
|
|
24953
25009
|
return requestJson({ url, signal });
|
|
24954
25010
|
}
|
|
24955
|
-
async function fetchUserTriiById({ baseUrl, spaceId, signal, userId }) {
|
|
25011
|
+
async function fetchUserTriiById({ baseUrl, spaceId, signal, userId, }) {
|
|
24956
25012
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24957
25013
|
const url = joinUrl(urls.SETTINGS, `/usersInfor/${userId}`);
|
|
24958
25014
|
return requestJson({ url, signal });
|
|
24959
25015
|
}
|
|
24960
|
-
async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal }) {
|
|
25016
|
+
async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal, }) {
|
|
24961
25017
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24962
25018
|
const fd = new FormData();
|
|
24963
25019
|
fd.append('file', file, file.name);
|
|
@@ -24966,6 +25022,7 @@ async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal }) {
|
|
|
24966
25022
|
}
|
|
24967
25023
|
const createEditContactApi = (baseUrl, spaceId) => ({
|
|
24968
25024
|
fetchLabels: ({ signal } = {}) => fetchLabels({ baseUrl, spaceId, signal }),
|
|
25025
|
+
createLabel: ({ name, signal }) => createLabel({ baseUrl, spaceId, name, signal }),
|
|
24969
25026
|
fetchContact: ({ contactId, signal }) => fetchContact({ baseUrl, spaceId, contactId, signal }),
|
|
24970
25027
|
fetchContactFields: ({ forType, signal }) => fetchContactFields({ baseUrl, spaceId, forType, signal }),
|
|
24971
25028
|
updateEntity: ({ entityType, entityId, body, signal }) => updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal }),
|
|
@@ -25772,6 +25829,7 @@ var editContactHelper = { getEditedField, getAddressesWithUpdatedValues };
|
|
|
25772
25829
|
|
|
25773
25830
|
const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, }) => {
|
|
25774
25831
|
const [isDeletingAddress, setIsDeletingAddress] = React$1.useState(false);
|
|
25832
|
+
const [initialSnapshot, setInitialSnapshot] = React$1.useState(() => initial);
|
|
25775
25833
|
const [imsFacebooks, setImsFacebooks] = React$1.useState(initial?.ims_facebook || []);
|
|
25776
25834
|
const [imsMercadolibre, setImsMercadolibre] = React$1.useState(initial?.ims_mercadolibre || []);
|
|
25777
25835
|
const [imsWebchats, setImsWebchats] = React$1.useState(initial?.ims_webchat || []);
|
|
@@ -25803,6 +25861,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25803
25861
|
const addWhatsappVerified = (newWhatsapp) => {
|
|
25804
25862
|
const updatedWhatsapps = [...imsWhatsapp, newWhatsapp];
|
|
25805
25863
|
setImsWhatsApp(updatedWhatsapps);
|
|
25864
|
+
setInitialSnapshot((prev) => ({
|
|
25865
|
+
...(prev ?? {}),
|
|
25866
|
+
ims_whatsapp: updatedWhatsapps,
|
|
25867
|
+
}));
|
|
25806
25868
|
};
|
|
25807
25869
|
const replaceAddress = (addressId, newAddress) => {
|
|
25808
25870
|
if (!newAddress) {
|
|
@@ -25816,6 +25878,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25816
25878
|
return email;
|
|
25817
25879
|
});
|
|
25818
25880
|
setEmails(newEmails);
|
|
25881
|
+
setInitialSnapshot((prev) => ({
|
|
25882
|
+
...(prev ?? {}),
|
|
25883
|
+
emails: newEmails,
|
|
25884
|
+
}));
|
|
25819
25885
|
}
|
|
25820
25886
|
if (newAddress.channelType === 5) {
|
|
25821
25887
|
const newPhoneNumbers = phoneNumbers.map((phoneNumber) => {
|
|
@@ -25825,6 +25891,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25825
25891
|
return phoneNumber;
|
|
25826
25892
|
});
|
|
25827
25893
|
setPhoneNumbers(newPhoneNumbers);
|
|
25894
|
+
setInitialSnapshot((prev) => ({
|
|
25895
|
+
...(prev ?? {}),
|
|
25896
|
+
phones: newPhoneNumbers,
|
|
25897
|
+
}));
|
|
25828
25898
|
}
|
|
25829
25899
|
if (newAddress.channelType === 13) {
|
|
25830
25900
|
const newImsWhatsapp = imsWhatsapp.map((item) => {
|
|
@@ -25834,6 +25904,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25834
25904
|
return item;
|
|
25835
25905
|
});
|
|
25836
25906
|
setImsWhatsApp(newImsWhatsapp);
|
|
25907
|
+
setInitialSnapshot((prev) => ({
|
|
25908
|
+
...(prev ?? {}),
|
|
25909
|
+
ims_whatsapp: newImsWhatsapp,
|
|
25910
|
+
}));
|
|
25837
25911
|
}
|
|
25838
25912
|
if (newAddress.channelType === 21) {
|
|
25839
25913
|
const newImsRCS = imsRCS.map((item) => {
|
|
@@ -25843,6 +25917,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25843
25917
|
return item;
|
|
25844
25918
|
});
|
|
25845
25919
|
setImsRCS(newImsRCS);
|
|
25920
|
+
setInitialSnapshot((prev) => ({
|
|
25921
|
+
...(prev ?? {}),
|
|
25922
|
+
ims_rcs: newImsRCS,
|
|
25923
|
+
}));
|
|
25846
25924
|
}
|
|
25847
25925
|
if (newAddress.channelType === 41) {
|
|
25848
25926
|
const newImsMercadolibre = imsMercadolibre.map((item) => {
|
|
@@ -25852,6 +25930,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25852
25930
|
return item;
|
|
25853
25931
|
});
|
|
25854
25932
|
setImsMercadolibre(newImsMercadolibre);
|
|
25933
|
+
setInitialSnapshot((prev) => ({
|
|
25934
|
+
...(prev ?? {}),
|
|
25935
|
+
ims_mercadolibre: newImsMercadolibre,
|
|
25936
|
+
}));
|
|
25855
25937
|
}
|
|
25856
25938
|
};
|
|
25857
25939
|
const handleAddressFieldChange = async (e, fieldId, type) => {
|
|
@@ -26004,49 +26086,82 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
26004
26086
|
case 3:
|
|
26005
26087
|
const newEmails = emails.filter((email) => email.id !== fieldId);
|
|
26006
26088
|
setEmails(newEmails);
|
|
26089
|
+
setInitialSnapshot((prev) => ({
|
|
26090
|
+
...(prev ?? {}),
|
|
26091
|
+
emails: newEmails,
|
|
26092
|
+
}));
|
|
26007
26093
|
break;
|
|
26008
26094
|
case 5:
|
|
26009
26095
|
const newPhoneNumbers = phoneNumbers.filter((phoneNumber) => phoneNumber.id !== fieldId);
|
|
26010
26096
|
setPhoneNumbers(newPhoneNumbers);
|
|
26097
|
+
setInitialSnapshot((prev) => ({
|
|
26098
|
+
...(prev ?? {}),
|
|
26099
|
+
phones: newPhoneNumbers,
|
|
26100
|
+
}));
|
|
26011
26101
|
break;
|
|
26012
26102
|
case 13:
|
|
26013
26103
|
const newImsWhatsapp = imsWhatsapp.filter((item) => item.id !== fieldId);
|
|
26014
26104
|
setImsWhatsApp(newImsWhatsapp);
|
|
26105
|
+
setInitialSnapshot((prev) => ({
|
|
26106
|
+
...(prev ?? {}),
|
|
26107
|
+
ims_whatsapp: newImsWhatsapp,
|
|
26108
|
+
}));
|
|
26015
26109
|
break;
|
|
26016
26110
|
case 21:
|
|
26017
26111
|
const newImsRCS = imsRCS.filter((item) => item.id !== fieldId);
|
|
26018
26112
|
setImsRCS(newImsRCS);
|
|
26113
|
+
setInitialSnapshot((prev) => ({
|
|
26114
|
+
...(prev ?? {}),
|
|
26115
|
+
ims_rcs: newImsRCS,
|
|
26116
|
+
}));
|
|
26019
26117
|
break;
|
|
26020
26118
|
case 41:
|
|
26021
26119
|
const newImsMercadolibre = imsMercadolibre.filter((item) => item.id !== fieldId);
|
|
26022
26120
|
setImsMercadolibre(newImsMercadolibre);
|
|
26121
|
+
setInitialSnapshot((prev) => ({
|
|
26122
|
+
...(prev ?? {}),
|
|
26123
|
+
ims_mercadolibre: newImsMercadolibre,
|
|
26124
|
+
}));
|
|
26023
26125
|
break;
|
|
26024
26126
|
case 14:
|
|
26025
26127
|
const newImsFacebooks = imsFacebooks.filter((item) => item.id !== fieldId);
|
|
26026
26128
|
setImsFacebooks(newImsFacebooks);
|
|
26129
|
+
setInitialSnapshot((prev) => ({
|
|
26130
|
+
...(prev ?? {}),
|
|
26131
|
+
ims_facebook: newImsFacebooks,
|
|
26132
|
+
}));
|
|
26027
26133
|
break;
|
|
26028
26134
|
case 20:
|
|
26029
26135
|
const newImsWebchats = imsWebchats.filter((item) => item.id !== fieldId);
|
|
26030
26136
|
setImsWebchats(newImsWebchats);
|
|
26137
|
+
setInitialSnapshot((prev) => ({
|
|
26138
|
+
...(prev ?? {}),
|
|
26139
|
+
ims_webchat: newImsWebchats,
|
|
26140
|
+
}));
|
|
26031
26141
|
break;
|
|
26032
26142
|
case 16:
|
|
26033
26143
|
const newImsInstagrams = imsInstagrams.filter((item) => item.id !== fieldId);
|
|
26034
26144
|
setImsInstagrams(newImsInstagrams);
|
|
26145
|
+
setInitialSnapshot((prev) => ({
|
|
26146
|
+
...(prev ?? {}),
|
|
26147
|
+
ims_instagram: newImsInstagrams,
|
|
26148
|
+
}));
|
|
26035
26149
|
break;
|
|
26036
26150
|
}
|
|
26037
26151
|
}
|
|
26038
26152
|
};
|
|
26039
26153
|
function resetToInitialContactInformation() {
|
|
26040
|
-
setImsFacebooks(
|
|
26041
|
-
setImsMercadolibre(
|
|
26042
|
-
setImsWebchats(
|
|
26043
|
-
setImsInstagrams(
|
|
26044
|
-
setImsWhatsApp(
|
|
26045
|
-
setImsRCS(
|
|
26046
|
-
setEmails(
|
|
26047
|
-
setPhoneNumbers(
|
|
26154
|
+
setImsFacebooks(initialSnapshot?.ims_facebook || []);
|
|
26155
|
+
setImsMercadolibre(initialSnapshot?.ims_mercadolibre || []);
|
|
26156
|
+
setImsWebchats(initialSnapshot?.ims_webchat || []);
|
|
26157
|
+
setImsInstagrams(initialSnapshot?.ims_instagram || []);
|
|
26158
|
+
setImsWhatsApp(initialSnapshot?.ims_whatsapp || []);
|
|
26159
|
+
setImsRCS(initialSnapshot?.ims_rcs || []);
|
|
26160
|
+
setEmails(initialSnapshot?.emails || []);
|
|
26161
|
+
setPhoneNumbers(initialSnapshot?.phones || []);
|
|
26048
26162
|
}
|
|
26049
26163
|
React$1.useEffect(() => {
|
|
26164
|
+
setInitialSnapshot(initial);
|
|
26050
26165
|
if (initial?.emails && initial?.phones) {
|
|
26051
26166
|
setEmails(initial.emails);
|
|
26052
26167
|
setPhoneNumbers(initial.phones);
|
|
@@ -26111,7 +26226,7 @@ const useMultipleSelect = ({ initialState = [], } = {}) => {
|
|
|
26111
26226
|
};
|
|
26112
26227
|
};
|
|
26113
26228
|
|
|
26114
|
-
const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) => {
|
|
26229
|
+
const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId, }) => {
|
|
26115
26230
|
const apiDeleteAddress = React$1.useMemo(() => async (payload) => {
|
|
26116
26231
|
if (!baseUrl || !spaceId)
|
|
26117
26232
|
return;
|
|
@@ -26151,8 +26266,7 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
|
|
|
26151
26266
|
const country = useField$1('text', business?.address1?.country || '');
|
|
26152
26267
|
const secondaryCountry = useField$1('text', business?.address2?.country || '');
|
|
26153
26268
|
const getEditedField = (key, originalValue, editedValue) => {
|
|
26154
|
-
if (originalValue !== editedValue &&
|
|
26155
|
-
!(originalValue === null && editedValue === '')) {
|
|
26269
|
+
if (originalValue !== editedValue && !(originalValue === null && editedValue === '')) {
|
|
26156
26270
|
return { [key]: editedValue };
|
|
26157
26271
|
}
|
|
26158
26272
|
return {};
|
|
@@ -26179,9 +26293,7 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
|
|
|
26179
26293
|
id: business.id,
|
|
26180
26294
|
...getEditedField('owner', business.owner, contactPropietary.attributes.value),
|
|
26181
26295
|
...getEditedField('name', business.name, name.attributes.value),
|
|
26182
|
-
imageUrl: contactImage.imageUrl
|
|
26183
|
-
? contactImage.removeParams(contactImage.imageUrl)
|
|
26184
|
-
: null,
|
|
26296
|
+
imageUrl: contactImage.imageUrl ? contactImage.removeParams(contactImage.imageUrl) : null,
|
|
26185
26297
|
tags: labelMultipleSelect.attributes.value,
|
|
26186
26298
|
properties: customProperties,
|
|
26187
26299
|
members: selectedContacts,
|
|
@@ -26196,26 +26308,23 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
|
|
|
26196
26308
|
function resetCustomProperty(nameKey) {
|
|
26197
26309
|
if (!business)
|
|
26198
26310
|
return;
|
|
26199
|
-
const
|
|
26311
|
+
const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
|
|
26312
|
+
const defaultProperty = business.properties.find((property) => property.nameKey === nameKey) ??
|
|
26313
|
+
business.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(nameKey));
|
|
26200
26314
|
if (!defaultProperty) {
|
|
26201
26315
|
console.error(`No se encontró una propiedad con nameKey: ${nameKey}`);
|
|
26202
26316
|
return; // Salir de la función si no se encuentra la propiedad
|
|
26203
26317
|
}
|
|
26204
|
-
const updatedProperties = customProperties.map((property) => property.nameKey === nameKey
|
|
26205
|
-
? { ...property, value: defaultProperty.value }
|
|
26206
|
-
: property);
|
|
26318
|
+
const updatedProperties = customProperties.map((property) => property.nameKey === nameKey ? { ...property, value: defaultProperty.value } : property);
|
|
26207
26319
|
setCustomProperties(updatedProperties);
|
|
26208
26320
|
}
|
|
26209
|
-
function replaceSpacesWithHyphen(input) {
|
|
26210
|
-
const result = input.replace(/ /g, '-');
|
|
26211
|
-
return result;
|
|
26212
|
-
}
|
|
26213
26321
|
const getFilteredCustomProperties = () => {
|
|
26214
26322
|
if (!business)
|
|
26215
26323
|
return [];
|
|
26216
26324
|
return customContactFields.map((customField) => {
|
|
26217
|
-
const
|
|
26218
|
-
const existingBusinessProperty = business.properties.find((property) => property.nameKey ===
|
|
26325
|
+
const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
|
|
26326
|
+
const existingBusinessProperty = business.properties.find((property) => property.nameKey === customField.nameKey) ??
|
|
26327
|
+
business.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(customField.nameKey));
|
|
26219
26328
|
if (existingBusinessProperty) {
|
|
26220
26329
|
return {
|
|
26221
26330
|
...existingBusinessProperty,
|
|
@@ -26300,7 +26409,7 @@ var dayjs_min = {exports: {}};
|
|
|
26300
26409
|
var dayjs_minExports = dayjs_min.exports;
|
|
26301
26410
|
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
26302
26411
|
|
|
26303
|
-
const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
|
|
26412
|
+
const useEditContact = ({ contact, customContactFields, baseUrl, spaceId, }) => {
|
|
26304
26413
|
const apiDeleteAddress = React$1.useMemo(() => async (payload) => {
|
|
26305
26414
|
if (!baseUrl || !spaceId)
|
|
26306
26415
|
return;
|
|
@@ -26384,9 +26493,7 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
|
|
|
26384
26493
|
phones: modifiedPhones,
|
|
26385
26494
|
// ims_whatsapp: modifiedImsWhatsapp,
|
|
26386
26495
|
tags: modifiedTags,
|
|
26387
|
-
imageUrl: contactImage.imageUrl
|
|
26388
|
-
? contactImage.removeParams(contactImage.imageUrl)
|
|
26389
|
-
: null,
|
|
26496
|
+
imageUrl: contactImage.imageUrl ? contactImage.removeParams(contactImage.imageUrl) : null,
|
|
26390
26497
|
properties: customProperties,
|
|
26391
26498
|
// businessId: selectedBusiness[0]?.businessId || '',
|
|
26392
26499
|
// businessName: selectedBusiness[0]?.businessName || '',
|
|
@@ -26412,27 +26519,23 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
|
|
|
26412
26519
|
function resetCustomProperty(nameKey) {
|
|
26413
26520
|
if (!contact)
|
|
26414
26521
|
return;
|
|
26415
|
-
const
|
|
26522
|
+
const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
|
|
26523
|
+
const defaultProperty = contact.properties.find((property) => property.nameKey === nameKey) ??
|
|
26524
|
+
contact.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(nameKey));
|
|
26416
26525
|
if (!defaultProperty) {
|
|
26417
26526
|
console.error(`No se encontró una propiedad con nameKey: ${nameKey}`);
|
|
26418
26527
|
return; // Salir de la función si no se encuentra la propiedad
|
|
26419
26528
|
}
|
|
26420
|
-
const updatedProperties = customProperties.map((property) => property.nameKey === nameKey
|
|
26421
|
-
? { ...property, value: defaultProperty.value }
|
|
26422
|
-
: property);
|
|
26529
|
+
const updatedProperties = customProperties.map((property) => property.nameKey === nameKey ? { ...property, value: defaultProperty.value } : property);
|
|
26423
26530
|
setCustomProperties(updatedProperties);
|
|
26424
26531
|
}
|
|
26425
|
-
// Utils
|
|
26426
|
-
function replaceSpacesWithHyphen(input) {
|
|
26427
|
-
const result = input.replace(/ /g, '-');
|
|
26428
|
-
return result;
|
|
26429
|
-
}
|
|
26430
26532
|
const getFilteredCustomProperties = () => {
|
|
26431
26533
|
if (!contact)
|
|
26432
26534
|
return [];
|
|
26433
26535
|
return customContactFields.map((customField) => {
|
|
26434
|
-
const
|
|
26435
|
-
const existingProperty = contact.properties.find((property) => property.nameKey ===
|
|
26536
|
+
const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
|
|
26537
|
+
const existingProperty = contact.properties.find((property) => property.nameKey === customField.nameKey) ??
|
|
26538
|
+
contact.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(customField.nameKey));
|
|
26436
26539
|
if (existingProperty) {
|
|
26437
26540
|
return {
|
|
26438
26541
|
...existingProperty,
|
|
@@ -26564,7 +26667,7 @@ const Section = ({ title, children }) => {
|
|
|
26564
26667
|
borderRadius: 2,
|
|
26565
26668
|
p: 2,
|
|
26566
26669
|
mb: 2,
|
|
26567
|
-
}, children: [jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle1",
|
|
26670
|
+
}, children: [jsxRuntimeExports.jsx(material.Typography, { variant: "subtitle1", children: title }), jsxRuntimeExports.jsx(material.Divider, { sx: { my: 1.5 } }), children] }));
|
|
26568
26671
|
};
|
|
26569
26672
|
|
|
26570
26673
|
const SectionContent = ({ children, ...boxProps }) => {
|
|
@@ -52712,7 +52815,7 @@ function SelectBusinessLabel({ value, displayValue, businessId }) {
|
|
|
52712
52815
|
}
|
|
52713
52816
|
setAnchorEl(targetElement);
|
|
52714
52817
|
};
|
|
52715
|
-
return (jsxRuntimeExports.jsxs(material.Box, { display: "flex", alignItems: "center", children: [jsxRuntimeExports.jsx(material.Typography, { onClick: handleOpenInfoPopover, fontWeight: '600', sx: {
|
|
52818
|
+
return (jsxRuntimeExports.jsxs(material.Box, { display: "flex", alignItems: "center", children: [jsxRuntimeExports.jsx(material.Typography, { onClick: handleOpenInfoPopover, variant: "body2", fontWeight: '600', sx: {
|
|
52716
52819
|
padding: 1,
|
|
52717
52820
|
cursor: 'pointer',
|
|
52718
52821
|
}, 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(material.Box, { display: "flex", alignItems: "center", justifyContent: "center", p: 1, children: jsxRuntimeExports.jsx(material.CircularProgress, { size: 20 }) }))] }));
|
|
@@ -52741,11 +52844,38 @@ const EntityInfoLabel = (props) => {
|
|
|
52741
52844
|
const inputType = props.inputType ?? 'text';
|
|
52742
52845
|
const [isEditing, setIsEditing] = React$1.useState(false);
|
|
52743
52846
|
const [isSaving, setIsSaving] = React$1.useState(false);
|
|
52847
|
+
const titleRef = React$1.useRef(null);
|
|
52848
|
+
const [isTitleTruncated, setIsTitleTruncated] = React$1.useState(false);
|
|
52744
52849
|
const [inputValue, setInputValue] = React$1.useState(() => {
|
|
52745
52850
|
if (props.entityType === 'business')
|
|
52746
52851
|
return value;
|
|
52747
52852
|
return typeof value === 'string' ? value : undefined;
|
|
52748
52853
|
});
|
|
52854
|
+
React$1.useEffect(() => {
|
|
52855
|
+
const el = titleRef.current;
|
|
52856
|
+
if (!el)
|
|
52857
|
+
return;
|
|
52858
|
+
const check = () => {
|
|
52859
|
+
const next = el.scrollWidth > el.clientWidth;
|
|
52860
|
+
setIsTitleTruncated(next);
|
|
52861
|
+
};
|
|
52862
|
+
check();
|
|
52863
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
52864
|
+
const ro = new ResizeObserver(() => {
|
|
52865
|
+
check();
|
|
52866
|
+
});
|
|
52867
|
+
ro.observe(el);
|
|
52868
|
+
return () => {
|
|
52869
|
+
ro.disconnect();
|
|
52870
|
+
};
|
|
52871
|
+
}
|
|
52872
|
+
if (typeof window === 'undefined')
|
|
52873
|
+
return;
|
|
52874
|
+
window.addEventListener('resize', check);
|
|
52875
|
+
return () => {
|
|
52876
|
+
window.removeEventListener('resize', check);
|
|
52877
|
+
};
|
|
52878
|
+
}, [title, isEditing]);
|
|
52749
52879
|
React$1.useEffect(() => {
|
|
52750
52880
|
if (props.entityType === 'business') {
|
|
52751
52881
|
setInputValue(value);
|
|
@@ -52850,12 +52980,17 @@ const EntityInfoLabel = (props) => {
|
|
|
52850
52980
|
'&:hover .edit-icon': {
|
|
52851
52981
|
opacity: 1,
|
|
52852
52982
|
},
|
|
52853
|
-
}, children: [jsxRuntimeExports.jsxs(material.Box, { display: "flex", position: "relative", minHeight: '25px', children: [
|
|
52983
|
+
}, children: [jsxRuntimeExports.jsxs(material.Box, { display: "flex", position: "relative", minHeight: '25px', children: [isTitleTruncated ? (jsxRuntimeExports.jsx(material.Tooltip, { title: title, arrow: true, children: jsxRuntimeExports.jsx(material.Typography, { 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: {
|
|
52984
|
+
minWidth: 0,
|
|
52985
|
+
overflow: 'hidden',
|
|
52986
|
+
textOverflow: 'ellipsis',
|
|
52987
|
+
whiteSpace: 'nowrap',
|
|
52988
|
+
}, children: title }) })) : (jsxRuntimeExports.jsx(material.Typography, { 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(material.CircularProgress, { 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(material.Box, { width: isEditing ? '100%' : '50%', position: "relative", children: isEditing && inputType === 'text' ? (jsxRuntimeExports.jsx(material.TextField, { value: textValue, onChange: handleInputChange, variant: "standard", size: "small", sx: { width: '100%' } })) : isEditing && (inputType === 'select' || inputType === 'selectMembers') ? (jsxRuntimeExports.jsxs(material.Select, { value: selectValue, onChange: handleSelectChange, variant: "standard", size: "small", sx: { width: '100%' }, children: [props.entityType === 'contact' ? (jsxRuntimeExports.jsx(material.MenuItem, { value: "", children: t('conversations.contactDetails.contactInfo.emptySelection') })) : null, options.map((option, index) => (jsxRuntimeExports.jsx(material.MenuItem, { value: option.id, children: props.entityType === 'contact'
|
|
52854
52989
|
? option.name?.trim() || (isUserInfo(option) ? option.email : '') || 'Sin nombre'
|
|
52855
52990
|
: 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 &&
|
|
52856
52991
|
props.entityType === 'contact' &&
|
|
52857
52992
|
inputType === 'selectBusiness' &&
|
|
52858
|
-
props.businessId ? (jsxRuntimeExports.jsx(SelectBusinessLabel, { value: value, displayValue: displayValue, businessId: props.businessId })) : (jsxRuntimeExports.jsx(material.Typography, { fontWeight: '400', sx: { padding: '2.5px 14px 8.5px 0px' }, color: (theme) => theme.palette.text.primary, children: displayValue || (typeof value === 'string' && value) || '-' })) })] }));
|
|
52993
|
+
props.businessId ? (jsxRuntimeExports.jsx(SelectBusinessLabel, { value: String(value ?? ''), displayValue: String(displayValue ?? ''), businessId: props.businessId })) : (jsxRuntimeExports.jsx(material.Typography, { variant: "body2", fontWeight: '400', sx: { padding: '2.5px 14px 8.5px 0px' }, color: (theme) => theme.palette.text.primary, children: displayValue || (typeof value === 'string' && value) || '-' })) })] }));
|
|
52859
52994
|
};
|
|
52860
52995
|
|
|
52861
52996
|
const ContactInfoLabel = (props) => {
|
|
@@ -54687,13 +54822,19 @@ const ContactBox = material.styled(material.Box)(({ theme }) => ({
|
|
|
54687
54822
|
}));
|
|
54688
54823
|
const FieldName = material.styled(material.Typography)(({ theme }) => ({
|
|
54689
54824
|
fontWeight: 600,
|
|
54825
|
+
fontSize: '0.875rem',
|
|
54690
54826
|
alignSelf: 'center',
|
|
54691
54827
|
color: theme.palette.text.primary,
|
|
54692
54828
|
letterSpacing: -0.5,
|
|
54693
54829
|
padding: 0,
|
|
54830
|
+
whiteSpace: 'nowrap',
|
|
54831
|
+
overflow: 'hidden',
|
|
54832
|
+
textOverflow: 'ellipsis',
|
|
54833
|
+
minWidth: 0,
|
|
54694
54834
|
}));
|
|
54695
54835
|
const FieldValue = material.styled(material.Typography)(({ theme }) => ({
|
|
54696
54836
|
fontWeight: 400,
|
|
54837
|
+
fontSize: '0.875rem',
|
|
54697
54838
|
padding: '2.5px 14px 8.5px 0px',
|
|
54698
54839
|
color: theme.palette.text.primary,
|
|
54699
54840
|
wordWrap: 'break-word',
|
|
@@ -54706,6 +54847,8 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
|
|
|
54706
54847
|
const { setCustomProperties } = entity.action;
|
|
54707
54848
|
const [isEditing, setIsEditing] = React$1.useState(false);
|
|
54708
54849
|
const [isSaving, setIsSaving] = React$1.useState(false);
|
|
54850
|
+
const titleRef = React$1.useRef(null);
|
|
54851
|
+
const [isTitleTruncated, setIsTitleTruncated] = React$1.useState(false);
|
|
54709
54852
|
const userDateFormat = (userTrii?.regCon_dateFormat || 'YYYY/MM/DD').toUpperCase();
|
|
54710
54853
|
const userTimeFormat = userTrii?.regCon_timeFormat || '24';
|
|
54711
54854
|
// Determina si el tipo de campo es numérico
|
|
@@ -54811,6 +54954,31 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
|
|
|
54811
54954
|
const foundField = customContactFields.find((field) => field.nameKey === propertyNameKey);
|
|
54812
54955
|
return foundField?.name || propertyNameKey;
|
|
54813
54956
|
};
|
|
54957
|
+
React$1.useEffect(() => {
|
|
54958
|
+
const el = titleRef.current;
|
|
54959
|
+
if (!el)
|
|
54960
|
+
return;
|
|
54961
|
+
const check = () => {
|
|
54962
|
+
const next = el.scrollWidth > el.clientWidth;
|
|
54963
|
+
setIsTitleTruncated(next);
|
|
54964
|
+
};
|
|
54965
|
+
check();
|
|
54966
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
54967
|
+
const ro = new ResizeObserver(() => {
|
|
54968
|
+
check();
|
|
54969
|
+
});
|
|
54970
|
+
ro.observe(el);
|
|
54971
|
+
return () => {
|
|
54972
|
+
ro.disconnect();
|
|
54973
|
+
};
|
|
54974
|
+
}
|
|
54975
|
+
if (typeof window === 'undefined')
|
|
54976
|
+
return;
|
|
54977
|
+
window.addEventListener('resize', check);
|
|
54978
|
+
return () => {
|
|
54979
|
+
window.removeEventListener('resize', check);
|
|
54980
|
+
};
|
|
54981
|
+
}, [customContactFields, property.nameKey, isEditing]);
|
|
54814
54982
|
const handleInputChange = (name, value) => {
|
|
54815
54983
|
const updatedValue = property.type === Contacts.ContactField_type.DATERANGE
|
|
54816
54984
|
? Array.isArray(value) && value[0] && value[1]
|
|
@@ -54863,7 +55031,7 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
|
|
|
54863
55031
|
else
|
|
54864
55032
|
return (jsxRuntimeExports.jsx(CustomPropertyInput, { type: type, nameKey: nameKey, value: value, onChange: handleInputChange }));
|
|
54865
55033
|
};
|
|
54866
|
-
return (jsxRuntimeExports.jsxs(ContactBox, { className: `fadein ${property.type === Contacts.ContactField_type.LONGTEXT ? 'contacts-col-12' : 'contacts-col-5'}`, children: [jsxRuntimeExports.jsxs(material.Box, { display: "flex", position: "relative", minHeight: "25px", children: [jsxRuntimeExports.jsx(FieldName, { flexGrow:
|
|
55034
|
+
return (jsxRuntimeExports.jsxs(ContactBox, { className: `fadein ${property.type === Contacts.ContactField_type.LONGTEXT ? 'contacts-col-12' : 'contacts-col-5'}`, children: [jsxRuntimeExports.jsxs(material.Box, { display: "flex", position: "relative", minHeight: "25px", alignItems: "center", children: [isTitleTruncated ? (jsxRuntimeExports.jsx(material.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(material.CircularProgress, { 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(material.Box, { width: isEditing || property.type === Contacts.ContactField_type.LONGTEXT ? '100%' : '50%', position: "relative", children: isEditing ? (EditField()) : (jsxRuntimeExports.jsx(FieldValue, { children: hasValue(property?.value)
|
|
54867
55035
|
? property.type === Contacts.ContactField_type.DATERANGE
|
|
54868
55036
|
? (() => {
|
|
54869
55037
|
if (typeof property.value === 'string') {
|
|
@@ -57330,7 +57498,7 @@ const AddressInformation = ({ entityType, entityData, baseUrl, spaceId, onEntity
|
|
|
57330
57498
|
onEntityUpdated,
|
|
57331
57499
|
};
|
|
57332
57500
|
const t = useTranslationContext();
|
|
57333
|
-
const AddressGroup = ({ addressNumber, title, }) => (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 rounded-xl p-4", children: [jsxRuntimeExports.jsx(material.Typography, { variant: "
|
|
57501
|
+
const AddressGroup = ({ addressNumber, title, }) => (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 rounded-xl p-4", children: [jsxRuntimeExports.jsx(material.Typography, { 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) => ({
|
|
57334
57502
|
[addressNumber]: { street: value },
|
|
57335
57503
|
}), minWidth: "100%" }) }), jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: entityType, title: t('conversations.contactDetails.city'), value: entityData[addressNumber]?.city ?? '', ...commonProps, constructUpdateObject: (value) => ({
|
|
57336
57504
|
[addressNumber]: { city: value },
|
|
@@ -57370,11 +57538,31 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
|
|
|
57370
57538
|
const [draftLabels, setDraftLabels] = React$1.useState([]);
|
|
57371
57539
|
const [tagsEditorInitialized, setTagsEditorInitialized] = React$1.useState(false);
|
|
57372
57540
|
const [isSaving, setIsSaving] = React$1.useState(false);
|
|
57541
|
+
const [createdLabels, setCreatedLabels] = React$1.useState([]);
|
|
57542
|
+
const [isCreatingLabel, setIsCreatingLabel] = React$1.useState(false);
|
|
57543
|
+
const labelsOptions = React$1.useMemo(() => {
|
|
57544
|
+
const safeLabels = labels ?? [];
|
|
57545
|
+
const safeCreated = createdLabels ?? [];
|
|
57546
|
+
const byId = new Map();
|
|
57547
|
+
for (const label of safeLabels) {
|
|
57548
|
+
if (!label?.id)
|
|
57549
|
+
continue;
|
|
57550
|
+
byId.set(String(label.id), label);
|
|
57551
|
+
}
|
|
57552
|
+
for (const label of safeCreated) {
|
|
57553
|
+
if (!label?.id)
|
|
57554
|
+
continue;
|
|
57555
|
+
byId.set(String(label.id), label);
|
|
57556
|
+
}
|
|
57557
|
+
return Array.from(byId.values());
|
|
57558
|
+
}, [labels, createdLabels]);
|
|
57373
57559
|
const reset = React$1.useCallback(() => {
|
|
57374
57560
|
setView('main');
|
|
57375
57561
|
setDraftLabels([]);
|
|
57376
57562
|
setTagsEditorInitialized(false);
|
|
57377
57563
|
setIsSaving(false);
|
|
57564
|
+
setCreatedLabels([]);
|
|
57565
|
+
setIsCreatingLabel(false);
|
|
57378
57566
|
}, []);
|
|
57379
57567
|
React$1.useEffect(() => {
|
|
57380
57568
|
if (!open) {
|
|
@@ -57388,13 +57576,61 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
|
|
|
57388
57576
|
}
|
|
57389
57577
|
if (tagsEditorInitialized)
|
|
57390
57578
|
return;
|
|
57391
|
-
if (!
|
|
57579
|
+
if (!labelsOptions.length)
|
|
57392
57580
|
return;
|
|
57393
57581
|
const selectedTagIds = new Set(selectedTags.map((t) => String(t.id)));
|
|
57394
|
-
const initialDraft =
|
|
57582
|
+
const initialDraft = labelsOptions.filter((l) => selectedTagIds.has(String(l?.id)));
|
|
57395
57583
|
setDraftLabels(initialDraft);
|
|
57396
57584
|
setTagsEditorInitialized(true);
|
|
57397
|
-
}, [view, tagsEditorInitialized,
|
|
57585
|
+
}, [view, tagsEditorInitialized, labelsOptions, selectedTags]);
|
|
57586
|
+
const handleCreateLabel = React$1.useCallback(async (name) => {
|
|
57587
|
+
if (isCreatingLabel)
|
|
57588
|
+
return;
|
|
57589
|
+
if (!baseUrl || !spaceId)
|
|
57590
|
+
return;
|
|
57591
|
+
const trimmedName = String(name ?? '').trim();
|
|
57592
|
+
if (!trimmedName)
|
|
57593
|
+
return;
|
|
57594
|
+
const normalizedName = trimmedName.toLowerCase();
|
|
57595
|
+
const existing = labelsOptions.find((l) => String(l?.name ?? '')
|
|
57596
|
+
.trim()
|
|
57597
|
+
.toLowerCase() === normalizedName);
|
|
57598
|
+
if (existing?.id) {
|
|
57599
|
+
setDraftLabels((prev) => {
|
|
57600
|
+
const safePrev = prev ?? [];
|
|
57601
|
+
const existsInDraft = safePrev.some((p) => String(p?.id) === String(existing.id));
|
|
57602
|
+
if (existsInDraft)
|
|
57603
|
+
return safePrev;
|
|
57604
|
+
return [...safePrev, existing];
|
|
57605
|
+
});
|
|
57606
|
+
return;
|
|
57607
|
+
}
|
|
57608
|
+
setIsCreatingLabel(true);
|
|
57609
|
+
try {
|
|
57610
|
+
const created = await createLabel({ baseUrl, spaceId, name: trimmedName });
|
|
57611
|
+
setCreatedLabels((prev) => {
|
|
57612
|
+
const safePrev = prev ?? [];
|
|
57613
|
+
if (!created?.id)
|
|
57614
|
+
return safePrev;
|
|
57615
|
+
const existsInCreated = safePrev.some((p) => String(p?.id) === String(created.id));
|
|
57616
|
+
if (existsInCreated)
|
|
57617
|
+
return safePrev;
|
|
57618
|
+
return [...safePrev, created];
|
|
57619
|
+
});
|
|
57620
|
+
setDraftLabels((prev) => {
|
|
57621
|
+
const safePrev = prev ?? [];
|
|
57622
|
+
if (!created?.id)
|
|
57623
|
+
return safePrev;
|
|
57624
|
+
const existsInDraft = safePrev.some((p) => String(p?.id) === String(created.id));
|
|
57625
|
+
if (existsInDraft)
|
|
57626
|
+
return safePrev;
|
|
57627
|
+
return [...safePrev, created];
|
|
57628
|
+
});
|
|
57629
|
+
}
|
|
57630
|
+
finally {
|
|
57631
|
+
setIsCreatingLabel(false);
|
|
57632
|
+
}
|
|
57633
|
+
}, [isCreatingLabel, baseUrl, spaceId, labelsOptions]);
|
|
57398
57634
|
const handleSaveTags = React$1.useCallback(async () => {
|
|
57399
57635
|
if (isSaving)
|
|
57400
57636
|
return;
|
|
@@ -57428,21 +57664,18 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
|
|
|
57428
57664
|
setView,
|
|
57429
57665
|
draftLabels,
|
|
57430
57666
|
setDraftLabels,
|
|
57667
|
+
labelsOptions,
|
|
57431
57668
|
isSaving,
|
|
57669
|
+
isCreatingLabel,
|
|
57670
|
+
handleCreateLabel,
|
|
57432
57671
|
handleSaveTags,
|
|
57433
57672
|
};
|
|
57434
57673
|
};
|
|
57435
57674
|
|
|
57436
57675
|
const useModalCloseHandler = ({ onClose }) => {
|
|
57437
|
-
const handleClose = React$1.useCallback((
|
|
57676
|
+
const handleClose = React$1.useCallback((_event, reason) => {
|
|
57438
57677
|
if (reason === 'escapeKeyDown') {
|
|
57439
|
-
|
|
57440
|
-
if (typeof maybeEvent?.stopPropagation === 'function') {
|
|
57441
|
-
maybeEvent.stopPropagation();
|
|
57442
|
-
}
|
|
57443
|
-
if (typeof maybeEvent?.preventDefault === 'function') {
|
|
57444
|
-
maybeEvent.preventDefault();
|
|
57445
|
-
}
|
|
57678
|
+
return;
|
|
57446
57679
|
}
|
|
57447
57680
|
onClose();
|
|
57448
57681
|
}, [onClose]);
|
|
@@ -57472,7 +57705,7 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, lang
|
|
|
57472
57705
|
entity: state.contactData,
|
|
57473
57706
|
setEntity: (next) => actions.setContactData(next ?? undefined),
|
|
57474
57707
|
});
|
|
57475
|
-
const { view, setView, draftLabels, setDraftLabels, isSaving: isSavingTags, handleSaveTags, } = useTagsEditorController({
|
|
57708
|
+
const { view, setView, draftLabels, setDraftLabels, labelsOptions, isSaving: isSavingTags, isCreatingLabel, handleCreateLabel, handleSaveTags, } = useTagsEditorController({
|
|
57476
57709
|
open,
|
|
57477
57710
|
baseUrl,
|
|
57478
57711
|
spaceId,
|
|
@@ -57512,20 +57745,26 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, lang
|
|
|
57512
57745
|
overflow: 'hidden',
|
|
57513
57746
|
};
|
|
57514
57747
|
const mergedSx = Array.isArray(sx) ? [baseSx, ...sx] : sx ? [baseSx, sx] : baseSx;
|
|
57515
|
-
return (jsxRuntimeExports.jsx(EditContactApiProvider, { value: api, children: jsxRuntimeExports.jsx(TranslationProvider, { t: t, children: jsxRuntimeExports.jsx(NavigateProvider, { navigate: navigate, children: jsxRuntimeExports.jsx(material.Modal, { open: open, onClose: handleClose, closeAfterTransition: true, slots: { backdrop: material.Backdrop }, slotProps: { backdrop: { timeout: 200 } }, children: jsxRuntimeExports.jsx(material.Fade, { in: open, timeout: 200, children: jsxRuntimeExports.
|
|
57516
|
-
|
|
57517
|
-
|
|
57518
|
-
|
|
57519
|
-
|
|
57520
|
-
|
|
57521
|
-
|
|
57522
|
-
|
|
57523
|
-
|
|
57524
|
-
|
|
57525
|
-
|
|
57526
|
-
|
|
57527
|
-
|
|
57528
|
-
|
|
57748
|
+
return (jsxRuntimeExports.jsx(EditContactApiProvider, { value: api, children: jsxRuntimeExports.jsx(TranslationProvider, { t: t, children: jsxRuntimeExports.jsx(NavigateProvider, { navigate: navigate, children: jsxRuntimeExports.jsx(material.Modal, { open: open, onClose: handleClose, closeAfterTransition: true, slots: { backdrop: material.Backdrop }, slotProps: { backdrop: { timeout: 200 } }, children: jsxRuntimeExports.jsx(material.Fade, { in: open, timeout: 200, children: jsxRuntimeExports.jsxs(material.Box, { sx: mergedSx, children: [jsxRuntimeExports.jsx(material.IconButton, { "aria-label": "close", onClick: handleClose, sx: {
|
|
57749
|
+
position: 'absolute',
|
|
57750
|
+
right: 8,
|
|
57751
|
+
top: 8,
|
|
57752
|
+
color: (theme) => theme.palette.grey[500],
|
|
57753
|
+
zIndex: 1,
|
|
57754
|
+
}, children: jsxRuntimeExports.jsx(default_1$g, {}) }), state.isLoading && !state.contactData ? (jsxRuntimeExports.jsx(material.Box, { sx: {
|
|
57755
|
+
display: 'flex',
|
|
57756
|
+
justifyContent: 'center',
|
|
57757
|
+
alignItems: 'center',
|
|
57758
|
+
minHeight: 220,
|
|
57759
|
+
}, children: jsxRuntimeExports.jsx(material.CircularProgress, {}) })) : state.error ? (jsxRuntimeExports.jsx(material.Box, { 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(material.Box, { sx: { position: 'relative', height: '100%' }, children: [jsxRuntimeExports.jsx(material.Fade, { in: view === 'main', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsxs(material.Box, { sx: { pt: 0.5, position: 'absolute', inset: 0, overflowY: 'auto' }, children: [jsxRuntimeExports.jsx(Header, { imgUrl: image.imageUrl, displayName: selectors.displayName, tags: selectors.tags, onEditTags: () => {
|
|
57760
|
+
setView('tags');
|
|
57761
|
+
}, 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(material.Box, { sx: { px: 1, pb: 2 }, children: [jsxRuntimeExports.jsx(General, { dateFormat: selectors.userTrii?.regCon_dateFormat || 'MM/dd/yyyy', entityType: selectors.contactType === 'contact' ||
|
|
57762
|
+
selectors.contactType === 'business'
|
|
57763
|
+
? selectors.contactType
|
|
57764
|
+
: 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated, currentUser: selectors.userTrii }), jsxRuntimeExports.jsx(AddressInformation, { entityType: selectors.contactType === 'contact' ||
|
|
57765
|
+
selectors.contactType === 'business'
|
|
57766
|
+
? selectors.contactType
|
|
57767
|
+
: 'contact', entityData: state.contactData, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated }), jsxRuntimeExports.jsx(ContactInformation, { ownerData: state.contactData })] })] }) }), jsxRuntimeExports.jsx(material.Fade, { in: view === 'tags', timeout: 200, mountOnEnter: true, unmountOnExit: true, children: jsxRuntimeExports.jsx(material.Box, { 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 }) }) })] }) })) : null] }) }) }) }) }) }));
|
|
57529
57768
|
};
|
|
57530
57769
|
|
|
57531
57770
|
exports.i18n = i18n;
|