@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/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)({
|
|
@@ -15272,11 +15272,16 @@ const MembersSection = ({ contactData, title, navigate }) => {
|
|
|
15272
15272
|
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)))] }));
|
|
15273
15273
|
};
|
|
15274
15274
|
|
|
15275
|
+
var add$1 = "Add";
|
|
15276
|
+
var close$1 = "Close";
|
|
15275
15277
|
var labels$1 = "Labels";
|
|
15276
15278
|
var phone$1 = "Phone";
|
|
15279
|
+
var phones$1 = "Phones";
|
|
15280
|
+
var number$1 = "Number";
|
|
15277
15281
|
var business$1 = "Business";
|
|
15278
15282
|
var businessMembers$1 = "Business Members";
|
|
15279
15283
|
var properties$1 = "Properties";
|
|
15284
|
+
var note$1 = "Note";
|
|
15280
15285
|
var view$1 = "View";
|
|
15281
15286
|
var email$1 = "Email";
|
|
15282
15287
|
var tags$1 = "Tags";
|
|
@@ -15320,11 +15325,16 @@ var conversations$1 = {
|
|
|
15320
15325
|
}
|
|
15321
15326
|
};
|
|
15322
15327
|
var en = {
|
|
15328
|
+
add: add$1,
|
|
15329
|
+
close: close$1,
|
|
15323
15330
|
labels: labels$1,
|
|
15324
15331
|
phone: phone$1,
|
|
15332
|
+
phones: phones$1,
|
|
15333
|
+
number: number$1,
|
|
15325
15334
|
business: business$1,
|
|
15326
15335
|
businessMembers: businessMembers$1,
|
|
15327
15336
|
properties: properties$1,
|
|
15337
|
+
note: note$1,
|
|
15328
15338
|
view: view$1,
|
|
15329
15339
|
email: email$1,
|
|
15330
15340
|
tags: tags$1,
|
|
@@ -15334,11 +15344,16 @@ var en = {
|
|
|
15334
15344
|
conversations: conversations$1
|
|
15335
15345
|
};
|
|
15336
15346
|
|
|
15347
|
+
var add = "Agregar";
|
|
15348
|
+
var close = "Cerrar";
|
|
15337
15349
|
var labels = "Etiquetas";
|
|
15338
15350
|
var phone = "Teléfono";
|
|
15351
|
+
var phones = "Teléfonos";
|
|
15352
|
+
var number = "Número";
|
|
15339
15353
|
var business = "Empresa";
|
|
15340
15354
|
var businessMembers = "Miembros de la empresa";
|
|
15341
15355
|
var properties = "Propiedades";
|
|
15356
|
+
var note = "Nota";
|
|
15342
15357
|
var view = "Ver";
|
|
15343
15358
|
var email = "Correo Electrónico";
|
|
15344
15359
|
var tags = "Etiquetas";
|
|
@@ -15382,11 +15397,16 @@ var conversations = {
|
|
|
15382
15397
|
}
|
|
15383
15398
|
};
|
|
15384
15399
|
var es = {
|
|
15400
|
+
add: add,
|
|
15401
|
+
close: close,
|
|
15385
15402
|
labels: labels,
|
|
15386
15403
|
phone: phone,
|
|
15404
|
+
phones: phones,
|
|
15405
|
+
number: number,
|
|
15387
15406
|
business: business,
|
|
15388
15407
|
businessMembers: businessMembers,
|
|
15389
15408
|
properties: properties,
|
|
15409
|
+
note: note,
|
|
15390
15410
|
view: view,
|
|
15391
15411
|
email: email,
|
|
15392
15412
|
tags: tags,
|
|
@@ -15500,6 +15520,19 @@ const ContactInfoPopup = ({ open, anchorEl, onClose, contactData, avatarImgUrl,
|
|
|
15500
15520
|
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
15521
|
};
|
|
15502
15522
|
|
|
15523
|
+
var Close = {};
|
|
15524
|
+
|
|
15525
|
+
var _interopRequireDefault$f = interopRequireDefaultExports;
|
|
15526
|
+
Object.defineProperty(Close, "__esModule", {
|
|
15527
|
+
value: true
|
|
15528
|
+
});
|
|
15529
|
+
var default_1$g = Close.default = void 0;
|
|
15530
|
+
var _createSvgIcon$f = _interopRequireDefault$f(requireCreateSvgIcon());
|
|
15531
|
+
var _jsxRuntime$f = jsxRuntimeExports;
|
|
15532
|
+
default_1$g = Close.default = (0, _createSvgIcon$f.default)( /*#__PURE__*/(0, _jsxRuntime$f.jsx)("path", {
|
|
15533
|
+
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"
|
|
15534
|
+
}), 'Close');
|
|
15535
|
+
|
|
15503
15536
|
var Edit = {};
|
|
15504
15537
|
|
|
15505
15538
|
var _interopRequireDefault$e = interopRequireDefaultExports;
|
|
@@ -15564,7 +15597,6 @@ const Tags = ({ tags, onEditTags }) => {
|
|
|
15564
15597
|
justifyContent: 'center',
|
|
15565
15598
|
}, children: [jsxRuntimeExports.jsxs(Box$2, { sx: {
|
|
15566
15599
|
maxWidth: 320,
|
|
15567
|
-
pr: 4,
|
|
15568
15600
|
position: 'relative',
|
|
15569
15601
|
'&:hover .tags-action, &:focus-within .tags-action': {
|
|
15570
15602
|
opacity: 1,
|
|
@@ -15578,7 +15610,8 @@ const Tags = ({ tags, onEditTags }) => {
|
|
|
15578
15610
|
},
|
|
15579
15611
|
} }, 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
15612
|
position: 'absolute',
|
|
15581
|
-
|
|
15613
|
+
left: '100%',
|
|
15614
|
+
ml: 1,
|
|
15582
15615
|
top: '50%',
|
|
15583
15616
|
transform: 'translateY(-50%)',
|
|
15584
15617
|
color: 'text.secondary',
|
|
@@ -15589,7 +15622,7 @@ const Tags = ({ tags, onEditTags }) => {
|
|
|
15589
15622
|
bgcolor: 'action.hover',
|
|
15590
15623
|
color: 'text.primary',
|
|
15591
15624
|
},
|
|
15592
|
-
}, children: safeTags.length ?
|
|
15625
|
+
}, 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
15626
|
borderRadius: 999,
|
|
15594
15627
|
maxWidth: 160,
|
|
15595
15628
|
'& .MuiChip-label': {
|
|
@@ -15616,8 +15649,13 @@ const NameWrapper = styled$5(Box$2)({
|
|
|
15616
15649
|
display: 'flex',
|
|
15617
15650
|
alignItems: 'center',
|
|
15618
15651
|
justifyContent: 'center',
|
|
15619
|
-
gap: '8px',
|
|
15620
15652
|
width: '100%',
|
|
15653
|
+
});
|
|
15654
|
+
const NameContainer = styled$5(Box$2)({
|
|
15655
|
+
position: 'relative',
|
|
15656
|
+
display: 'flex',
|
|
15657
|
+
justifyContent: 'center',
|
|
15658
|
+
maxWidth: '100%',
|
|
15621
15659
|
'&:hover .edit-icon': {
|
|
15622
15660
|
opacity: 1,
|
|
15623
15661
|
visibility: 'visible',
|
|
@@ -15627,6 +15665,10 @@ const EditButton = styled$5(IconButton$2)({
|
|
|
15627
15665
|
opacity: 0,
|
|
15628
15666
|
visibility: 'hidden',
|
|
15629
15667
|
transition: 'all 0.2s',
|
|
15668
|
+
position: 'absolute',
|
|
15669
|
+
left: '100%',
|
|
15670
|
+
top: '50%',
|
|
15671
|
+
transform: 'translateY(-50%)',
|
|
15630
15672
|
});
|
|
15631
15673
|
const ContactName = ({ displayName, contactType, firstName, lastName, name, entityId, onEntityUpdated, }) => {
|
|
15632
15674
|
const api = useEditContactApi();
|
|
@@ -15677,7 +15719,7 @@ const ContactName = ({ displayName, contactType, firstName, lastName, name, enti
|
|
|
15677
15719
|
if (isEditing) {
|
|
15678
15720
|
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
15721
|
}
|
|
15680
|
-
return (jsxRuntimeExports.
|
|
15722
|
+
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
15723
|
};
|
|
15682
15724
|
|
|
15683
15725
|
var Delete = {};
|
|
@@ -24792,7 +24834,7 @@ const PAGE_SIZE = 20;
|
|
|
24792
24834
|
const AutocompletePopper = styled$3(MuiPopper)(({ theme }) => ({
|
|
24793
24835
|
zIndex: theme.zIndex.modal + 1,
|
|
24794
24836
|
}));
|
|
24795
|
-
const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving }) => {
|
|
24837
|
+
const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving, onCreateNew, isCreatingNew, }) => {
|
|
24796
24838
|
const t = useTranslationContext();
|
|
24797
24839
|
const [searchValue, setSearchValue] = useState('');
|
|
24798
24840
|
const [limit, setLimit] = useState(PAGE_SIZE);
|
|
@@ -24808,10 +24850,19 @@ const TagsEditor = ({ value, options, onChange, onBack, onSave, isSaving }) => {
|
|
|
24808
24850
|
if (nearBottom)
|
|
24809
24851
|
setLimit((l) => l + PAGE_SIZE);
|
|
24810
24852
|
};
|
|
24811
|
-
|
|
24853
|
+
const CustomNoOptionsMessage = () => {
|
|
24854
|
+
const trimmedSearchValue = String(searchValue ?? '').trim();
|
|
24855
|
+
const isDisabled = !trimmedSearchValue || isSaving || isCreatingNew;
|
|
24856
|
+
return (jsxRuntimeExports.jsxs(Box$2, { sx: {
|
|
24857
|
+
display: 'flex',
|
|
24858
|
+
justifyContent: 'space-between',
|
|
24859
|
+
alignItems: 'center',
|
|
24860
|
+
}, 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') })] }));
|
|
24861
|
+
};
|
|
24862
|
+
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: AutocompletePopper, 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
24863
|
onScroll: onListboxScroll,
|
|
24813
24864
|
sx: { maxHeight: 280, overflowY: 'auto' },
|
|
24814
|
-
}, noOptionsText:
|
|
24865
|
+
}, noOptionsText: jsxRuntimeExports.jsx(CustomNoOptionsMessage, {}), sx: { width: '100%' } })] }));
|
|
24815
24866
|
};
|
|
24816
24867
|
|
|
24817
24868
|
class ApiError extends Error {
|
|
@@ -24885,17 +24936,22 @@ async function fetchLabels({ baseUrl, spaceId, signal }) {
|
|
|
24885
24936
|
const url = joinUrl(urls.CONTACTS, '/labels');
|
|
24886
24937
|
return requestJson({ url, signal });
|
|
24887
24938
|
}
|
|
24939
|
+
async function createLabel({ baseUrl, spaceId, name, signal }) {
|
|
24940
|
+
const urls = getApiUrls(baseUrl, spaceId);
|
|
24941
|
+
const url = joinUrl(urls.CONTACTS, '/labels');
|
|
24942
|
+
return requestJson({ url, method: 'POST', body: { name }, signal });
|
|
24943
|
+
}
|
|
24888
24944
|
async function fetchContact({ baseUrl, spaceId, contactId, signal }) {
|
|
24889
24945
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24890
24946
|
const url = joinUrl(urls.CONTACTS, `/contacts/${encodeURIComponent(contactId)}`);
|
|
24891
24947
|
return requestJson({ url, signal });
|
|
24892
24948
|
}
|
|
24893
|
-
async function fetchContactFields({ baseUrl, spaceId, forType, signal }) {
|
|
24949
|
+
async function fetchContactFields({ baseUrl, spaceId, forType, signal, }) {
|
|
24894
24950
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24895
24951
|
const url = `${joinUrl(urls.CONTACTS, '/ContactFields')}?filter=custom&for=${encodeURIComponent(forType)}`;
|
|
24896
24952
|
return requestJson({ url, signal });
|
|
24897
24953
|
}
|
|
24898
|
-
async function updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal }) {
|
|
24954
|
+
async function updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal, }) {
|
|
24899
24955
|
const path = entityType === 'business'
|
|
24900
24956
|
? `/business/${encodeURIComponent(entityId)}`
|
|
24901
24957
|
: `/contacts/${encodeURIComponent(entityId)}`;
|
|
@@ -24908,7 +24964,7 @@ async function deleteAddress({ baseUrl, spaceId, data, signal }) {
|
|
|
24908
24964
|
const url = joinUrl(urls.CONTACTS, '/contactAddresses');
|
|
24909
24965
|
return requestJson({ url, method: 'DELETE', body: data, signal });
|
|
24910
24966
|
}
|
|
24911
|
-
async function checkContactAddress({ baseUrl, spaceId, data, signal }) {
|
|
24967
|
+
async function checkContactAddress({ baseUrl, spaceId, data, signal, }) {
|
|
24912
24968
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24913
24969
|
const url = joinUrl(urls.CONTACTS, '/contactAddresses/check');
|
|
24914
24970
|
return requestJson({ url, method: 'POST', body: data, signal });
|
|
@@ -24918,7 +24974,7 @@ async function setContactAddress({ baseUrl, spaceId, data, signal }) {
|
|
|
24918
24974
|
const url = joinUrl(urls.CONTACTS, '/contactAddresses/set');
|
|
24919
24975
|
return requestJson({ url, method: 'POST', body: data, signal });
|
|
24920
24976
|
}
|
|
24921
|
-
async function updateContactAddress({ baseUrl, spaceId, data, signal }) {
|
|
24977
|
+
async function updateContactAddress({ baseUrl, spaceId, data, signal, }) {
|
|
24922
24978
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24923
24979
|
const url = joinUrl(urls.CONTACTS, `/contactAddresses/${encodeURIComponent(data.contactAddressId)}`);
|
|
24924
24980
|
return requestJson({ url, method: 'PUT', body: data, signal });
|
|
@@ -24933,12 +24989,12 @@ async function fetchUsers({ baseUrl, spaceId, signal }) {
|
|
|
24933
24989
|
const url = joinUrl(urls.SETTINGS, `/users`);
|
|
24934
24990
|
return requestJson({ url, signal });
|
|
24935
24991
|
}
|
|
24936
|
-
async function fetchUserTriiById({ baseUrl, spaceId, signal, userId }) {
|
|
24992
|
+
async function fetchUserTriiById({ baseUrl, spaceId, signal, userId, }) {
|
|
24937
24993
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24938
24994
|
const url = joinUrl(urls.SETTINGS, `/usersInfor/${userId}`);
|
|
24939
24995
|
return requestJson({ url, signal });
|
|
24940
24996
|
}
|
|
24941
|
-
async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal }) {
|
|
24997
|
+
async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal, }) {
|
|
24942
24998
|
const urls = getApiUrls(baseUrl, spaceId);
|
|
24943
24999
|
const fd = new FormData();
|
|
24944
25000
|
fd.append('file', file, file.name);
|
|
@@ -24947,6 +25003,7 @@ async function uploadAvatar({ baseUrl, spaceId, contactId, file, signal }) {
|
|
|
24947
25003
|
}
|
|
24948
25004
|
const createEditContactApi = (baseUrl, spaceId) => ({
|
|
24949
25005
|
fetchLabels: ({ signal } = {}) => fetchLabels({ baseUrl, spaceId, signal }),
|
|
25006
|
+
createLabel: ({ name, signal }) => createLabel({ baseUrl, spaceId, name, signal }),
|
|
24950
25007
|
fetchContact: ({ contactId, signal }) => fetchContact({ baseUrl, spaceId, contactId, signal }),
|
|
24951
25008
|
fetchContactFields: ({ forType, signal }) => fetchContactFields({ baseUrl, spaceId, forType, signal }),
|
|
24952
25009
|
updateEntity: ({ entityType, entityId, body, signal }) => updateEntity({ baseUrl, spaceId, entityType, entityId, body, signal }),
|
|
@@ -25753,6 +25810,7 @@ var editContactHelper = { getEditedField, getAddressesWithUpdatedValues };
|
|
|
25753
25810
|
|
|
25754
25811
|
const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, }) => {
|
|
25755
25812
|
const [isDeletingAddress, setIsDeletingAddress] = useState(false);
|
|
25813
|
+
const [initialSnapshot, setInitialSnapshot] = useState(() => initial);
|
|
25756
25814
|
const [imsFacebooks, setImsFacebooks] = useState(initial?.ims_facebook || []);
|
|
25757
25815
|
const [imsMercadolibre, setImsMercadolibre] = useState(initial?.ims_mercadolibre || []);
|
|
25758
25816
|
const [imsWebchats, setImsWebchats] = useState(initial?.ims_webchat || []);
|
|
@@ -25784,6 +25842,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25784
25842
|
const addWhatsappVerified = (newWhatsapp) => {
|
|
25785
25843
|
const updatedWhatsapps = [...imsWhatsapp, newWhatsapp];
|
|
25786
25844
|
setImsWhatsApp(updatedWhatsapps);
|
|
25845
|
+
setInitialSnapshot((prev) => ({
|
|
25846
|
+
...(prev ?? {}),
|
|
25847
|
+
ims_whatsapp: updatedWhatsapps,
|
|
25848
|
+
}));
|
|
25787
25849
|
};
|
|
25788
25850
|
const replaceAddress = (addressId, newAddress) => {
|
|
25789
25851
|
if (!newAddress) {
|
|
@@ -25797,6 +25859,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25797
25859
|
return email;
|
|
25798
25860
|
});
|
|
25799
25861
|
setEmails(newEmails);
|
|
25862
|
+
setInitialSnapshot((prev) => ({
|
|
25863
|
+
...(prev ?? {}),
|
|
25864
|
+
emails: newEmails,
|
|
25865
|
+
}));
|
|
25800
25866
|
}
|
|
25801
25867
|
if (newAddress.channelType === 5) {
|
|
25802
25868
|
const newPhoneNumbers = phoneNumbers.map((phoneNumber) => {
|
|
@@ -25806,6 +25872,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25806
25872
|
return phoneNumber;
|
|
25807
25873
|
});
|
|
25808
25874
|
setPhoneNumbers(newPhoneNumbers);
|
|
25875
|
+
setInitialSnapshot((prev) => ({
|
|
25876
|
+
...(prev ?? {}),
|
|
25877
|
+
phones: newPhoneNumbers,
|
|
25878
|
+
}));
|
|
25809
25879
|
}
|
|
25810
25880
|
if (newAddress.channelType === 13) {
|
|
25811
25881
|
const newImsWhatsapp = imsWhatsapp.map((item) => {
|
|
@@ -25815,6 +25885,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25815
25885
|
return item;
|
|
25816
25886
|
});
|
|
25817
25887
|
setImsWhatsApp(newImsWhatsapp);
|
|
25888
|
+
setInitialSnapshot((prev) => ({
|
|
25889
|
+
...(prev ?? {}),
|
|
25890
|
+
ims_whatsapp: newImsWhatsapp,
|
|
25891
|
+
}));
|
|
25818
25892
|
}
|
|
25819
25893
|
if (newAddress.channelType === 21) {
|
|
25820
25894
|
const newImsRCS = imsRCS.map((item) => {
|
|
@@ -25824,6 +25898,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25824
25898
|
return item;
|
|
25825
25899
|
});
|
|
25826
25900
|
setImsRCS(newImsRCS);
|
|
25901
|
+
setInitialSnapshot((prev) => ({
|
|
25902
|
+
...(prev ?? {}),
|
|
25903
|
+
ims_rcs: newImsRCS,
|
|
25904
|
+
}));
|
|
25827
25905
|
}
|
|
25828
25906
|
if (newAddress.channelType === 41) {
|
|
25829
25907
|
const newImsMercadolibre = imsMercadolibre.map((item) => {
|
|
@@ -25833,6 +25911,10 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25833
25911
|
return item;
|
|
25834
25912
|
});
|
|
25835
25913
|
setImsMercadolibre(newImsMercadolibre);
|
|
25914
|
+
setInitialSnapshot((prev) => ({
|
|
25915
|
+
...(prev ?? {}),
|
|
25916
|
+
ims_mercadolibre: newImsMercadolibre,
|
|
25917
|
+
}));
|
|
25836
25918
|
}
|
|
25837
25919
|
};
|
|
25838
25920
|
const handleAddressFieldChange = async (e, fieldId, type) => {
|
|
@@ -25985,49 +26067,82 @@ const useEditContactMethods = ({ entityId, initial, dispatch, deleteAddress, })
|
|
|
25985
26067
|
case 3:
|
|
25986
26068
|
const newEmails = emails.filter((email) => email.id !== fieldId);
|
|
25987
26069
|
setEmails(newEmails);
|
|
26070
|
+
setInitialSnapshot((prev) => ({
|
|
26071
|
+
...(prev ?? {}),
|
|
26072
|
+
emails: newEmails,
|
|
26073
|
+
}));
|
|
25988
26074
|
break;
|
|
25989
26075
|
case 5:
|
|
25990
26076
|
const newPhoneNumbers = phoneNumbers.filter((phoneNumber) => phoneNumber.id !== fieldId);
|
|
25991
26077
|
setPhoneNumbers(newPhoneNumbers);
|
|
26078
|
+
setInitialSnapshot((prev) => ({
|
|
26079
|
+
...(prev ?? {}),
|
|
26080
|
+
phones: newPhoneNumbers,
|
|
26081
|
+
}));
|
|
25992
26082
|
break;
|
|
25993
26083
|
case 13:
|
|
25994
26084
|
const newImsWhatsapp = imsWhatsapp.filter((item) => item.id !== fieldId);
|
|
25995
26085
|
setImsWhatsApp(newImsWhatsapp);
|
|
26086
|
+
setInitialSnapshot((prev) => ({
|
|
26087
|
+
...(prev ?? {}),
|
|
26088
|
+
ims_whatsapp: newImsWhatsapp,
|
|
26089
|
+
}));
|
|
25996
26090
|
break;
|
|
25997
26091
|
case 21:
|
|
25998
26092
|
const newImsRCS = imsRCS.filter((item) => item.id !== fieldId);
|
|
25999
26093
|
setImsRCS(newImsRCS);
|
|
26094
|
+
setInitialSnapshot((prev) => ({
|
|
26095
|
+
...(prev ?? {}),
|
|
26096
|
+
ims_rcs: newImsRCS,
|
|
26097
|
+
}));
|
|
26000
26098
|
break;
|
|
26001
26099
|
case 41:
|
|
26002
26100
|
const newImsMercadolibre = imsMercadolibre.filter((item) => item.id !== fieldId);
|
|
26003
26101
|
setImsMercadolibre(newImsMercadolibre);
|
|
26102
|
+
setInitialSnapshot((prev) => ({
|
|
26103
|
+
...(prev ?? {}),
|
|
26104
|
+
ims_mercadolibre: newImsMercadolibre,
|
|
26105
|
+
}));
|
|
26004
26106
|
break;
|
|
26005
26107
|
case 14:
|
|
26006
26108
|
const newImsFacebooks = imsFacebooks.filter((item) => item.id !== fieldId);
|
|
26007
26109
|
setImsFacebooks(newImsFacebooks);
|
|
26110
|
+
setInitialSnapshot((prev) => ({
|
|
26111
|
+
...(prev ?? {}),
|
|
26112
|
+
ims_facebook: newImsFacebooks,
|
|
26113
|
+
}));
|
|
26008
26114
|
break;
|
|
26009
26115
|
case 20:
|
|
26010
26116
|
const newImsWebchats = imsWebchats.filter((item) => item.id !== fieldId);
|
|
26011
26117
|
setImsWebchats(newImsWebchats);
|
|
26118
|
+
setInitialSnapshot((prev) => ({
|
|
26119
|
+
...(prev ?? {}),
|
|
26120
|
+
ims_webchat: newImsWebchats,
|
|
26121
|
+
}));
|
|
26012
26122
|
break;
|
|
26013
26123
|
case 16:
|
|
26014
26124
|
const newImsInstagrams = imsInstagrams.filter((item) => item.id !== fieldId);
|
|
26015
26125
|
setImsInstagrams(newImsInstagrams);
|
|
26126
|
+
setInitialSnapshot((prev) => ({
|
|
26127
|
+
...(prev ?? {}),
|
|
26128
|
+
ims_instagram: newImsInstagrams,
|
|
26129
|
+
}));
|
|
26016
26130
|
break;
|
|
26017
26131
|
}
|
|
26018
26132
|
}
|
|
26019
26133
|
};
|
|
26020
26134
|
function resetToInitialContactInformation() {
|
|
26021
|
-
setImsFacebooks(
|
|
26022
|
-
setImsMercadolibre(
|
|
26023
|
-
setImsWebchats(
|
|
26024
|
-
setImsInstagrams(
|
|
26025
|
-
setImsWhatsApp(
|
|
26026
|
-
setImsRCS(
|
|
26027
|
-
setEmails(
|
|
26028
|
-
setPhoneNumbers(
|
|
26135
|
+
setImsFacebooks(initialSnapshot?.ims_facebook || []);
|
|
26136
|
+
setImsMercadolibre(initialSnapshot?.ims_mercadolibre || []);
|
|
26137
|
+
setImsWebchats(initialSnapshot?.ims_webchat || []);
|
|
26138
|
+
setImsInstagrams(initialSnapshot?.ims_instagram || []);
|
|
26139
|
+
setImsWhatsApp(initialSnapshot?.ims_whatsapp || []);
|
|
26140
|
+
setImsRCS(initialSnapshot?.ims_rcs || []);
|
|
26141
|
+
setEmails(initialSnapshot?.emails || []);
|
|
26142
|
+
setPhoneNumbers(initialSnapshot?.phones || []);
|
|
26029
26143
|
}
|
|
26030
26144
|
useEffect(() => {
|
|
26145
|
+
setInitialSnapshot(initial);
|
|
26031
26146
|
if (initial?.emails && initial?.phones) {
|
|
26032
26147
|
setEmails(initial.emails);
|
|
26033
26148
|
setPhoneNumbers(initial.phones);
|
|
@@ -26092,7 +26207,7 @@ const useMultipleSelect = ({ initialState = [], } = {}) => {
|
|
|
26092
26207
|
};
|
|
26093
26208
|
};
|
|
26094
26209
|
|
|
26095
|
-
const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) => {
|
|
26210
|
+
const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId, }) => {
|
|
26096
26211
|
const apiDeleteAddress = useMemo(() => async (payload) => {
|
|
26097
26212
|
if (!baseUrl || !spaceId)
|
|
26098
26213
|
return;
|
|
@@ -26132,8 +26247,7 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
|
|
|
26132
26247
|
const country = useField$1('text', business?.address1?.country || '');
|
|
26133
26248
|
const secondaryCountry = useField$1('text', business?.address2?.country || '');
|
|
26134
26249
|
const getEditedField = (key, originalValue, editedValue) => {
|
|
26135
|
-
if (originalValue !== editedValue &&
|
|
26136
|
-
!(originalValue === null && editedValue === '')) {
|
|
26250
|
+
if (originalValue !== editedValue && !(originalValue === null && editedValue === '')) {
|
|
26137
26251
|
return { [key]: editedValue };
|
|
26138
26252
|
}
|
|
26139
26253
|
return {};
|
|
@@ -26160,9 +26274,7 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
|
|
|
26160
26274
|
id: business.id,
|
|
26161
26275
|
...getEditedField('owner', business.owner, contactPropietary.attributes.value),
|
|
26162
26276
|
...getEditedField('name', business.name, name.attributes.value),
|
|
26163
|
-
imageUrl: contactImage.imageUrl
|
|
26164
|
-
? contactImage.removeParams(contactImage.imageUrl)
|
|
26165
|
-
: null,
|
|
26277
|
+
imageUrl: contactImage.imageUrl ? contactImage.removeParams(contactImage.imageUrl) : null,
|
|
26166
26278
|
tags: labelMultipleSelect.attributes.value,
|
|
26167
26279
|
properties: customProperties,
|
|
26168
26280
|
members: selectedContacts,
|
|
@@ -26177,26 +26289,23 @@ const useEditBusiness = ({ business, customContactFields, baseUrl, spaceId }) =>
|
|
|
26177
26289
|
function resetCustomProperty(nameKey) {
|
|
26178
26290
|
if (!business)
|
|
26179
26291
|
return;
|
|
26180
|
-
const
|
|
26292
|
+
const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
|
|
26293
|
+
const defaultProperty = business.properties.find((property) => property.nameKey === nameKey) ??
|
|
26294
|
+
business.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(nameKey));
|
|
26181
26295
|
if (!defaultProperty) {
|
|
26182
26296
|
console.error(`No se encontró una propiedad con nameKey: ${nameKey}`);
|
|
26183
26297
|
return; // Salir de la función si no se encuentra la propiedad
|
|
26184
26298
|
}
|
|
26185
|
-
const updatedProperties = customProperties.map((property) => property.nameKey === nameKey
|
|
26186
|
-
? { ...property, value: defaultProperty.value }
|
|
26187
|
-
: property);
|
|
26299
|
+
const updatedProperties = customProperties.map((property) => property.nameKey === nameKey ? { ...property, value: defaultProperty.value } : property);
|
|
26188
26300
|
setCustomProperties(updatedProperties);
|
|
26189
26301
|
}
|
|
26190
|
-
function replaceSpacesWithHyphen(input) {
|
|
26191
|
-
const result = input.replace(/ /g, '-');
|
|
26192
|
-
return result;
|
|
26193
|
-
}
|
|
26194
26302
|
const getFilteredCustomProperties = () => {
|
|
26195
26303
|
if (!business)
|
|
26196
26304
|
return [];
|
|
26197
26305
|
return customContactFields.map((customField) => {
|
|
26198
|
-
const
|
|
26199
|
-
const existingBusinessProperty = business.properties.find((property) => property.nameKey ===
|
|
26306
|
+
const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
|
|
26307
|
+
const existingBusinessProperty = business.properties.find((property) => property.nameKey === customField.nameKey) ??
|
|
26308
|
+
business.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(customField.nameKey));
|
|
26200
26309
|
if (existingBusinessProperty) {
|
|
26201
26310
|
return {
|
|
26202
26311
|
...existingBusinessProperty,
|
|
@@ -26281,7 +26390,7 @@ var dayjs_min = {exports: {}};
|
|
|
26281
26390
|
var dayjs_minExports = dayjs_min.exports;
|
|
26282
26391
|
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
26283
26392
|
|
|
26284
|
-
const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
|
|
26393
|
+
const useEditContact = ({ contact, customContactFields, baseUrl, spaceId, }) => {
|
|
26285
26394
|
const apiDeleteAddress = useMemo(() => async (payload) => {
|
|
26286
26395
|
if (!baseUrl || !spaceId)
|
|
26287
26396
|
return;
|
|
@@ -26365,9 +26474,7 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
|
|
|
26365
26474
|
phones: modifiedPhones,
|
|
26366
26475
|
// ims_whatsapp: modifiedImsWhatsapp,
|
|
26367
26476
|
tags: modifiedTags,
|
|
26368
|
-
imageUrl: contactImage.imageUrl
|
|
26369
|
-
? contactImage.removeParams(contactImage.imageUrl)
|
|
26370
|
-
: null,
|
|
26477
|
+
imageUrl: contactImage.imageUrl ? contactImage.removeParams(contactImage.imageUrl) : null,
|
|
26371
26478
|
properties: customProperties,
|
|
26372
26479
|
// businessId: selectedBusiness[0]?.businessId || '',
|
|
26373
26480
|
// businessName: selectedBusiness[0]?.businessName || '',
|
|
@@ -26393,27 +26500,23 @@ const useEditContact = ({ contact, customContactFields, baseUrl, spaceId }) => {
|
|
|
26393
26500
|
function resetCustomProperty(nameKey) {
|
|
26394
26501
|
if (!contact)
|
|
26395
26502
|
return;
|
|
26396
|
-
const
|
|
26503
|
+
const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
|
|
26504
|
+
const defaultProperty = contact.properties.find((property) => property.nameKey === nameKey) ??
|
|
26505
|
+
contact.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(nameKey));
|
|
26397
26506
|
if (!defaultProperty) {
|
|
26398
26507
|
console.error(`No se encontró una propiedad con nameKey: ${nameKey}`);
|
|
26399
26508
|
return; // Salir de la función si no se encuentra la propiedad
|
|
26400
26509
|
}
|
|
26401
|
-
const updatedProperties = customProperties.map((property) => property.nameKey === nameKey
|
|
26402
|
-
? { ...property, value: defaultProperty.value }
|
|
26403
|
-
: property);
|
|
26510
|
+
const updatedProperties = customProperties.map((property) => property.nameKey === nameKey ? { ...property, value: defaultProperty.value } : property);
|
|
26404
26511
|
setCustomProperties(updatedProperties);
|
|
26405
26512
|
}
|
|
26406
|
-
// Utils
|
|
26407
|
-
function replaceSpacesWithHyphen(input) {
|
|
26408
|
-
const result = input.replace(/ /g, '-');
|
|
26409
|
-
return result;
|
|
26410
|
-
}
|
|
26411
26513
|
const getFilteredCustomProperties = () => {
|
|
26412
26514
|
if (!contact)
|
|
26413
26515
|
return [];
|
|
26414
26516
|
return customContactFields.map((customField) => {
|
|
26415
|
-
const
|
|
26416
|
-
const existingProperty = contact.properties.find((property) => property.nameKey ===
|
|
26517
|
+
const normalizeNameKey = (input) => input.trim().toLowerCase().replace(/\s+/g, '-').replace(/-+/g, '-');
|
|
26518
|
+
const existingProperty = contact.properties.find((property) => property.nameKey === customField.nameKey) ??
|
|
26519
|
+
contact.properties.find((property) => normalizeNameKey(property.nameKey) === normalizeNameKey(customField.nameKey));
|
|
26417
26520
|
if (existingProperty) {
|
|
26418
26521
|
return {
|
|
26419
26522
|
...existingProperty,
|
|
@@ -26545,7 +26648,7 @@ const Section = ({ title, children }) => {
|
|
|
26545
26648
|
borderRadius: 2,
|
|
26546
26649
|
p: 2,
|
|
26547
26650
|
mb: 2,
|
|
26548
|
-
}, children: [jsxRuntimeExports.jsx(Typography$2, { variant: "subtitle1",
|
|
26651
|
+
}, children: [jsxRuntimeExports.jsx(Typography$2, { variant: "subtitle1", children: title }), jsxRuntimeExports.jsx(Divider, { sx: { my: 1.5 } }), children] }));
|
|
26549
26652
|
};
|
|
26550
26653
|
|
|
26551
26654
|
const SectionContent = ({ children, ...boxProps }) => {
|
|
@@ -52693,7 +52796,7 @@ function SelectBusinessLabel({ value, displayValue, businessId }) {
|
|
|
52693
52796
|
}
|
|
52694
52797
|
setAnchorEl(targetElement);
|
|
52695
52798
|
};
|
|
52696
|
-
return (jsxRuntimeExports.jsxs(Box$2, { display: "flex", alignItems: "center", children: [jsxRuntimeExports.jsx(Typography$2, { onClick: handleOpenInfoPopover, fontWeight: '600', sx: {
|
|
52799
|
+
return (jsxRuntimeExports.jsxs(Box$2, { display: "flex", alignItems: "center", children: [jsxRuntimeExports.jsx(Typography$2, { onClick: handleOpenInfoPopover, variant: "body2", fontWeight: '600', sx: {
|
|
52697
52800
|
padding: 1,
|
|
52698
52801
|
cursor: 'pointer',
|
|
52699
52802
|
}, 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 +52825,38 @@ const EntityInfoLabel = (props) => {
|
|
|
52722
52825
|
const inputType = props.inputType ?? 'text';
|
|
52723
52826
|
const [isEditing, setIsEditing] = useState(false);
|
|
52724
52827
|
const [isSaving, setIsSaving] = useState(false);
|
|
52828
|
+
const titleRef = useRef(null);
|
|
52829
|
+
const [isTitleTruncated, setIsTitleTruncated] = useState(false);
|
|
52725
52830
|
const [inputValue, setInputValue] = useState(() => {
|
|
52726
52831
|
if (props.entityType === 'business')
|
|
52727
52832
|
return value;
|
|
52728
52833
|
return typeof value === 'string' ? value : undefined;
|
|
52729
52834
|
});
|
|
52835
|
+
useEffect(() => {
|
|
52836
|
+
const el = titleRef.current;
|
|
52837
|
+
if (!el)
|
|
52838
|
+
return;
|
|
52839
|
+
const check = () => {
|
|
52840
|
+
const next = el.scrollWidth > el.clientWidth;
|
|
52841
|
+
setIsTitleTruncated(next);
|
|
52842
|
+
};
|
|
52843
|
+
check();
|
|
52844
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
52845
|
+
const ro = new ResizeObserver(() => {
|
|
52846
|
+
check();
|
|
52847
|
+
});
|
|
52848
|
+
ro.observe(el);
|
|
52849
|
+
return () => {
|
|
52850
|
+
ro.disconnect();
|
|
52851
|
+
};
|
|
52852
|
+
}
|
|
52853
|
+
if (typeof window === 'undefined')
|
|
52854
|
+
return;
|
|
52855
|
+
window.addEventListener('resize', check);
|
|
52856
|
+
return () => {
|
|
52857
|
+
window.removeEventListener('resize', check);
|
|
52858
|
+
};
|
|
52859
|
+
}, [title, isEditing]);
|
|
52730
52860
|
useEffect(() => {
|
|
52731
52861
|
if (props.entityType === 'business') {
|
|
52732
52862
|
setInputValue(value);
|
|
@@ -52831,12 +52961,17 @@ const EntityInfoLabel = (props) => {
|
|
|
52831
52961
|
'&:hover .edit-icon': {
|
|
52832
52962
|
opacity: 1,
|
|
52833
52963
|
},
|
|
52834
|
-
}, children: [jsxRuntimeExports.jsxs(Box$2, { display: "flex", position: "relative", minHeight: '25px', children: [
|
|
52964
|
+
}, 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: {
|
|
52965
|
+
minWidth: 0,
|
|
52966
|
+
overflow: 'hidden',
|
|
52967
|
+
textOverflow: 'ellipsis',
|
|
52968
|
+
whiteSpace: 'nowrap',
|
|
52969
|
+
}, 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
52970
|
? option.name?.trim() || (isUserInfo(option) ? option.email : '') || 'Sin nombre'
|
|
52836
52971
|
: 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
52972
|
props.entityType === 'contact' &&
|
|
52838
52973
|
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) || '-' })) })] }));
|
|
52974
|
+
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
52975
|
};
|
|
52841
52976
|
|
|
52842
52977
|
const ContactInfoLabel = (props) => {
|
|
@@ -54668,13 +54803,19 @@ const ContactBox = styled$5(Box$2)(({ theme }) => ({
|
|
|
54668
54803
|
}));
|
|
54669
54804
|
const FieldName = styled$5(Typography$2)(({ theme }) => ({
|
|
54670
54805
|
fontWeight: 600,
|
|
54806
|
+
fontSize: '0.875rem',
|
|
54671
54807
|
alignSelf: 'center',
|
|
54672
54808
|
color: theme.palette.text.primary,
|
|
54673
54809
|
letterSpacing: -0.5,
|
|
54674
54810
|
padding: 0,
|
|
54811
|
+
whiteSpace: 'nowrap',
|
|
54812
|
+
overflow: 'hidden',
|
|
54813
|
+
textOverflow: 'ellipsis',
|
|
54814
|
+
minWidth: 0,
|
|
54675
54815
|
}));
|
|
54676
54816
|
const FieldValue = styled$5(Typography$2)(({ theme }) => ({
|
|
54677
54817
|
fontWeight: 400,
|
|
54818
|
+
fontSize: '0.875rem',
|
|
54678
54819
|
padding: '2.5px 14px 8.5px 0px',
|
|
54679
54820
|
color: theme.palette.text.primary,
|
|
54680
54821
|
wordWrap: 'break-word',
|
|
@@ -54687,6 +54828,8 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
|
|
|
54687
54828
|
const { setCustomProperties } = entity.action;
|
|
54688
54829
|
const [isEditing, setIsEditing] = useState(false);
|
|
54689
54830
|
const [isSaving, setIsSaving] = useState(false);
|
|
54831
|
+
const titleRef = useRef(null);
|
|
54832
|
+
const [isTitleTruncated, setIsTitleTruncated] = useState(false);
|
|
54690
54833
|
const userDateFormat = (userTrii?.regCon_dateFormat || 'YYYY/MM/DD').toUpperCase();
|
|
54691
54834
|
const userTimeFormat = userTrii?.regCon_timeFormat || '24';
|
|
54692
54835
|
// Determina si el tipo de campo es numérico
|
|
@@ -54792,6 +54935,31 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
|
|
|
54792
54935
|
const foundField = customContactFields.find((field) => field.nameKey === propertyNameKey);
|
|
54793
54936
|
return foundField?.name || propertyNameKey;
|
|
54794
54937
|
};
|
|
54938
|
+
useEffect(() => {
|
|
54939
|
+
const el = titleRef.current;
|
|
54940
|
+
if (!el)
|
|
54941
|
+
return;
|
|
54942
|
+
const check = () => {
|
|
54943
|
+
const next = el.scrollWidth > el.clientWidth;
|
|
54944
|
+
setIsTitleTruncated(next);
|
|
54945
|
+
};
|
|
54946
|
+
check();
|
|
54947
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
54948
|
+
const ro = new ResizeObserver(() => {
|
|
54949
|
+
check();
|
|
54950
|
+
});
|
|
54951
|
+
ro.observe(el);
|
|
54952
|
+
return () => {
|
|
54953
|
+
ro.disconnect();
|
|
54954
|
+
};
|
|
54955
|
+
}
|
|
54956
|
+
if (typeof window === 'undefined')
|
|
54957
|
+
return;
|
|
54958
|
+
window.addEventListener('resize', check);
|
|
54959
|
+
return () => {
|
|
54960
|
+
window.removeEventListener('resize', check);
|
|
54961
|
+
};
|
|
54962
|
+
}, [customContactFields, property.nameKey, isEditing]);
|
|
54795
54963
|
const handleInputChange = (name, value) => {
|
|
54796
54964
|
const updatedValue = property.type === Contacts.ContactField_type.DATERANGE
|
|
54797
54965
|
? Array.isArray(value) && value[0] && value[1]
|
|
@@ -54844,7 +55012,7 @@ const EntityCustomFieldLabel = ({ property, entity, entityType, entityId, custom
|
|
|
54844
55012
|
else
|
|
54845
55013
|
return (jsxRuntimeExports.jsx(CustomPropertyInput, { type: type, nameKey: nameKey, value: value, onChange: handleInputChange }));
|
|
54846
55014
|
};
|
|
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:
|
|
55015
|
+
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
55016
|
? property.type === Contacts.ContactField_type.DATERANGE
|
|
54849
55017
|
? (() => {
|
|
54850
55018
|
if (typeof property.value === 'string') {
|
|
@@ -57311,7 +57479,7 @@ const AddressInformation = ({ entityType, entityData, baseUrl, spaceId, onEntity
|
|
|
57311
57479
|
onEntityUpdated,
|
|
57312
57480
|
};
|
|
57313
57481
|
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: "
|
|
57482
|
+
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
57483
|
[addressNumber]: { street: value },
|
|
57316
57484
|
}), minWidth: "100%" }) }), jsxRuntimeExports.jsx(EntityInfoLabel, { entityType: entityType, title: t('conversations.contactDetails.city'), value: entityData[addressNumber]?.city ?? '', ...commonProps, constructUpdateObject: (value) => ({
|
|
57317
57485
|
[addressNumber]: { city: value },
|
|
@@ -57351,11 +57519,31 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
|
|
|
57351
57519
|
const [draftLabels, setDraftLabels] = useState([]);
|
|
57352
57520
|
const [tagsEditorInitialized, setTagsEditorInitialized] = useState(false);
|
|
57353
57521
|
const [isSaving, setIsSaving] = useState(false);
|
|
57522
|
+
const [createdLabels, setCreatedLabels] = useState([]);
|
|
57523
|
+
const [isCreatingLabel, setIsCreatingLabel] = useState(false);
|
|
57524
|
+
const labelsOptions = useMemo(() => {
|
|
57525
|
+
const safeLabels = labels ?? [];
|
|
57526
|
+
const safeCreated = createdLabels ?? [];
|
|
57527
|
+
const byId = new Map();
|
|
57528
|
+
for (const label of safeLabels) {
|
|
57529
|
+
if (!label?.id)
|
|
57530
|
+
continue;
|
|
57531
|
+
byId.set(String(label.id), label);
|
|
57532
|
+
}
|
|
57533
|
+
for (const label of safeCreated) {
|
|
57534
|
+
if (!label?.id)
|
|
57535
|
+
continue;
|
|
57536
|
+
byId.set(String(label.id), label);
|
|
57537
|
+
}
|
|
57538
|
+
return Array.from(byId.values());
|
|
57539
|
+
}, [labels, createdLabels]);
|
|
57354
57540
|
const reset = useCallback(() => {
|
|
57355
57541
|
setView('main');
|
|
57356
57542
|
setDraftLabels([]);
|
|
57357
57543
|
setTagsEditorInitialized(false);
|
|
57358
57544
|
setIsSaving(false);
|
|
57545
|
+
setCreatedLabels([]);
|
|
57546
|
+
setIsCreatingLabel(false);
|
|
57359
57547
|
}, []);
|
|
57360
57548
|
useEffect(() => {
|
|
57361
57549
|
if (!open) {
|
|
@@ -57369,13 +57557,61 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
|
|
|
57369
57557
|
}
|
|
57370
57558
|
if (tagsEditorInitialized)
|
|
57371
57559
|
return;
|
|
57372
|
-
if (!
|
|
57560
|
+
if (!labelsOptions.length)
|
|
57373
57561
|
return;
|
|
57374
57562
|
const selectedTagIds = new Set(selectedTags.map((t) => String(t.id)));
|
|
57375
|
-
const initialDraft =
|
|
57563
|
+
const initialDraft = labelsOptions.filter((l) => selectedTagIds.has(String(l?.id)));
|
|
57376
57564
|
setDraftLabels(initialDraft);
|
|
57377
57565
|
setTagsEditorInitialized(true);
|
|
57378
|
-
}, [view, tagsEditorInitialized,
|
|
57566
|
+
}, [view, tagsEditorInitialized, labelsOptions, selectedTags]);
|
|
57567
|
+
const handleCreateLabel = useCallback(async (name) => {
|
|
57568
|
+
if (isCreatingLabel)
|
|
57569
|
+
return;
|
|
57570
|
+
if (!baseUrl || !spaceId)
|
|
57571
|
+
return;
|
|
57572
|
+
const trimmedName = String(name ?? '').trim();
|
|
57573
|
+
if (!trimmedName)
|
|
57574
|
+
return;
|
|
57575
|
+
const normalizedName = trimmedName.toLowerCase();
|
|
57576
|
+
const existing = labelsOptions.find((l) => String(l?.name ?? '')
|
|
57577
|
+
.trim()
|
|
57578
|
+
.toLowerCase() === normalizedName);
|
|
57579
|
+
if (existing?.id) {
|
|
57580
|
+
setDraftLabels((prev) => {
|
|
57581
|
+
const safePrev = prev ?? [];
|
|
57582
|
+
const existsInDraft = safePrev.some((p) => String(p?.id) === String(existing.id));
|
|
57583
|
+
if (existsInDraft)
|
|
57584
|
+
return safePrev;
|
|
57585
|
+
return [...safePrev, existing];
|
|
57586
|
+
});
|
|
57587
|
+
return;
|
|
57588
|
+
}
|
|
57589
|
+
setIsCreatingLabel(true);
|
|
57590
|
+
try {
|
|
57591
|
+
const created = await createLabel({ baseUrl, spaceId, name: trimmedName });
|
|
57592
|
+
setCreatedLabels((prev) => {
|
|
57593
|
+
const safePrev = prev ?? [];
|
|
57594
|
+
if (!created?.id)
|
|
57595
|
+
return safePrev;
|
|
57596
|
+
const existsInCreated = safePrev.some((p) => String(p?.id) === String(created.id));
|
|
57597
|
+
if (existsInCreated)
|
|
57598
|
+
return safePrev;
|
|
57599
|
+
return [...safePrev, created];
|
|
57600
|
+
});
|
|
57601
|
+
setDraftLabels((prev) => {
|
|
57602
|
+
const safePrev = prev ?? [];
|
|
57603
|
+
if (!created?.id)
|
|
57604
|
+
return safePrev;
|
|
57605
|
+
const existsInDraft = safePrev.some((p) => String(p?.id) === String(created.id));
|
|
57606
|
+
if (existsInDraft)
|
|
57607
|
+
return safePrev;
|
|
57608
|
+
return [...safePrev, created];
|
|
57609
|
+
});
|
|
57610
|
+
}
|
|
57611
|
+
finally {
|
|
57612
|
+
setIsCreatingLabel(false);
|
|
57613
|
+
}
|
|
57614
|
+
}, [isCreatingLabel, baseUrl, spaceId, labelsOptions]);
|
|
57379
57615
|
const handleSaveTags = useCallback(async () => {
|
|
57380
57616
|
if (isSaving)
|
|
57381
57617
|
return;
|
|
@@ -57409,21 +57645,18 @@ const useTagsEditorController = ({ open, baseUrl, spaceId, contactData, contactT
|
|
|
57409
57645
|
setView,
|
|
57410
57646
|
draftLabels,
|
|
57411
57647
|
setDraftLabels,
|
|
57648
|
+
labelsOptions,
|
|
57412
57649
|
isSaving,
|
|
57650
|
+
isCreatingLabel,
|
|
57651
|
+
handleCreateLabel,
|
|
57413
57652
|
handleSaveTags,
|
|
57414
57653
|
};
|
|
57415
57654
|
};
|
|
57416
57655
|
|
|
57417
57656
|
const useModalCloseHandler = ({ onClose }) => {
|
|
57418
|
-
const handleClose = useCallback((
|
|
57657
|
+
const handleClose = useCallback((_event, reason) => {
|
|
57419
57658
|
if (reason === 'escapeKeyDown') {
|
|
57420
|
-
|
|
57421
|
-
if (typeof maybeEvent?.stopPropagation === 'function') {
|
|
57422
|
-
maybeEvent.stopPropagation();
|
|
57423
|
-
}
|
|
57424
|
-
if (typeof maybeEvent?.preventDefault === 'function') {
|
|
57425
|
-
maybeEvent.preventDefault();
|
|
57426
|
-
}
|
|
57659
|
+
return;
|
|
57427
57660
|
}
|
|
57428
57661
|
onClose();
|
|
57429
57662
|
}, [onClose]);
|
|
@@ -57453,7 +57686,7 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, lang
|
|
|
57453
57686
|
entity: state.contactData,
|
|
57454
57687
|
setEntity: (next) => actions.setContactData(next ?? undefined),
|
|
57455
57688
|
});
|
|
57456
|
-
const { view, setView, draftLabels, setDraftLabels, isSaving: isSavingTags, handleSaveTags, } = useTagsEditorController({
|
|
57689
|
+
const { view, setView, draftLabels, setDraftLabels, labelsOptions, isSaving: isSavingTags, isCreatingLabel, handleCreateLabel, handleSaveTags, } = useTagsEditorController({
|
|
57457
57690
|
open,
|
|
57458
57691
|
baseUrl,
|
|
57459
57692
|
spaceId,
|
|
@@ -57493,20 +57726,26 @@ const EditContactModal = ({ open, onClose, baseUrl, spaceId, contactId, sx, lang
|
|
|
57493
57726
|
overflow: 'hidden',
|
|
57494
57727
|
};
|
|
57495
57728
|
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
|
-
|
|
57729
|
+
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, children: [jsxRuntimeExports.jsx(IconButton$2, { "aria-label": "close", onClick: handleClose, sx: {
|
|
57730
|
+
position: 'absolute',
|
|
57731
|
+
right: 8,
|
|
57732
|
+
top: 8,
|
|
57733
|
+
color: (theme) => theme.palette.grey[500],
|
|
57734
|
+
zIndex: 1,
|
|
57735
|
+
}, children: jsxRuntimeExports.jsx(default_1$g, {}) }), state.isLoading && !state.contactData ? (jsxRuntimeExports.jsx(Box$2, { sx: {
|
|
57736
|
+
display: 'flex',
|
|
57737
|
+
justifyContent: 'center',
|
|
57738
|
+
alignItems: 'center',
|
|
57739
|
+
minHeight: 220,
|
|
57740
|
+
}, 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: () => {
|
|
57741
|
+
setView('tags');
|
|
57742
|
+
}, 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' ||
|
|
57743
|
+
selectors.contactType === 'business'
|
|
57744
|
+
? selectors.contactType
|
|
57745
|
+
: 'contact', entityData: state.contactData, customContactFields: selectors.contactFields, baseUrl: baseUrl, spaceId: spaceId, onEntityUpdated: handleEntityUpdated, currentUser: selectors.userTrii }), jsxRuntimeExports.jsx(AddressInformation, { entityType: selectors.contactType === 'contact' ||
|
|
57746
|
+
selectors.contactType === 'business'
|
|
57747
|
+
? selectors.contactType
|
|
57748
|
+
: '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 }) }) })] }) })) : null] }) }) }) }) }) }));
|
|
57510
57749
|
};
|
|
57511
57750
|
|
|
57512
57751
|
export { ContactInfoPopup, EditContactModal };
|