@product7/product7-js 0.6.2 → 0.6.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@product7/product7-js",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "JavaScript SDK for integrating Product7 feedback widgets into any website",
5
5
  "main": "dist/product7-js.js",
6
6
  "module": "src/index.js",
@@ -1059,7 +1059,7 @@ export class LiveChatWidget extends BaseWidget {
1059
1059
  this.LiveChatState.onlineCount = response.data.online_count || 0;
1060
1060
  this.LiveChatState.responseTime = response.data.response_time || '';
1061
1061
 
1062
- if (response.data.available_agents) {
1062
+ if (response.data.available_agents && this.LiveChatState.showAvatars !== false) {
1063
1063
  this.LiveChatState.setTeamAvatarsFromAgents(
1064
1064
  response.data.available_agents
1065
1065
  );
@@ -27,8 +27,10 @@
27
27
  }
28
28
 
29
29
  _updateContent() {
30
- const avatarsHtml = this.state.showAvatars ? this._renderAvatarStack() : '';
30
+ const isUnavailable = this.state.businessHoursState === 'offline' || this.state.businessHoursState === 'away';
31
+ const avatarsHtml = (this.state.showAvatars && !isUnavailable) ? this._renderAvatarStack() : '';
31
32
  const recentChangelogHtml = this._renderRecentChangelog();
33
+ const availabilityHtml = this._renderAvailabilityStatus();
32
34
 
33
35
  this.element.innerHTML = `
34
36
  <div class="liveChat-home-scroll">
@@ -42,6 +44,7 @@
42
44
  <div class="liveChat-home-welcome">
43
45
  <span class="liveChat-home-greeting">${this.state.greetingMessage}</span>
44
46
  <span class="liveChat-home-question">${this.state.welcomeMessage}</span>
47
+ ${availabilityHtml}
45
48
  </div>
46
49
  </div>
47
50
 
@@ -81,18 +84,16 @@
81
84
  const businessState = this.state.businessHoursState;
82
85
 
83
86
  if (businessState === 'offline') {
84
- let offlineText = 'We\'re currently closed';
87
+ let offlineText = "We're currently closed";
85
88
  if (this.state.holidayName) {
86
89
  offlineText = `Closed for ${this.state.holidayName}`;
87
90
  } else if (this.state.nextOpenAt) {
88
91
  const opens = new Date(this.state.nextOpenAt);
89
92
  const now = new Date();
90
93
  const diffHours = Math.round((opens - now) / 3600000);
91
- if (diffHours < 24) {
92
- offlineText = `Opens in ${diffHours}h`;
93
- } else {
94
- offlineText = `Opens ${opens.toLocaleDateString('en-US', { weekday: 'short', hour: 'numeric', hour12: true })}`;
95
- }
94
+ offlineText = diffHours < 24
95
+ ? `Opens in ${diffHours}h`
96
+ : `Opens ${opens.toLocaleDateString('en-US', { weekday: 'short', hour: 'numeric', hour12: true })}`;
96
97
  }
97
98
  return `
98
99
  <div class="liveChat-home-availability">
@@ -102,6 +103,15 @@
102
103
  `;
103
104
  }
104
105
 
106
+ if (businessState === 'away') {
107
+ return `
108
+ <div class="liveChat-home-availability">
109
+ <span class="liveChat-availability-dot liveChat-availability-away"></span>
110
+ <span class="liveChat-availability-text">${this.state.responseTime}</span>
111
+ </div>
112
+ `;
113
+ }
114
+
105
115
  if (this.state.agentsOnline) {
106
116
  return `
107
117
  <div class="liveChat-home-availability">