@product7/feedback-sdk 1.3.5 → 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) {
@@ -5889,20 +5906,7 @@
5889
5906
  }
5890
5907
  this.messengerState.userContext.name = contactData.name;
5891
5908
  this.messengerState.userContext.email = contactData.email;
5892
- this.messengerState.isIdentified = true; // ADD THIS LINE
5893
-
5894
- // Process pending message
5895
- const pendingMessage = this.messengerState.pendingMessage;
5896
- if (pendingMessage) {
5897
- this.messengerState.pendingMessage = null;
5898
- await this.startNewConversation(
5899
- pendingMessage.content,
5900
- '',
5901
- pendingMessage.attachments
5902
- );
5903
- } else {
5904
- this.messengerState.setView('chat');
5905
- }
5909
+ this.messengerState.isIdentified = true;
5906
5910
  }
5907
5911
 
5908
5912
  return response;