@product7/feedback-sdk 1.3.6 → 1.3.7
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/package.json
CHANGED
|
@@ -204,29 +204,13 @@ async _handleIdentifyContact(contactData) {
|
|
|
204
204
|
if (response.status) {
|
|
205
205
|
console.log('[MessengerWidget] Contact identified:', response.data.contact_id);
|
|
206
206
|
|
|
207
|
+
// Update state
|
|
207
208
|
if (!this.messengerState.userContext) {
|
|
208
209
|
this.messengerState.userContext = {};
|
|
209
210
|
}
|
|
210
211
|
this.messengerState.userContext.name = contactData.name;
|
|
211
212
|
this.messengerState.userContext.email = contactData.email;
|
|
212
213
|
this.messengerState.isIdentified = true;
|
|
213
|
-
|
|
214
|
-
const pendingMessage = this.messengerState.pendingMessage;
|
|
215
|
-
if (pendingMessage) {
|
|
216
|
-
this.messengerState.pendingMessage = null;
|
|
217
|
-
|
|
218
|
-
// SET VIEW FIRST
|
|
219
|
-
this.messengerState.setView('chat');
|
|
220
|
-
|
|
221
|
-
// THEN start conversation
|
|
222
|
-
await this.startNewConversation(
|
|
223
|
-
pendingMessage.content,
|
|
224
|
-
'',
|
|
225
|
-
pendingMessage.attachments
|
|
226
|
-
);
|
|
227
|
-
} else {
|
|
228
|
-
this.messengerState.setView('chat');
|
|
229
|
-
}
|
|
230
214
|
}
|
|
231
215
|
|
|
232
216
|
return response;
|
|
@@ -235,6 +219,7 @@ async _handleIdentifyContact(contactData) {
|
|
|
235
219
|
throw error;
|
|
236
220
|
}
|
|
237
221
|
}
|
|
222
|
+
|
|
238
223
|
async _handleUploadFile(base64Data, filename) {
|
|
239
224
|
try {
|
|
240
225
|
const response = await this.apiService.uploadFile(base64Data, filename);
|
|
@@ -164,45 +164,62 @@ export class PreChatFormView {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
167
|
+
async _handleSubmit() {
|
|
168
|
+
const nameInput = this.element.querySelector('#messenger-prechat-name');
|
|
169
|
+
const emailInput = this.element.querySelector('#messenger-prechat-email');
|
|
170
|
+
const submitBtn = this.element.querySelector('.messenger-prechat-submit');
|
|
171
|
+
const submitText = submitBtn.querySelector('.messenger-prechat-submit-text');
|
|
172
|
+
const submitLoading = submitBtn.querySelector('.messenger-prechat-submit-loading');
|
|
173
|
+
|
|
174
|
+
const name = nameInput.value.trim();
|
|
175
|
+
const email = emailInput.value.trim();
|
|
176
|
+
|
|
177
|
+
this._isSubmitting = true;
|
|
178
|
+
submitBtn.disabled = true;
|
|
179
|
+
submitText.style.display = 'none';
|
|
180
|
+
submitLoading.style.display = 'inline-flex';
|
|
181
|
+
|
|
182
|
+
try {
|
|
183
|
+
// Call identification API
|
|
184
|
+
if (this.options.onIdentifyContact) {
|
|
185
|
+
await this.options.onIdentifyContact({ name, email });
|
|
186
|
+
}
|
|
186
187
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
188
|
+
// Update state
|
|
189
|
+
if (!this.state.userContext) {
|
|
190
|
+
this.state.userContext = {};
|
|
191
|
+
}
|
|
192
|
+
this.state.userContext.name = name;
|
|
193
|
+
this.state.userContext.email = email;
|
|
194
|
+
this.state.isIdentified = true;
|
|
192
195
|
|
|
193
|
-
|
|
196
|
+
this._isSubmitting = false;
|
|
194
197
|
|
|
198
|
+
// Process pending message if exists
|
|
199
|
+
const pendingMessage = this.state.pendingMessage;
|
|
200
|
+
if (pendingMessage && this.options.onStartConversation) {
|
|
201
|
+
this.state.pendingMessage = null;
|
|
202
|
+
this.state.setView('chat');
|
|
203
|
+
|
|
204
|
+
// Start conversation with pending message
|
|
205
|
+
await this.options.onStartConversation(
|
|
206
|
+
pendingMessage.content,
|
|
207
|
+
pendingMessage.attachments
|
|
208
|
+
);
|
|
209
|
+
} else {
|
|
210
|
+
// No pending message, just go to chat
|
|
195
211
|
this.state.setView('chat');
|
|
196
|
-
} catch (error) {
|
|
197
|
-
console.error('[PreChatFormView] Error submitting form:', error);
|
|
198
|
-
this._showError('messenger-email-error', 'Something went wrong. Please try again.');
|
|
199
|
-
|
|
200
|
-
this._isSubmitting = false;
|
|
201
|
-
submitBtn.disabled = false;
|
|
202
|
-
submitText.style.display = 'inline';
|
|
203
|
-
submitLoading.style.display = 'none';
|
|
204
212
|
}
|
|
213
|
+
} catch (error) {
|
|
214
|
+
console.error('[PreChatFormView] Error submitting form:', error);
|
|
215
|
+
this._showError('messenger-email-error', 'Something went wrong. Please try again.');
|
|
216
|
+
|
|
217
|
+
this._isSubmitting = false;
|
|
218
|
+
submitBtn.disabled = false;
|
|
219
|
+
submitText.style.display = 'inline';
|
|
220
|
+
submitLoading.style.display = 'none';
|
|
205
221
|
}
|
|
222
|
+
}
|
|
206
223
|
|
|
207
224
|
destroy() {
|
|
208
225
|
if (this.element && this.element.parentNode) {
|