@plusscommunities/pluss-core-web 1.4.30 → 1.4.31-auth0.0
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/index.cjs.js +136 -84
- package/dist/index.esm.js +136 -84
- package/dist/index.umd.js +136 -84
- package/package.json +2 -2
- package/src/apis/fileActions.js +28 -7
- package/src/components/AudienceSelector.js +1 -1
- package/src/components/FileInput.js +1 -1
- package/src/components/ImageInput.js +26 -23
- package/src/config.js +5 -0
- package/src/helper/HelpDeskWidget.js +6 -42
- package/src/session.js +2 -3
package/dist/index.cjs.js
CHANGED
|
@@ -79,7 +79,75 @@ var CoreConfig = {
|
|
|
79
79
|
defaultAllowComments: true,
|
|
80
80
|
makeApiKey: '',
|
|
81
81
|
logo: '',
|
|
82
|
-
clientName: ''
|
|
82
|
+
clientName: '',
|
|
83
|
+
AuthStrategy: {
|
|
84
|
+
getAccessToken: function () {
|
|
85
|
+
var _getAccessToken = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
|
86
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
87
|
+
while (1) {
|
|
88
|
+
switch (_context.prev = _context.next) {
|
|
89
|
+
case 0:
|
|
90
|
+
return _context.abrupt("return", null);
|
|
91
|
+
|
|
92
|
+
case 1:
|
|
93
|
+
case "end":
|
|
94
|
+
return _context.stop();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, _callee);
|
|
98
|
+
}));
|
|
99
|
+
|
|
100
|
+
function getAccessToken() {
|
|
101
|
+
return _getAccessToken.apply(this, arguments);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return getAccessToken;
|
|
105
|
+
}(),
|
|
106
|
+
getCurrentUserId: function () {
|
|
107
|
+
var _getCurrentUserId = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
108
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
109
|
+
while (1) {
|
|
110
|
+
switch (_context2.prev = _context2.next) {
|
|
111
|
+
case 0:
|
|
112
|
+
return _context2.abrupt("return", null);
|
|
113
|
+
|
|
114
|
+
case 1:
|
|
115
|
+
case "end":
|
|
116
|
+
return _context2.stop();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}, _callee2);
|
|
120
|
+
}));
|
|
121
|
+
|
|
122
|
+
function getCurrentUserId() {
|
|
123
|
+
return _getCurrentUserId.apply(this, arguments);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return getCurrentUserId;
|
|
127
|
+
}(),
|
|
128
|
+
hasActiveSession: function () {
|
|
129
|
+
var _hasActiveSession = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
130
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
131
|
+
while (1) {
|
|
132
|
+
switch (_context3.prev = _context3.next) {
|
|
133
|
+
case 0:
|
|
134
|
+
return _context3.abrupt("return", false);
|
|
135
|
+
|
|
136
|
+
case 1:
|
|
137
|
+
case "end":
|
|
138
|
+
return _context3.stop();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}, _callee3);
|
|
142
|
+
}));
|
|
143
|
+
|
|
144
|
+
function hasActiveSession() {
|
|
145
|
+
return _hasActiveSession.apply(this, arguments);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return hasActiveSession;
|
|
149
|
+
}()
|
|
150
|
+
}
|
|
83
151
|
},
|
|
84
152
|
init: function init(environment) {
|
|
85
153
|
CoreConfig.env = environment;
|
|
@@ -88,29 +156,28 @@ var CoreConfig = {
|
|
|
88
156
|
|
|
89
157
|
var getSessionTokenAWS = /*#__PURE__*/function () {
|
|
90
158
|
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(prefix) {
|
|
91
|
-
var
|
|
159
|
+
var token;
|
|
92
160
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
93
161
|
while (1) {
|
|
94
162
|
switch (_context.prev = _context.next) {
|
|
95
163
|
case 0:
|
|
96
164
|
_context.next = 2;
|
|
97
|
-
return
|
|
165
|
+
return CoreConfig.env.AuthStrategy.getAccessToken();
|
|
98
166
|
|
|
99
167
|
case 2:
|
|
100
|
-
|
|
101
|
-
token = data.getAccessToken().getJwtToken();
|
|
168
|
+
token = _context.sent;
|
|
102
169
|
|
|
103
170
|
if (!___default['default'].isUndefined(prefix)) {
|
|
104
|
-
_context.next =
|
|
171
|
+
_context.next = 5;
|
|
105
172
|
break;
|
|
106
173
|
}
|
|
107
174
|
|
|
108
175
|
return _context.abrupt("return", token);
|
|
109
176
|
|
|
110
|
-
case
|
|
177
|
+
case 5:
|
|
111
178
|
return _context.abrupt("return", "".concat(prefix, " ").concat(token));
|
|
112
179
|
|
|
113
|
-
case
|
|
180
|
+
case 6:
|
|
114
181
|
case "end":
|
|
115
182
|
return _context.stop();
|
|
116
183
|
}
|
|
@@ -1096,48 +1163,15 @@ var getPluralOptions = function getPluralOptions(count, singular, plural) {
|
|
|
1096
1163
|
};
|
|
1097
1164
|
|
|
1098
1165
|
var setChatUser = function setChatUser(auth) {
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
setChatUser(auth);
|
|
1102
|
-
}, 1000);
|
|
1103
|
-
return;
|
|
1104
|
-
}
|
|
1166
|
+
return;
|
|
1167
|
+
}; // deprecated
|
|
1105
1168
|
|
|
1106
|
-
if (!auth.user) {
|
|
1107
|
-
return window.tidioChatApi && window.tidioChatApi.setVisitorData({
|
|
1108
|
-
name: undefined,
|
|
1109
|
-
email: undefined,
|
|
1110
|
-
phone: undefined,
|
|
1111
|
-
site: undefined,
|
|
1112
|
-
company: CoreConfig.env.clientName,
|
|
1113
|
-
distinct_id: undefined
|
|
1114
|
-
});
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
return window.tidioChatApi && window.tidioChatApi.setVisitorData({
|
|
1118
|
-
name: "".concat(auth.user.displayName, " - ").concat(CoreConfig.env.clientName, " ").concat(auth.site),
|
|
1119
|
-
email: auth.user.email,
|
|
1120
|
-
phone: auth.user.phoneNumber,
|
|
1121
|
-
site: auth.site,
|
|
1122
|
-
userType: auth.auth,
|
|
1123
|
-
company: CoreConfig.env.clientName,
|
|
1124
|
-
distinct_id: auth.user.Id
|
|
1125
|
-
});
|
|
1126
|
-
};
|
|
1127
1169
|
var openChat = function openChat() {
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1170
|
+
return;
|
|
1171
|
+
}; // deprecated
|
|
1172
|
+
|
|
1131
1173
|
var hideChat = function hideChat() {
|
|
1132
|
-
|
|
1133
|
-
setTimeout(function () {
|
|
1134
|
-
window.tidioChatApi.display(false);
|
|
1135
|
-
}, 1000);
|
|
1136
|
-
} else {
|
|
1137
|
-
setTimeout(function () {
|
|
1138
|
-
hideChat();
|
|
1139
|
-
}, 1000);
|
|
1140
|
-
}
|
|
1174
|
+
return;
|
|
1141
1175
|
};
|
|
1142
1176
|
|
|
1143
1177
|
// api
|
|
@@ -1679,31 +1713,34 @@ function CanvasImageUploader(options) {
|
|
|
1679
1713
|
var fileActions = {
|
|
1680
1714
|
uploadMediaAsync: function () {
|
|
1681
1715
|
var _uploadMediaAsync = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(file, filename) {
|
|
1682
|
-
var newFilename,
|
|
1683
|
-
|
|
1716
|
+
var newFilename, signedUrlRes, baseUploadsUrl;
|
|
1684
1717
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
1685
1718
|
while (1) {
|
|
1686
1719
|
switch (_context.prev = _context.next) {
|
|
1687
1720
|
case 0:
|
|
1688
1721
|
newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1689
1722
|
_context.next = 3;
|
|
1690
|
-
return
|
|
1723
|
+
return authedFunction({
|
|
1724
|
+
method: 'GET',
|
|
1725
|
+
url: getUrl('media', 'get/presignedurl', {
|
|
1726
|
+
filename: newFilename
|
|
1727
|
+
})
|
|
1728
|
+
});
|
|
1691
1729
|
|
|
1692
1730
|
case 3:
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
bucket: uploadBucket
|
|
1731
|
+
signedUrlRes = _context.sent;
|
|
1732
|
+
_context.next = 6;
|
|
1733
|
+
return axios__default['default'].put(signedUrlRes.data.url, file, {
|
|
1734
|
+
headers: {
|
|
1735
|
+
'Content-Type': file.type
|
|
1736
|
+
}
|
|
1700
1737
|
});
|
|
1701
1738
|
|
|
1702
|
-
case
|
|
1703
|
-
|
|
1704
|
-
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(
|
|
1739
|
+
case 6:
|
|
1740
|
+
baseUploadsUrl = CoreConfig.env.baseUploadsUrl;
|
|
1741
|
+
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(signedUrlRes.data.key));
|
|
1705
1742
|
|
|
1706
|
-
case
|
|
1743
|
+
case 8:
|
|
1707
1744
|
case "end":
|
|
1708
1745
|
return _context.stop();
|
|
1709
1746
|
}
|
|
@@ -1717,6 +1754,15 @@ var fileActions = {
|
|
|
1717
1754
|
|
|
1718
1755
|
return uploadMediaAsync;
|
|
1719
1756
|
}(),
|
|
1757
|
+
// uploadMediaAsync: async (file, filename) => {
|
|
1758
|
+
// const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1759
|
+
// const userId = await getCurrentUserSub();
|
|
1760
|
+
// const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
1761
|
+
// const { baseUploadsUrl, uploadBucket } = Config.env;
|
|
1762
|
+
// await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
|
|
1763
|
+
// console.log('uploaded file', `${baseUploadsUrl}${url}`);
|
|
1764
|
+
// return `${baseUploadsUrl}${url}`;
|
|
1765
|
+
// },
|
|
1720
1766
|
// readBase64: async (file) => {
|
|
1721
1767
|
// return new Promise((resolve, reject) => {
|
|
1722
1768
|
// var reader = new FileReader();
|
|
@@ -1730,6 +1776,14 @@ var fileActions = {
|
|
|
1730
1776
|
// };
|
|
1731
1777
|
// });
|
|
1732
1778
|
// },
|
|
1779
|
+
getPresignedUrl: function getPresignedUrl(filename) {
|
|
1780
|
+
return authedFunction({
|
|
1781
|
+
method: 'GET',
|
|
1782
|
+
url: getUrl('media', 'get/presignedurl', {
|
|
1783
|
+
filename: filename
|
|
1784
|
+
})
|
|
1785
|
+
});
|
|
1786
|
+
},
|
|
1733
1787
|
compressImage: function compressImage(file, maxSize, quality, noCompress) {
|
|
1734
1788
|
return new Promise(function (resolve, reject) {
|
|
1735
1789
|
if (noCompress) {
|
|
@@ -5223,9 +5277,7 @@ var mapStateToProps$5 = function mapStateToProps() {
|
|
|
5223
5277
|
return {};
|
|
5224
5278
|
};
|
|
5225
5279
|
|
|
5226
|
-
var FileInput = reactRedux.connect(mapStateToProps$5, {}, null, {
|
|
5227
|
-
withRef: true
|
|
5228
|
-
})(FileInputComponent);
|
|
5280
|
+
var FileInput = reactRedux.connect(mapStateToProps$5, {}, null, {})(FileInputComponent);
|
|
5229
5281
|
|
|
5230
5282
|
function ownKeys$e(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5231
5283
|
|
|
@@ -6847,11 +6899,12 @@ var ImageInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
6847
6899
|
onDrop: function onDrop(files) {
|
|
6848
6900
|
return _this6.onDrop(files, true);
|
|
6849
6901
|
}
|
|
6850
|
-
}, function (
|
|
6851
|
-
var getRootProps =
|
|
6902
|
+
}, function (state) {
|
|
6903
|
+
var getRootProps = state.getRootProps,
|
|
6904
|
+
getInputProps = state.getInputProps;
|
|
6852
6905
|
return /*#__PURE__*/React__default['default'].createElement("div", _extends__default['default']({
|
|
6853
6906
|
className: "imageInput_buttonContainer-simple"
|
|
6854
|
-
}, getRootProps()), /*#__PURE__*/React__default['default'].createElement(Button, {
|
|
6907
|
+
}, getRootProps()), /*#__PURE__*/React__default['default'].createElement("input", getInputProps()), /*#__PURE__*/React__default['default'].createElement(Button, {
|
|
6855
6908
|
buttonType: "secondary",
|
|
6856
6909
|
className: "imageInput_button imageInput_button-simple",
|
|
6857
6910
|
disabled: true
|
|
@@ -6899,13 +6952,14 @@ var ImageInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
6899
6952
|
disabled: this.props.disabled,
|
|
6900
6953
|
accept: this.getAccept(),
|
|
6901
6954
|
onDrop: this.onDrop
|
|
6902
|
-
}, function (
|
|
6903
|
-
var getRootProps =
|
|
6904
|
-
|
|
6955
|
+
}, function (state) {
|
|
6956
|
+
var getRootProps = state.getRootProps,
|
|
6957
|
+
getInputProps = state.getInputProps,
|
|
6958
|
+
isDragActive = state.isDragActive;
|
|
6905
6959
|
return /*#__PURE__*/React__default['default'].createElement("div", _extends__default['default']({
|
|
6906
6960
|
style: _objectSpread$a({}, _this6.props.style),
|
|
6907
6961
|
className: "imageInput_upload ".concat(_this6.getErrorState())
|
|
6908
|
-
}, getRootProps()), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
6962
|
+
}, getRootProps()), /*#__PURE__*/React__default['default'].createElement("input", getInputProps()), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
6909
6963
|
className: "".concat(isDragActive ? 'imageInput_dropZoneActive' : '', " ").concat(_this6.props.horizontalText ? ' imageInput_horizontalText' : '')
|
|
6910
6964
|
}, !_this6.props.simpleStyle && /*#__PURE__*/React__default['default'].createElement("img", {
|
|
6911
6965
|
src: "https://s3-ap-southeast-2.amazonaws.com/pluss60-dev-media/pluss/document.svg",
|
|
@@ -7149,15 +7203,16 @@ var ImageInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
7149
7203
|
onDrop: function onDrop(files) {
|
|
7150
7204
|
return _this12.onDrop(files, true);
|
|
7151
7205
|
}
|
|
7152
|
-
}, function (
|
|
7153
|
-
var getRootProps =
|
|
7154
|
-
|
|
7206
|
+
}, function (state) {
|
|
7207
|
+
var getRootProps = state.getRootProps,
|
|
7208
|
+
getInputProps = state.getInputProps,
|
|
7209
|
+
isDragActive = state.isDragActive;
|
|
7155
7210
|
return /*#__PURE__*/React__default['default'].createElement("div", _extends__default['default']({
|
|
7156
7211
|
style: {
|
|
7157
7212
|
padding: '15px'
|
|
7158
7213
|
},
|
|
7159
7214
|
className: "imageInput_upload folder ".concat(_this12.getErrorState())
|
|
7160
|
-
}, getRootProps()), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
7215
|
+
}, getRootProps()), /*#__PURE__*/React__default['default'].createElement("input", getInputProps()), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
7161
7216
|
className: isDragActive ? 'imageInput_dropZoneActive' : ''
|
|
7162
7217
|
}, /*#__PURE__*/React__default['default'].createElement("img", {
|
|
7163
7218
|
src: "https://s3-ap-southeast-2.amazonaws.com/pluss60-dev-media/pluss/document.svg",
|
|
@@ -7251,11 +7306,12 @@ var ImageInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
7251
7306
|
onDrop: function onDrop(files) {
|
|
7252
7307
|
return _this15.onDrop(files, true);
|
|
7253
7308
|
}
|
|
7254
|
-
}, function (
|
|
7255
|
-
var getRootProps =
|
|
7309
|
+
}, function (state) {
|
|
7310
|
+
var getRootProps = state.getRootProps,
|
|
7311
|
+
getInputProps = state.getInputProps;
|
|
7256
7312
|
return /*#__PURE__*/React__default['default'].createElement("div", _extends__default['default']({}, getRootProps(), {
|
|
7257
7313
|
className: "imageInputRight_button"
|
|
7258
|
-
}), /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
7314
|
+
}), /*#__PURE__*/React__default['default'].createElement("input", getInputProps()), /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
7259
7315
|
className: "imageInputRight_button_icon",
|
|
7260
7316
|
name: "plus-circle"
|
|
7261
7317
|
}), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
@@ -7327,9 +7383,7 @@ var mapStateToProps$2 = function mapStateToProps(state) {
|
|
|
7327
7383
|
};
|
|
7328
7384
|
};
|
|
7329
7385
|
|
|
7330
|
-
var ImageInput = reactRedux.connect(mapStateToProps$2, {}, null, {
|
|
7331
|
-
withRef: true
|
|
7332
|
-
})(ImageInputComponent);
|
|
7386
|
+
var ImageInput = reactRedux.connect(mapStateToProps$2, {}, null, {})(ImageInputComponent);
|
|
7333
7387
|
|
|
7334
7388
|
function _createSuper$m(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$m(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
|
|
7335
7389
|
|
|
@@ -9932,9 +9986,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9932
9986
|
|
|
9933
9987
|
var toExport = reactRedux.connect(null, {
|
|
9934
9988
|
setAuth: setAuth
|
|
9935
|
-
}, null, {
|
|
9936
|
-
withRef: true
|
|
9937
|
-
})(AudienceSelector);
|
|
9989
|
+
}, null, {})(AudienceSelector);
|
|
9938
9990
|
|
|
9939
9991
|
function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
|
|
9940
9992
|
|
package/dist/index.esm.js
CHANGED
|
@@ -49,7 +49,75 @@ var CoreConfig = {
|
|
|
49
49
|
defaultAllowComments: true,
|
|
50
50
|
makeApiKey: '',
|
|
51
51
|
logo: '',
|
|
52
|
-
clientName: ''
|
|
52
|
+
clientName: '',
|
|
53
|
+
AuthStrategy: {
|
|
54
|
+
getAccessToken: function () {
|
|
55
|
+
var _getAccessToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
56
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
57
|
+
while (1) {
|
|
58
|
+
switch (_context.prev = _context.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
return _context.abrupt("return", null);
|
|
61
|
+
|
|
62
|
+
case 1:
|
|
63
|
+
case "end":
|
|
64
|
+
return _context.stop();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}, _callee);
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
function getAccessToken() {
|
|
71
|
+
return _getAccessToken.apply(this, arguments);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return getAccessToken;
|
|
75
|
+
}(),
|
|
76
|
+
getCurrentUserId: function () {
|
|
77
|
+
var _getCurrentUserId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
78
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
79
|
+
while (1) {
|
|
80
|
+
switch (_context2.prev = _context2.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
return _context2.abrupt("return", null);
|
|
83
|
+
|
|
84
|
+
case 1:
|
|
85
|
+
case "end":
|
|
86
|
+
return _context2.stop();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, _callee2);
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
function getCurrentUserId() {
|
|
93
|
+
return _getCurrentUserId.apply(this, arguments);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return getCurrentUserId;
|
|
97
|
+
}(),
|
|
98
|
+
hasActiveSession: function () {
|
|
99
|
+
var _hasActiveSession = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
100
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
101
|
+
while (1) {
|
|
102
|
+
switch (_context3.prev = _context3.next) {
|
|
103
|
+
case 0:
|
|
104
|
+
return _context3.abrupt("return", false);
|
|
105
|
+
|
|
106
|
+
case 1:
|
|
107
|
+
case "end":
|
|
108
|
+
return _context3.stop();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}, _callee3);
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
function hasActiveSession() {
|
|
115
|
+
return _hasActiveSession.apply(this, arguments);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return hasActiveSession;
|
|
119
|
+
}()
|
|
120
|
+
}
|
|
53
121
|
},
|
|
54
122
|
init: function init(environment) {
|
|
55
123
|
CoreConfig.env = environment;
|
|
@@ -58,29 +126,28 @@ var CoreConfig = {
|
|
|
58
126
|
|
|
59
127
|
var getSessionTokenAWS = /*#__PURE__*/function () {
|
|
60
128
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(prefix) {
|
|
61
|
-
var
|
|
129
|
+
var token;
|
|
62
130
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
63
131
|
while (1) {
|
|
64
132
|
switch (_context.prev = _context.next) {
|
|
65
133
|
case 0:
|
|
66
134
|
_context.next = 2;
|
|
67
|
-
return
|
|
135
|
+
return CoreConfig.env.AuthStrategy.getAccessToken();
|
|
68
136
|
|
|
69
137
|
case 2:
|
|
70
|
-
|
|
71
|
-
token = data.getAccessToken().getJwtToken();
|
|
138
|
+
token = _context.sent;
|
|
72
139
|
|
|
73
140
|
if (!_.isUndefined(prefix)) {
|
|
74
|
-
_context.next =
|
|
141
|
+
_context.next = 5;
|
|
75
142
|
break;
|
|
76
143
|
}
|
|
77
144
|
|
|
78
145
|
return _context.abrupt("return", token);
|
|
79
146
|
|
|
80
|
-
case
|
|
147
|
+
case 5:
|
|
81
148
|
return _context.abrupt("return", "".concat(prefix, " ").concat(token));
|
|
82
149
|
|
|
83
|
-
case
|
|
150
|
+
case 6:
|
|
84
151
|
case "end":
|
|
85
152
|
return _context.stop();
|
|
86
153
|
}
|
|
@@ -1066,48 +1133,15 @@ var getPluralOptions = function getPluralOptions(count, singular, plural) {
|
|
|
1066
1133
|
};
|
|
1067
1134
|
|
|
1068
1135
|
var setChatUser = function setChatUser(auth) {
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
setChatUser(auth);
|
|
1072
|
-
}, 1000);
|
|
1073
|
-
return;
|
|
1074
|
-
}
|
|
1136
|
+
return;
|
|
1137
|
+
}; // deprecated
|
|
1075
1138
|
|
|
1076
|
-
if (!auth.user) {
|
|
1077
|
-
return window.tidioChatApi && window.tidioChatApi.setVisitorData({
|
|
1078
|
-
name: undefined,
|
|
1079
|
-
email: undefined,
|
|
1080
|
-
phone: undefined,
|
|
1081
|
-
site: undefined,
|
|
1082
|
-
company: CoreConfig.env.clientName,
|
|
1083
|
-
distinct_id: undefined
|
|
1084
|
-
});
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
return window.tidioChatApi && window.tidioChatApi.setVisitorData({
|
|
1088
|
-
name: "".concat(auth.user.displayName, " - ").concat(CoreConfig.env.clientName, " ").concat(auth.site),
|
|
1089
|
-
email: auth.user.email,
|
|
1090
|
-
phone: auth.user.phoneNumber,
|
|
1091
|
-
site: auth.site,
|
|
1092
|
-
userType: auth.auth,
|
|
1093
|
-
company: CoreConfig.env.clientName,
|
|
1094
|
-
distinct_id: auth.user.Id
|
|
1095
|
-
});
|
|
1096
|
-
};
|
|
1097
1139
|
var openChat = function openChat() {
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1140
|
+
return;
|
|
1141
|
+
}; // deprecated
|
|
1142
|
+
|
|
1101
1143
|
var hideChat = function hideChat() {
|
|
1102
|
-
|
|
1103
|
-
setTimeout(function () {
|
|
1104
|
-
window.tidioChatApi.display(false);
|
|
1105
|
-
}, 1000);
|
|
1106
|
-
} else {
|
|
1107
|
-
setTimeout(function () {
|
|
1108
|
-
hideChat();
|
|
1109
|
-
}, 1000);
|
|
1110
|
-
}
|
|
1144
|
+
return;
|
|
1111
1145
|
};
|
|
1112
1146
|
|
|
1113
1147
|
// api
|
|
@@ -1649,31 +1683,34 @@ function CanvasImageUploader(options) {
|
|
|
1649
1683
|
var fileActions = {
|
|
1650
1684
|
uploadMediaAsync: function () {
|
|
1651
1685
|
var _uploadMediaAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file, filename) {
|
|
1652
|
-
var newFilename,
|
|
1653
|
-
|
|
1686
|
+
var newFilename, signedUrlRes, baseUploadsUrl;
|
|
1654
1687
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1655
1688
|
while (1) {
|
|
1656
1689
|
switch (_context.prev = _context.next) {
|
|
1657
1690
|
case 0:
|
|
1658
1691
|
newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1659
1692
|
_context.next = 3;
|
|
1660
|
-
return
|
|
1693
|
+
return authedFunction({
|
|
1694
|
+
method: 'GET',
|
|
1695
|
+
url: getUrl('media', 'get/presignedurl', {
|
|
1696
|
+
filename: newFilename
|
|
1697
|
+
})
|
|
1698
|
+
});
|
|
1661
1699
|
|
|
1662
1700
|
case 3:
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
bucket: uploadBucket
|
|
1701
|
+
signedUrlRes = _context.sent;
|
|
1702
|
+
_context.next = 6;
|
|
1703
|
+
return axios.put(signedUrlRes.data.url, file, {
|
|
1704
|
+
headers: {
|
|
1705
|
+
'Content-Type': file.type
|
|
1706
|
+
}
|
|
1670
1707
|
});
|
|
1671
1708
|
|
|
1672
|
-
case
|
|
1673
|
-
|
|
1674
|
-
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(
|
|
1709
|
+
case 6:
|
|
1710
|
+
baseUploadsUrl = CoreConfig.env.baseUploadsUrl;
|
|
1711
|
+
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(signedUrlRes.data.key));
|
|
1675
1712
|
|
|
1676
|
-
case
|
|
1713
|
+
case 8:
|
|
1677
1714
|
case "end":
|
|
1678
1715
|
return _context.stop();
|
|
1679
1716
|
}
|
|
@@ -1687,6 +1724,15 @@ var fileActions = {
|
|
|
1687
1724
|
|
|
1688
1725
|
return uploadMediaAsync;
|
|
1689
1726
|
}(),
|
|
1727
|
+
// uploadMediaAsync: async (file, filename) => {
|
|
1728
|
+
// const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1729
|
+
// const userId = await getCurrentUserSub();
|
|
1730
|
+
// const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
1731
|
+
// const { baseUploadsUrl, uploadBucket } = Config.env;
|
|
1732
|
+
// await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
|
|
1733
|
+
// console.log('uploaded file', `${baseUploadsUrl}${url}`);
|
|
1734
|
+
// return `${baseUploadsUrl}${url}`;
|
|
1735
|
+
// },
|
|
1690
1736
|
// readBase64: async (file) => {
|
|
1691
1737
|
// return new Promise((resolve, reject) => {
|
|
1692
1738
|
// var reader = new FileReader();
|
|
@@ -1700,6 +1746,14 @@ var fileActions = {
|
|
|
1700
1746
|
// };
|
|
1701
1747
|
// });
|
|
1702
1748
|
// },
|
|
1749
|
+
getPresignedUrl: function getPresignedUrl(filename) {
|
|
1750
|
+
return authedFunction({
|
|
1751
|
+
method: 'GET',
|
|
1752
|
+
url: getUrl('media', 'get/presignedurl', {
|
|
1753
|
+
filename: filename
|
|
1754
|
+
})
|
|
1755
|
+
});
|
|
1756
|
+
},
|
|
1703
1757
|
compressImage: function compressImage(file, maxSize, quality, noCompress) {
|
|
1704
1758
|
return new Promise(function (resolve, reject) {
|
|
1705
1759
|
if (noCompress) {
|
|
@@ -5193,9 +5247,7 @@ var mapStateToProps$5 = function mapStateToProps() {
|
|
|
5193
5247
|
return {};
|
|
5194
5248
|
};
|
|
5195
5249
|
|
|
5196
|
-
var FileInput = connect(mapStateToProps$5, {}, null, {
|
|
5197
|
-
withRef: true
|
|
5198
|
-
})(FileInputComponent);
|
|
5250
|
+
var FileInput = connect(mapStateToProps$5, {}, null, {})(FileInputComponent);
|
|
5199
5251
|
|
|
5200
5252
|
function ownKeys$e(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5201
5253
|
|
|
@@ -6817,11 +6869,12 @@ var ImageInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
6817
6869
|
onDrop: function onDrop(files) {
|
|
6818
6870
|
return _this6.onDrop(files, true);
|
|
6819
6871
|
}
|
|
6820
|
-
}, function (
|
|
6821
|
-
var getRootProps =
|
|
6872
|
+
}, function (state) {
|
|
6873
|
+
var getRootProps = state.getRootProps,
|
|
6874
|
+
getInputProps = state.getInputProps;
|
|
6822
6875
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
6823
6876
|
className: "imageInput_buttonContainer-simple"
|
|
6824
|
-
}, getRootProps()), /*#__PURE__*/React.createElement(Button, {
|
|
6877
|
+
}, getRootProps()), /*#__PURE__*/React.createElement("input", getInputProps()), /*#__PURE__*/React.createElement(Button, {
|
|
6825
6878
|
buttonType: "secondary",
|
|
6826
6879
|
className: "imageInput_button imageInput_button-simple",
|
|
6827
6880
|
disabled: true
|
|
@@ -6869,13 +6922,14 @@ var ImageInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
6869
6922
|
disabled: this.props.disabled,
|
|
6870
6923
|
accept: this.getAccept(),
|
|
6871
6924
|
onDrop: this.onDrop
|
|
6872
|
-
}, function (
|
|
6873
|
-
var getRootProps =
|
|
6874
|
-
|
|
6925
|
+
}, function (state) {
|
|
6926
|
+
var getRootProps = state.getRootProps,
|
|
6927
|
+
getInputProps = state.getInputProps,
|
|
6928
|
+
isDragActive = state.isDragActive;
|
|
6875
6929
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
6876
6930
|
style: _objectSpread$a({}, _this6.props.style),
|
|
6877
6931
|
className: "imageInput_upload ".concat(_this6.getErrorState())
|
|
6878
|
-
}, getRootProps()), /*#__PURE__*/React.createElement("div", {
|
|
6932
|
+
}, getRootProps()), /*#__PURE__*/React.createElement("input", getInputProps()), /*#__PURE__*/React.createElement("div", {
|
|
6879
6933
|
className: "".concat(isDragActive ? 'imageInput_dropZoneActive' : '', " ").concat(_this6.props.horizontalText ? ' imageInput_horizontalText' : '')
|
|
6880
6934
|
}, !_this6.props.simpleStyle && /*#__PURE__*/React.createElement("img", {
|
|
6881
6935
|
src: "https://s3-ap-southeast-2.amazonaws.com/pluss60-dev-media/pluss/document.svg",
|
|
@@ -7119,15 +7173,16 @@ var ImageInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
7119
7173
|
onDrop: function onDrop(files) {
|
|
7120
7174
|
return _this12.onDrop(files, true);
|
|
7121
7175
|
}
|
|
7122
|
-
}, function (
|
|
7123
|
-
var getRootProps =
|
|
7124
|
-
|
|
7176
|
+
}, function (state) {
|
|
7177
|
+
var getRootProps = state.getRootProps,
|
|
7178
|
+
getInputProps = state.getInputProps,
|
|
7179
|
+
isDragActive = state.isDragActive;
|
|
7125
7180
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
7126
7181
|
style: {
|
|
7127
7182
|
padding: '15px'
|
|
7128
7183
|
},
|
|
7129
7184
|
className: "imageInput_upload folder ".concat(_this12.getErrorState())
|
|
7130
|
-
}, getRootProps()), /*#__PURE__*/React.createElement("div", {
|
|
7185
|
+
}, getRootProps()), /*#__PURE__*/React.createElement("input", getInputProps()), /*#__PURE__*/React.createElement("div", {
|
|
7131
7186
|
className: isDragActive ? 'imageInput_dropZoneActive' : ''
|
|
7132
7187
|
}, /*#__PURE__*/React.createElement("img", {
|
|
7133
7188
|
src: "https://s3-ap-southeast-2.amazonaws.com/pluss60-dev-media/pluss/document.svg",
|
|
@@ -7221,11 +7276,12 @@ var ImageInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
7221
7276
|
onDrop: function onDrop(files) {
|
|
7222
7277
|
return _this15.onDrop(files, true);
|
|
7223
7278
|
}
|
|
7224
|
-
}, function (
|
|
7225
|
-
var getRootProps =
|
|
7279
|
+
}, function (state) {
|
|
7280
|
+
var getRootProps = state.getRootProps,
|
|
7281
|
+
getInputProps = state.getInputProps;
|
|
7226
7282
|
return /*#__PURE__*/React.createElement("div", _extends({}, getRootProps(), {
|
|
7227
7283
|
className: "imageInputRight_button"
|
|
7228
|
-
}), /*#__PURE__*/React.createElement(FontAwesome, {
|
|
7284
|
+
}), /*#__PURE__*/React.createElement("input", getInputProps()), /*#__PURE__*/React.createElement(FontAwesome, {
|
|
7229
7285
|
className: "imageInputRight_button_icon",
|
|
7230
7286
|
name: "plus-circle"
|
|
7231
7287
|
}), /*#__PURE__*/React.createElement("p", {
|
|
@@ -7297,9 +7353,7 @@ var mapStateToProps$2 = function mapStateToProps(state) {
|
|
|
7297
7353
|
};
|
|
7298
7354
|
};
|
|
7299
7355
|
|
|
7300
|
-
var ImageInput = connect(mapStateToProps$2, {}, null, {
|
|
7301
|
-
withRef: true
|
|
7302
|
-
})(ImageInputComponent);
|
|
7356
|
+
var ImageInput = connect(mapStateToProps$2, {}, null, {})(ImageInputComponent);
|
|
7303
7357
|
|
|
7304
7358
|
function _createSuper$m(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$m(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
7305
7359
|
|
|
@@ -9902,9 +9956,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9902
9956
|
|
|
9903
9957
|
var toExport = connect(null, {
|
|
9904
9958
|
setAuth: setAuth
|
|
9905
|
-
}, null, {
|
|
9906
|
-
withRef: true
|
|
9907
|
-
})(AudienceSelector);
|
|
9959
|
+
}, null, {})(AudienceSelector);
|
|
9908
9960
|
|
|
9909
9961
|
function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9910
9962
|
|
package/dist/index.umd.js
CHANGED
|
@@ -47,7 +47,75 @@
|
|
|
47
47
|
defaultAllowComments: true,
|
|
48
48
|
makeApiKey: '',
|
|
49
49
|
logo: '',
|
|
50
|
-
clientName: ''
|
|
50
|
+
clientName: '',
|
|
51
|
+
AuthStrategy: {
|
|
52
|
+
getAccessToken: function () {
|
|
53
|
+
var _getAccessToken = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
|
54
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
55
|
+
while (1) {
|
|
56
|
+
switch (_context.prev = _context.next) {
|
|
57
|
+
case 0:
|
|
58
|
+
return _context.abrupt("return", null);
|
|
59
|
+
|
|
60
|
+
case 1:
|
|
61
|
+
case "end":
|
|
62
|
+
return _context.stop();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, _callee);
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
function getAccessToken() {
|
|
69
|
+
return _getAccessToken.apply(this, arguments);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return getAccessToken;
|
|
73
|
+
}(),
|
|
74
|
+
getCurrentUserId: function () {
|
|
75
|
+
var _getCurrentUserId = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
76
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
77
|
+
while (1) {
|
|
78
|
+
switch (_context2.prev = _context2.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
return _context2.abrupt("return", null);
|
|
81
|
+
|
|
82
|
+
case 1:
|
|
83
|
+
case "end":
|
|
84
|
+
return _context2.stop();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}, _callee2);
|
|
88
|
+
}));
|
|
89
|
+
|
|
90
|
+
function getCurrentUserId() {
|
|
91
|
+
return _getCurrentUserId.apply(this, arguments);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return getCurrentUserId;
|
|
95
|
+
}(),
|
|
96
|
+
hasActiveSession: function () {
|
|
97
|
+
var _hasActiveSession = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
98
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
99
|
+
while (1) {
|
|
100
|
+
switch (_context3.prev = _context3.next) {
|
|
101
|
+
case 0:
|
|
102
|
+
return _context3.abrupt("return", false);
|
|
103
|
+
|
|
104
|
+
case 1:
|
|
105
|
+
case "end":
|
|
106
|
+
return _context3.stop();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}, _callee3);
|
|
110
|
+
}));
|
|
111
|
+
|
|
112
|
+
function hasActiveSession() {
|
|
113
|
+
return _hasActiveSession.apply(this, arguments);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return hasActiveSession;
|
|
117
|
+
}()
|
|
118
|
+
}
|
|
51
119
|
},
|
|
52
120
|
init: function init(environment) {
|
|
53
121
|
CoreConfig.env = environment;
|
|
@@ -56,29 +124,28 @@
|
|
|
56
124
|
|
|
57
125
|
var getSessionTokenAWS = /*#__PURE__*/function () {
|
|
58
126
|
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(prefix) {
|
|
59
|
-
var
|
|
127
|
+
var token;
|
|
60
128
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
61
129
|
while (1) {
|
|
62
130
|
switch (_context.prev = _context.next) {
|
|
63
131
|
case 0:
|
|
64
132
|
_context.next = 2;
|
|
65
|
-
return
|
|
133
|
+
return CoreConfig.env.AuthStrategy.getAccessToken();
|
|
66
134
|
|
|
67
135
|
case 2:
|
|
68
|
-
|
|
69
|
-
token = data.getAccessToken().getJwtToken();
|
|
136
|
+
token = _context.sent;
|
|
70
137
|
|
|
71
138
|
if (!___default['default'].isUndefined(prefix)) {
|
|
72
|
-
_context.next =
|
|
139
|
+
_context.next = 5;
|
|
73
140
|
break;
|
|
74
141
|
}
|
|
75
142
|
|
|
76
143
|
return _context.abrupt("return", token);
|
|
77
144
|
|
|
78
|
-
case
|
|
145
|
+
case 5:
|
|
79
146
|
return _context.abrupt("return", "".concat(prefix, " ").concat(token));
|
|
80
147
|
|
|
81
|
-
case
|
|
148
|
+
case 6:
|
|
82
149
|
case "end":
|
|
83
150
|
return _context.stop();
|
|
84
151
|
}
|
|
@@ -1064,48 +1131,15 @@
|
|
|
1064
1131
|
};
|
|
1065
1132
|
|
|
1066
1133
|
var setChatUser = function setChatUser(auth) {
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
setChatUser(auth);
|
|
1070
|
-
}, 1000);
|
|
1071
|
-
return;
|
|
1072
|
-
}
|
|
1134
|
+
return;
|
|
1135
|
+
}; // deprecated
|
|
1073
1136
|
|
|
1074
|
-
if (!auth.user) {
|
|
1075
|
-
return window.tidioChatApi && window.tidioChatApi.setVisitorData({
|
|
1076
|
-
name: undefined,
|
|
1077
|
-
email: undefined,
|
|
1078
|
-
phone: undefined,
|
|
1079
|
-
site: undefined,
|
|
1080
|
-
company: CoreConfig.env.clientName,
|
|
1081
|
-
distinct_id: undefined
|
|
1082
|
-
});
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
return window.tidioChatApi && window.tidioChatApi.setVisitorData({
|
|
1086
|
-
name: "".concat(auth.user.displayName, " - ").concat(CoreConfig.env.clientName, " ").concat(auth.site),
|
|
1087
|
-
email: auth.user.email,
|
|
1088
|
-
phone: auth.user.phoneNumber,
|
|
1089
|
-
site: auth.site,
|
|
1090
|
-
userType: auth.auth,
|
|
1091
|
-
company: CoreConfig.env.clientName,
|
|
1092
|
-
distinct_id: auth.user.Id
|
|
1093
|
-
});
|
|
1094
|
-
};
|
|
1095
1137
|
var openChat = function openChat() {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1138
|
+
return;
|
|
1139
|
+
}; // deprecated
|
|
1140
|
+
|
|
1099
1141
|
var hideChat = function hideChat() {
|
|
1100
|
-
|
|
1101
|
-
setTimeout(function () {
|
|
1102
|
-
window.tidioChatApi.display(false);
|
|
1103
|
-
}, 1000);
|
|
1104
|
-
} else {
|
|
1105
|
-
setTimeout(function () {
|
|
1106
|
-
hideChat();
|
|
1107
|
-
}, 1000);
|
|
1108
|
-
}
|
|
1142
|
+
return;
|
|
1109
1143
|
};
|
|
1110
1144
|
|
|
1111
1145
|
// api
|
|
@@ -1647,31 +1681,34 @@
|
|
|
1647
1681
|
var fileActions = {
|
|
1648
1682
|
uploadMediaAsync: function () {
|
|
1649
1683
|
var _uploadMediaAsync = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(file, filename) {
|
|
1650
|
-
var newFilename,
|
|
1651
|
-
|
|
1684
|
+
var newFilename, signedUrlRes, baseUploadsUrl;
|
|
1652
1685
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
1653
1686
|
while (1) {
|
|
1654
1687
|
switch (_context.prev = _context.next) {
|
|
1655
1688
|
case 0:
|
|
1656
1689
|
newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1657
1690
|
_context.next = 3;
|
|
1658
|
-
return
|
|
1691
|
+
return authedFunction({
|
|
1692
|
+
method: 'GET',
|
|
1693
|
+
url: getUrl('media', 'get/presignedurl', {
|
|
1694
|
+
filename: newFilename
|
|
1695
|
+
})
|
|
1696
|
+
});
|
|
1659
1697
|
|
|
1660
1698
|
case 3:
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
bucket: uploadBucket
|
|
1699
|
+
signedUrlRes = _context.sent;
|
|
1700
|
+
_context.next = 6;
|
|
1701
|
+
return axios__default['default'].put(signedUrlRes.data.url, file, {
|
|
1702
|
+
headers: {
|
|
1703
|
+
'Content-Type': file.type
|
|
1704
|
+
}
|
|
1668
1705
|
});
|
|
1669
1706
|
|
|
1670
|
-
case
|
|
1671
|
-
|
|
1672
|
-
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(
|
|
1707
|
+
case 6:
|
|
1708
|
+
baseUploadsUrl = CoreConfig.env.baseUploadsUrl;
|
|
1709
|
+
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(signedUrlRes.data.key));
|
|
1673
1710
|
|
|
1674
|
-
case
|
|
1711
|
+
case 8:
|
|
1675
1712
|
case "end":
|
|
1676
1713
|
return _context.stop();
|
|
1677
1714
|
}
|
|
@@ -1685,6 +1722,15 @@
|
|
|
1685
1722
|
|
|
1686
1723
|
return uploadMediaAsync;
|
|
1687
1724
|
}(),
|
|
1725
|
+
// uploadMediaAsync: async (file, filename) => {
|
|
1726
|
+
// const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1727
|
+
// const userId = await getCurrentUserSub();
|
|
1728
|
+
// const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
1729
|
+
// const { baseUploadsUrl, uploadBucket } = Config.env;
|
|
1730
|
+
// await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
|
|
1731
|
+
// console.log('uploaded file', `${baseUploadsUrl}${url}`);
|
|
1732
|
+
// return `${baseUploadsUrl}${url}`;
|
|
1733
|
+
// },
|
|
1688
1734
|
// readBase64: async (file) => {
|
|
1689
1735
|
// return new Promise((resolve, reject) => {
|
|
1690
1736
|
// var reader = new FileReader();
|
|
@@ -1698,6 +1744,14 @@
|
|
|
1698
1744
|
// };
|
|
1699
1745
|
// });
|
|
1700
1746
|
// },
|
|
1747
|
+
getPresignedUrl: function getPresignedUrl(filename) {
|
|
1748
|
+
return authedFunction({
|
|
1749
|
+
method: 'GET',
|
|
1750
|
+
url: getUrl('media', 'get/presignedurl', {
|
|
1751
|
+
filename: filename
|
|
1752
|
+
})
|
|
1753
|
+
});
|
|
1754
|
+
},
|
|
1701
1755
|
compressImage: function compressImage(file, maxSize, quality, noCompress) {
|
|
1702
1756
|
return new Promise(function (resolve, reject) {
|
|
1703
1757
|
if (noCompress) {
|
|
@@ -5191,9 +5245,7 @@
|
|
|
5191
5245
|
return {};
|
|
5192
5246
|
};
|
|
5193
5247
|
|
|
5194
|
-
var FileInput = reactRedux.connect(mapStateToProps$5, {}, null, {
|
|
5195
|
-
withRef: true
|
|
5196
|
-
})(FileInputComponent);
|
|
5248
|
+
var FileInput = reactRedux.connect(mapStateToProps$5, {}, null, {})(FileInputComponent);
|
|
5197
5249
|
|
|
5198
5250
|
function ownKeys$e(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5199
5251
|
|
|
@@ -6815,11 +6867,12 @@
|
|
|
6815
6867
|
onDrop: function onDrop(files) {
|
|
6816
6868
|
return _this6.onDrop(files, true);
|
|
6817
6869
|
}
|
|
6818
|
-
}, function (
|
|
6819
|
-
var getRootProps =
|
|
6870
|
+
}, function (state) {
|
|
6871
|
+
var getRootProps = state.getRootProps,
|
|
6872
|
+
getInputProps = state.getInputProps;
|
|
6820
6873
|
return /*#__PURE__*/React__default['default'].createElement("div", _extends__default['default']({
|
|
6821
6874
|
className: "imageInput_buttonContainer-simple"
|
|
6822
|
-
}, getRootProps()), /*#__PURE__*/React__default['default'].createElement(Button, {
|
|
6875
|
+
}, getRootProps()), /*#__PURE__*/React__default['default'].createElement("input", getInputProps()), /*#__PURE__*/React__default['default'].createElement(Button, {
|
|
6823
6876
|
buttonType: "secondary",
|
|
6824
6877
|
className: "imageInput_button imageInput_button-simple",
|
|
6825
6878
|
disabled: true
|
|
@@ -6867,13 +6920,14 @@
|
|
|
6867
6920
|
disabled: this.props.disabled,
|
|
6868
6921
|
accept: this.getAccept(),
|
|
6869
6922
|
onDrop: this.onDrop
|
|
6870
|
-
}, function (
|
|
6871
|
-
var getRootProps =
|
|
6872
|
-
|
|
6923
|
+
}, function (state) {
|
|
6924
|
+
var getRootProps = state.getRootProps,
|
|
6925
|
+
getInputProps = state.getInputProps,
|
|
6926
|
+
isDragActive = state.isDragActive;
|
|
6873
6927
|
return /*#__PURE__*/React__default['default'].createElement("div", _extends__default['default']({
|
|
6874
6928
|
style: _objectSpread$a({}, _this6.props.style),
|
|
6875
6929
|
className: "imageInput_upload ".concat(_this6.getErrorState())
|
|
6876
|
-
}, getRootProps()), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
6930
|
+
}, getRootProps()), /*#__PURE__*/React__default['default'].createElement("input", getInputProps()), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
6877
6931
|
className: "".concat(isDragActive ? 'imageInput_dropZoneActive' : '', " ").concat(_this6.props.horizontalText ? ' imageInput_horizontalText' : '')
|
|
6878
6932
|
}, !_this6.props.simpleStyle && /*#__PURE__*/React__default['default'].createElement("img", {
|
|
6879
6933
|
src: "https://s3-ap-southeast-2.amazonaws.com/pluss60-dev-media/pluss/document.svg",
|
|
@@ -7117,15 +7171,16 @@
|
|
|
7117
7171
|
onDrop: function onDrop(files) {
|
|
7118
7172
|
return _this12.onDrop(files, true);
|
|
7119
7173
|
}
|
|
7120
|
-
}, function (
|
|
7121
|
-
var getRootProps =
|
|
7122
|
-
|
|
7174
|
+
}, function (state) {
|
|
7175
|
+
var getRootProps = state.getRootProps,
|
|
7176
|
+
getInputProps = state.getInputProps,
|
|
7177
|
+
isDragActive = state.isDragActive;
|
|
7123
7178
|
return /*#__PURE__*/React__default['default'].createElement("div", _extends__default['default']({
|
|
7124
7179
|
style: {
|
|
7125
7180
|
padding: '15px'
|
|
7126
7181
|
},
|
|
7127
7182
|
className: "imageInput_upload folder ".concat(_this12.getErrorState())
|
|
7128
|
-
}, getRootProps()), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
7183
|
+
}, getRootProps()), /*#__PURE__*/React__default['default'].createElement("input", getInputProps()), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
7129
7184
|
className: isDragActive ? 'imageInput_dropZoneActive' : ''
|
|
7130
7185
|
}, /*#__PURE__*/React__default['default'].createElement("img", {
|
|
7131
7186
|
src: "https://s3-ap-southeast-2.amazonaws.com/pluss60-dev-media/pluss/document.svg",
|
|
@@ -7219,11 +7274,12 @@
|
|
|
7219
7274
|
onDrop: function onDrop(files) {
|
|
7220
7275
|
return _this15.onDrop(files, true);
|
|
7221
7276
|
}
|
|
7222
|
-
}, function (
|
|
7223
|
-
var getRootProps =
|
|
7277
|
+
}, function (state) {
|
|
7278
|
+
var getRootProps = state.getRootProps,
|
|
7279
|
+
getInputProps = state.getInputProps;
|
|
7224
7280
|
return /*#__PURE__*/React__default['default'].createElement("div", _extends__default['default']({}, getRootProps(), {
|
|
7225
7281
|
className: "imageInputRight_button"
|
|
7226
|
-
}), /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
7282
|
+
}), /*#__PURE__*/React__default['default'].createElement("input", getInputProps()), /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
7227
7283
|
className: "imageInputRight_button_icon",
|
|
7228
7284
|
name: "plus-circle"
|
|
7229
7285
|
}), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
@@ -7295,9 +7351,7 @@
|
|
|
7295
7351
|
};
|
|
7296
7352
|
};
|
|
7297
7353
|
|
|
7298
|
-
var ImageInput = reactRedux.connect(mapStateToProps$2, {}, null, {
|
|
7299
|
-
withRef: true
|
|
7300
|
-
})(ImageInputComponent);
|
|
7354
|
+
var ImageInput = reactRedux.connect(mapStateToProps$2, {}, null, {})(ImageInputComponent);
|
|
7301
7355
|
|
|
7302
7356
|
function _createSuper$m(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$m(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
|
|
7303
7357
|
|
|
@@ -9900,9 +9954,7 @@
|
|
|
9900
9954
|
|
|
9901
9955
|
var toExport = reactRedux.connect(null, {
|
|
9902
9956
|
setAuth: setAuth
|
|
9903
|
-
}, null, {
|
|
9904
|
-
withRef: true
|
|
9905
|
-
})(AudienceSelector);
|
|
9957
|
+
}, null, {})(AudienceSelector);
|
|
9906
9958
|
|
|
9907
9959
|
function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
|
|
9908
9960
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plusscommunities/pluss-core-web",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.31-auth0.0",
|
|
4
4
|
"description": "Core extension package for Pluss Communities platform",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"lodash": "^4.17.4",
|
|
38
38
|
"moment": "^2.18.1",
|
|
39
39
|
"react": "^16.14.0",
|
|
40
|
-
"react-dropzone": "^14.2.
|
|
40
|
+
"react-dropzone": "^14.2.3",
|
|
41
41
|
"react-fontawesome": "^1.6.1",
|
|
42
42
|
"react-redux": "^5.0.6",
|
|
43
43
|
"react-router-dom": "^4.2.2",
|
package/src/apis/fileActions.js
CHANGED
|
@@ -4,18 +4,33 @@ import { Storage } from 'aws-amplify';
|
|
|
4
4
|
import CanvasImageUploader from '../helper/files/canvasImageUploader';
|
|
5
5
|
import $ from 'jquery';
|
|
6
6
|
import { generateImageName, randomString, getUrl } from '../helper';
|
|
7
|
+
import Axios from 'axios';
|
|
7
8
|
|
|
8
9
|
export const fileActions = {
|
|
9
10
|
uploadMediaAsync: async (file, filename) => {
|
|
10
11
|
const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
await
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
const signedUrlRes = await authedFunction({
|
|
13
|
+
method: 'GET',
|
|
14
|
+
url: getUrl('media', 'get/presignedurl', { filename: newFilename }),
|
|
15
|
+
});
|
|
16
|
+
await Axios.put(signedUrlRes.data.url, file, {
|
|
17
|
+
headers: {
|
|
18
|
+
'Content-Type': file.type,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const { baseUploadsUrl } = Config.env;
|
|
22
|
+
return `${baseUploadsUrl}${signedUrlRes.data.key}`;
|
|
18
23
|
},
|
|
24
|
+
// uploadMediaAsync: async (file, filename) => {
|
|
25
|
+
// const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
26
|
+
// const userId = await getCurrentUserSub();
|
|
27
|
+
// const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
28
|
+
|
|
29
|
+
// const { baseUploadsUrl, uploadBucket } = Config.env;
|
|
30
|
+
// await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
|
|
31
|
+
// console.log('uploaded file', `${baseUploadsUrl}${url}`);
|
|
32
|
+
// return `${baseUploadsUrl}${url}`;
|
|
33
|
+
// },
|
|
19
34
|
|
|
20
35
|
// readBase64: async (file) => {
|
|
21
36
|
// return new Promise((resolve, reject) => {
|
|
@@ -30,6 +45,12 @@ export const fileActions = {
|
|
|
30
45
|
// };
|
|
31
46
|
// });
|
|
32
47
|
// },
|
|
48
|
+
getPresignedUrl: (filename) => {
|
|
49
|
+
return authedFunction({
|
|
50
|
+
method: 'GET',
|
|
51
|
+
url: getUrl('media', 'get/presignedurl', { filename }),
|
|
52
|
+
});
|
|
53
|
+
},
|
|
33
54
|
compressImage: (file, maxSize, quality, noCompress) => {
|
|
34
55
|
return new Promise((resolve, reject) => {
|
|
35
56
|
if (noCompress) {
|
|
@@ -647,6 +647,6 @@ class AudienceSelector extends Component {
|
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
649
|
|
|
650
|
-
const toExport = connect(null, { setAuth }, null, {
|
|
650
|
+
const toExport = connect(null, { setAuth }, null, {})(AudienceSelector);
|
|
651
651
|
|
|
652
652
|
export { toExport as AudienceSelector };
|
|
@@ -329,5 +329,5 @@ const mapStateToProps = () => {
|
|
|
329
329
|
return {};
|
|
330
330
|
};
|
|
331
331
|
|
|
332
|
-
const FileInput = connect(mapStateToProps, {}, null, {
|
|
332
|
+
const FileInput = connect(mapStateToProps, {}, null, {})(FileInputComponent);
|
|
333
333
|
export { FileInput };
|
|
@@ -535,13 +535,18 @@ class ImageInputComponent extends Component {
|
|
|
535
535
|
}}
|
|
536
536
|
>
|
|
537
537
|
<Dropzone disabled={this.props.disabled} accept={this.getAccept()} onDrop={(files) => this.onDrop(files, true)}>
|
|
538
|
-
{(
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
538
|
+
{(state) => {
|
|
539
|
+
const { getRootProps, getInputProps } = state;
|
|
540
|
+
|
|
541
|
+
return (
|
|
542
|
+
<div className="imageInput_buttonContainer-simple" {...getRootProps()}>
|
|
543
|
+
<input {...getInputProps()} />
|
|
544
|
+
<Button buttonType="secondary" className="imageInput_button imageInput_button-simple" disabled>
|
|
545
|
+
Change image
|
|
546
|
+
</Button>
|
|
547
|
+
</div>
|
|
548
|
+
);
|
|
549
|
+
}}
|
|
545
550
|
</Dropzone>
|
|
546
551
|
</div>
|
|
547
552
|
</div>
|
|
@@ -582,9 +587,11 @@ class ImageInputComponent extends Component {
|
|
|
582
587
|
return (
|
|
583
588
|
<div key={index} className={this.getClassNames(input, inputsLength)} style={{ ...this.props.style }}>
|
|
584
589
|
<Dropzone disabled={this.props.disabled} accept={this.getAccept()} onDrop={this.onDrop}>
|
|
585
|
-
{(
|
|
590
|
+
{(state) => {
|
|
591
|
+
const { getRootProps, getInputProps, isDragActive } = state;
|
|
586
592
|
return (
|
|
587
593
|
<div style={{ ...this.props.style }} className={`imageInput_upload ${this.getErrorState()}`} {...getRootProps()}>
|
|
594
|
+
<input {...getInputProps()} />
|
|
588
595
|
<div
|
|
589
596
|
className={`${isDragActive ? 'imageInput_dropZoneActive' : ''} ${
|
|
590
597
|
this.props.horizontalText ? ' imageInput_horizontalText' : ''
|
|
@@ -805,9 +812,11 @@ class ImageInputComponent extends Component {
|
|
|
805
812
|
<div>
|
|
806
813
|
{this.canAddImageToLibrary() && (
|
|
807
814
|
<Dropzone disabled={this.props.disabled} accept={this.getAccept()} onDrop={(files) => this.onDrop(files, true)}>
|
|
808
|
-
{(
|
|
815
|
+
{(state) => {
|
|
816
|
+
const { getRootProps, getInputProps, isDragActive } = state;
|
|
809
817
|
return (
|
|
810
818
|
<div style={{ padding: '15px' }} className={`imageInput_upload folder ${this.getErrorState()}`} {...getRootProps()}>
|
|
819
|
+
<input {...getInputProps()} />
|
|
811
820
|
<div className={isDragActive ? 'imageInput_dropZoneActive' : ''}>
|
|
812
821
|
<img
|
|
813
822
|
src="https://s3-ap-southeast-2.amazonaws.com/pluss60-dev-media/pluss/document.svg"
|
|
@@ -899,23 +908,17 @@ class ImageInputComponent extends Component {
|
|
|
899
908
|
return (
|
|
900
909
|
<div className="imageInputRight">
|
|
901
910
|
<Dropzone disabled={this.props.disabled} accept={this.getAccept()} onDrop={(files) => this.onDrop(files, true)}>
|
|
902
|
-
{(
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
<
|
|
906
|
-
</div>
|
|
907
|
-
)}
|
|
908
|
-
</Dropzone>
|
|
909
|
-
{/* <Dropzone onDrop={(files) => this.onDrop(files, true)}>{({ getRootProps, getInputProps }) => (
|
|
910
|
-
<div {...getRootProps({ disabled: this.props.disabled, accept: this.getAccept(), className: 'imageInputRight_button' })}>
|
|
911
|
-
<div className="imageInputRight_button">
|
|
911
|
+
{(state) => {
|
|
912
|
+
const { getRootProps, getInputProps } = state;
|
|
913
|
+
return (
|
|
914
|
+
<div {...getRootProps()} className="imageInputRight_button">
|
|
912
915
|
<input {...getInputProps()} />
|
|
913
916
|
<FontAwesome className="imageInputRight_button_icon" name="plus-circle" />
|
|
914
917
|
<p className="imageInputRight_button_text">Upload File</p>
|
|
915
918
|
</div>
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
</Dropzone>
|
|
919
|
+
);
|
|
920
|
+
}}
|
|
921
|
+
</Dropzone>
|
|
919
922
|
<div
|
|
920
923
|
className="imageInputRight_button"
|
|
921
924
|
onClick={() => {
|
|
@@ -981,5 +984,5 @@ const mapStateToProps = (state) => {
|
|
|
981
984
|
};
|
|
982
985
|
};
|
|
983
986
|
|
|
984
|
-
const ImageInput = connect(mapStateToProps, {}, null, {
|
|
987
|
+
const ImageInput = connect(mapStateToProps, {}, null, {})(ImageInputComponent);
|
|
985
988
|
export { ImageInput };
|
package/src/config.js
CHANGED
|
@@ -16,6 +16,11 @@ const CoreConfig = {
|
|
|
16
16
|
makeApiKey: '',
|
|
17
17
|
logo: '',
|
|
18
18
|
clientName: '',
|
|
19
|
+
AuthStrategy: {
|
|
20
|
+
getAccessToken: async () => null,
|
|
21
|
+
getCurrentUserId: async () => null,
|
|
22
|
+
hasActiveSession: async () => false,
|
|
23
|
+
},
|
|
19
24
|
},
|
|
20
25
|
init: (environment) => {
|
|
21
26
|
CoreConfig.env = environment;
|
|
@@ -1,52 +1,16 @@
|
|
|
1
1
|
import Config from '../config';
|
|
2
2
|
|
|
3
|
+
// deprecated
|
|
3
4
|
export const setChatUser = (auth) => {
|
|
4
|
-
|
|
5
|
-
setTimeout(() => {
|
|
6
|
-
setChatUser(auth);
|
|
7
|
-
}, 1000);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
if (!auth.user) {
|
|
11
|
-
return (
|
|
12
|
-
window.tidioChatApi &&
|
|
13
|
-
window.tidioChatApi.setVisitorData({
|
|
14
|
-
name: undefined,
|
|
15
|
-
email: undefined,
|
|
16
|
-
phone: undefined,
|
|
17
|
-
site: undefined,
|
|
18
|
-
company: Config.env.clientName,
|
|
19
|
-
distinct_id: undefined,
|
|
20
|
-
})
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
return (
|
|
24
|
-
window.tidioChatApi &&
|
|
25
|
-
window.tidioChatApi.setVisitorData({
|
|
26
|
-
name: `${auth.user.displayName} - ${Config.env.clientName} ${auth.site}`,
|
|
27
|
-
email: auth.user.email,
|
|
28
|
-
phone: auth.user.phoneNumber,
|
|
29
|
-
site: auth.site,
|
|
30
|
-
userType: auth.auth,
|
|
31
|
-
company: Config.env.clientName,
|
|
32
|
-
distinct_id: auth.user.Id,
|
|
33
|
-
})
|
|
34
|
-
);
|
|
5
|
+
return;
|
|
35
6
|
};
|
|
36
7
|
|
|
8
|
+
// deprecated
|
|
37
9
|
export const openChat = () => {
|
|
38
|
-
|
|
39
|
-
window.tidioChatApi.open();
|
|
10
|
+
return;
|
|
40
11
|
};
|
|
41
12
|
|
|
13
|
+
// deprecated
|
|
42
14
|
export const hideChat = () => {
|
|
43
|
-
|
|
44
|
-
setTimeout(() => {
|
|
45
|
-
window.tidioChatApi.display(false);
|
|
46
|
-
}, 1000);
|
|
47
|
-
} else {
|
|
48
|
-
setTimeout(() => {
|
|
49
|
-
hideChat();
|
|
50
|
-
}, 1000);
|
|
51
|
-
}
|
|
15
|
+
return;
|
|
52
16
|
};
|
package/src/session.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { Auth } from 'aws-amplify';
|
|
4
|
+
import Config from './config';
|
|
4
5
|
|
|
5
6
|
export const getSessionTokenAWS = async (prefix) => {
|
|
6
|
-
const
|
|
7
|
-
const token = data.getAccessToken().getJwtToken();
|
|
7
|
+
const token = await Config.env.AuthStrategy.getAccessToken();
|
|
8
8
|
if (_.isUndefined(prefix)) return token;
|
|
9
9
|
return `${prefix} ${token}`;
|
|
10
10
|
};
|
|
11
|
-
|
|
12
11
|
// export const getRefreshTokenAWS = async () => {
|
|
13
12
|
// const data = await Auth.currentSession();
|
|
14
13
|
// return data.getRefreshToken().token;
|