@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.
@@ -5367,45 +5367,62 @@
5367
5367
  }
5368
5368
  }
5369
5369
 
5370
- async _handleSubmit() {
5371
- const nameInput = this.element.querySelector('#messenger-prechat-name');
5372
- const emailInput = this.element.querySelector('#messenger-prechat-email');
5373
- const submitBtn = this.element.querySelector('.messenger-prechat-submit');
5374
- const submitText = submitBtn.querySelector('.messenger-prechat-submit-text');
5375
- const submitLoading = submitBtn.querySelector('.messenger-prechat-submit-loading');
5370
+ async _handleSubmit() {
5371
+ const nameInput = this.element.querySelector('#messenger-prechat-name');
5372
+ const emailInput = this.element.querySelector('#messenger-prechat-email');
5373
+ const submitBtn = this.element.querySelector('.messenger-prechat-submit');
5374
+ const submitText = submitBtn.querySelector('.messenger-prechat-submit-text');
5375
+ const submitLoading = submitBtn.querySelector('.messenger-prechat-submit-loading');
5376
5376
 
5377
- const name = nameInput.value.trim();
5378
- const email = emailInput.value.trim();
5377
+ const name = nameInput.value.trim();
5378
+ const email = emailInput.value.trim();
5379
5379
 
5380
- this._isSubmitting = true;
5381
- submitBtn.disabled = true;
5382
- submitText.style.display = 'none';
5383
- submitLoading.style.display = 'inline-flex';
5380
+ this._isSubmitting = true;
5381
+ submitBtn.disabled = true;
5382
+ submitText.style.display = 'none';
5383
+ submitLoading.style.display = 'inline-flex';
5384
5384
 
5385
- try {
5386
- if (this.options.onIdentifyContact) {
5387
- await this.options.onIdentifyContact({ name, email });
5388
- }
5385
+ try {
5386
+ // Call identification API
5387
+ if (this.options.onIdentifyContact) {
5388
+ await this.options.onIdentifyContact({ name, email });
5389
+ }
5389
5390
 
5390
- if (!this.state.userContext) {
5391
- this.state.userContext = {};
5392
- }
5393
- this.state.userContext.name = name;
5394
- this.state.userContext.email = email;
5391
+ // Update state
5392
+ if (!this.state.userContext) {
5393
+ this.state.userContext = {};
5394
+ }
5395
+ this.state.userContext.name = name;
5396
+ this.state.userContext.email = email;
5397
+ this.state.isIdentified = true;
5395
5398
 
5396
- this._isSubmitting = false;
5399
+ this._isSubmitting = false;
5397
5400
 
5401
+ // Process pending message if exists
5402
+ const pendingMessage = this.state.pendingMessage;
5403
+ if (pendingMessage && this.options.onStartConversation) {
5404
+ this.state.pendingMessage = null;
5405
+ this.state.setView('chat');
5406
+
5407
+ // Start conversation with pending message
5408
+ await this.options.onStartConversation(
5409
+ pendingMessage.content,
5410
+ pendingMessage.attachments
5411
+ );
5412
+ } else {
5413
+ // No pending message, just go to chat
5398
5414
  this.state.setView('chat');
5399
- } catch (error) {
5400
- console.error('[PreChatFormView] Error submitting form:', error);
5401
- this._showError('messenger-email-error', 'Something went wrong. Please try again.');
5402
-
5403
- this._isSubmitting = false;
5404
- submitBtn.disabled = false;
5405
- submitText.style.display = 'inline';
5406
- submitLoading.style.display = 'none';
5407
5415
  }
5416
+ } catch (error) {
5417
+ console.error('[PreChatFormView] Error submitting form:', error);
5418
+ this._showError('messenger-email-error', 'Something went wrong. Please try again.');
5419
+
5420
+ this._isSubmitting = false;
5421
+ submitBtn.disabled = false;
5422
+ submitText.style.display = 'inline';
5423
+ submitLoading.style.display = 'none';
5408
5424
  }
5425
+ }
5409
5426
 
5410
5427
  destroy() {
5411
5428
  if (this.element && this.element.parentNode) {
@@ -5883,29 +5900,13 @@
5883
5900
  if (response.status) {
5884
5901
  console.log('[MessengerWidget] Contact identified:', response.data.contact_id);
5885
5902
 
5903
+ // Update state
5886
5904
  if (!this.messengerState.userContext) {
5887
5905
  this.messengerState.userContext = {};
5888
5906
  }
5889
5907
  this.messengerState.userContext.name = contactData.name;
5890
5908
  this.messengerState.userContext.email = contactData.email;
5891
5909
  this.messengerState.isIdentified = true;
5892
-
5893
- const pendingMessage = this.messengerState.pendingMessage;
5894
- if (pendingMessage) {
5895
- this.messengerState.pendingMessage = null;
5896
-
5897
- // SET VIEW FIRST
5898
- this.messengerState.setView('chat');
5899
-
5900
- // THEN start conversation
5901
- await this.startNewConversation(
5902
- pendingMessage.content,
5903
- '',
5904
- pendingMessage.attachments
5905
- );
5906
- } else {
5907
- this.messengerState.setView('chat');
5908
- }
5909
5910
  }
5910
5911
 
5911
5912
  return response;
@@ -5914,6 +5915,7 @@
5914
5915
  throw error;
5915
5916
  }
5916
5917
  }
5918
+
5917
5919
  async _handleUploadFile(base64Data, filename) {
5918
5920
  try {
5919
5921
  const response = await this.apiService.uploadFile(base64Data, filename);