powr-sdk-web 5.4.0 → 5.4.2
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/chat/index.js +270 -69
- package/package.json +1 -1
package/dist/chat/index.js
CHANGED
|
@@ -35,6 +35,11 @@ var PowrBaseChat = function PowrBaseChat(_ref) {
|
|
|
35
35
|
apiUrl = _ref.apiUrl,
|
|
36
36
|
projectGroupName = _ref.projectGroupName,
|
|
37
37
|
participantIds = _ref.participantIds,
|
|
38
|
+
_ref$projects = _ref.projects,
|
|
39
|
+
projects = _ref$projects === void 0 ? [] : _ref$projects,
|
|
40
|
+
_ref$selectedProject = _ref.selectedProject,
|
|
41
|
+
selectedProject = _ref$selectedProject === void 0 ? null : _ref$selectedProject,
|
|
42
|
+
onProjectChange = _ref.onProjectChange,
|
|
38
43
|
onMessageSent = _ref.onMessageSent,
|
|
39
44
|
onConversationCreated = _ref.onConversationCreated,
|
|
40
45
|
onError = _ref.onError,
|
|
@@ -76,10 +81,14 @@ var PowrBaseChat = function PowrBaseChat(_ref) {
|
|
|
76
81
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
77
82
|
showNewChat = _useState14[0],
|
|
78
83
|
setShowNewChat = _useState14[1];
|
|
79
|
-
var _useState15 = (0, _react.useState)(
|
|
84
|
+
var _useState15 = (0, _react.useState)('chat'),
|
|
80
85
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
newChatTab = _useState16[0],
|
|
87
|
+
setNewChatTab = _useState16[1];
|
|
88
|
+
var _useState17 = (0, _react.useState)([]),
|
|
89
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
90
|
+
users = _useState18[0],
|
|
91
|
+
setUsers = _useState18[1];
|
|
83
92
|
var messagesEndRef = (0, _react.useRef)(null);
|
|
84
93
|
var pollingInterval = (0, _react.useRef)(undefined);
|
|
85
94
|
var hasSelectedProjectGroup = (0, _react.useRef)(false);
|
|
@@ -99,45 +108,51 @@ var PowrBaseChat = function PowrBaseChat(_ref) {
|
|
|
99
108
|
return _regenerator().w(function (_context) {
|
|
100
109
|
while (1) switch (_context.n) {
|
|
101
110
|
case 0:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
if (!(!projectId || !apiUrl)) {
|
|
112
|
+
_context.n = 1;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return _context.a(2);
|
|
105
116
|
case 1:
|
|
117
|
+
_context.p = 1;
|
|
118
|
+
_context.n = 2;
|
|
119
|
+
return (0, _auth.apiCall)(apiUrl, "/chat/conversations", projectId);
|
|
120
|
+
case 2:
|
|
106
121
|
_yield$apiCall = _context.v;
|
|
107
122
|
data = _yield$apiCall.data;
|
|
108
123
|
ok = _yield$apiCall.ok;
|
|
109
124
|
if (!(ok && data.success && Array.isArray(data.data))) {
|
|
110
|
-
_context.n =
|
|
125
|
+
_context.n = 6;
|
|
111
126
|
break;
|
|
112
127
|
}
|
|
113
128
|
convos = data.data; // Ensure project group exists when projectGroupName + participantIds provided
|
|
114
129
|
if (!(projectGroupName && participantIds !== null && participantIds !== void 0 && participantIds.length && projectId)) {
|
|
115
|
-
_context.n =
|
|
130
|
+
_context.n = 5;
|
|
116
131
|
break;
|
|
117
132
|
}
|
|
118
|
-
_context.n =
|
|
133
|
+
_context.n = 3;
|
|
119
134
|
return ensureProjectGroup();
|
|
120
|
-
case
|
|
135
|
+
case 3:
|
|
121
136
|
groupId = _context.v;
|
|
122
137
|
if (!groupId) {
|
|
123
|
-
_context.n =
|
|
138
|
+
_context.n = 5;
|
|
124
139
|
break;
|
|
125
140
|
}
|
|
126
141
|
hasGroup = convos.some(function (c) {
|
|
127
142
|
return c.id === groupId;
|
|
128
143
|
});
|
|
129
144
|
if (hasGroup) {
|
|
130
|
-
_context.n =
|
|
145
|
+
_context.n = 5;
|
|
131
146
|
break;
|
|
132
147
|
}
|
|
133
|
-
_context.n =
|
|
148
|
+
_context.n = 4;
|
|
134
149
|
return (0, _auth.apiCall)(apiUrl, "/chat/conversations", projectId);
|
|
135
|
-
case
|
|
150
|
+
case 4:
|
|
136
151
|
refetch = _context.v;
|
|
137
152
|
if (refetch.ok && (_refetch$data = refetch.data) !== null && _refetch$data !== void 0 && _refetch$data.success && Array.isArray((_refetch$data2 = refetch.data) === null || _refetch$data2 === void 0 ? void 0 : _refetch$data2.data)) {
|
|
138
153
|
convos = refetch.data.data;
|
|
139
154
|
}
|
|
140
|
-
case
|
|
155
|
+
case 5:
|
|
141
156
|
setConversations(convos);
|
|
142
157
|
// Default to project group on first load when available
|
|
143
158
|
if (projectGroupName && !hasSelectedProjectGroup.current) {
|
|
@@ -149,23 +164,23 @@ var PowrBaseChat = function PowrBaseChat(_ref) {
|
|
|
149
164
|
hasSelectedProjectGroup.current = true;
|
|
150
165
|
}
|
|
151
166
|
}
|
|
152
|
-
_context.n =
|
|
167
|
+
_context.n = 7;
|
|
153
168
|
break;
|
|
154
|
-
case 5:
|
|
155
|
-
setConversations([]);
|
|
156
169
|
case 6:
|
|
157
|
-
|
|
158
|
-
break;
|
|
170
|
+
setConversations([]);
|
|
159
171
|
case 7:
|
|
160
|
-
_context.
|
|
172
|
+
_context.n = 9;
|
|
173
|
+
break;
|
|
174
|
+
case 8:
|
|
175
|
+
_context.p = 8;
|
|
161
176
|
_t = _context.v;
|
|
162
177
|
console.error('Error fetching conversations:', _t);
|
|
163
178
|
setConversations([]);
|
|
164
179
|
onError === null || onError === void 0 || onError(_t);
|
|
165
|
-
case
|
|
180
|
+
case 9:
|
|
166
181
|
return _context.a(2);
|
|
167
182
|
}
|
|
168
|
-
}, _callee, null, [[
|
|
183
|
+
}, _callee, null, [[1, 8]]);
|
|
169
184
|
}));
|
|
170
185
|
return function fetchConversations() {
|
|
171
186
|
return _ref2.apply(this, arguments);
|
|
@@ -179,11 +194,17 @@ var PowrBaseChat = function PowrBaseChat(_ref) {
|
|
|
179
194
|
return _regenerator().w(function (_context2) {
|
|
180
195
|
while (1) switch (_context2.n) {
|
|
181
196
|
case 0:
|
|
182
|
-
|
|
197
|
+
if (!(!projectId || !apiUrl)) {
|
|
198
|
+
_context2.n = 1;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
return _context2.a(2);
|
|
202
|
+
case 1:
|
|
203
|
+
_context2.p = 1;
|
|
183
204
|
console.log('Fetching users...');
|
|
184
|
-
_context2.n =
|
|
205
|
+
_context2.n = 2;
|
|
185
206
|
return (0, _auth.apiCall)(apiUrl, "/chat/users", projectId);
|
|
186
|
-
case
|
|
207
|
+
case 2:
|
|
187
208
|
_yield$apiCall2 = _context2.v;
|
|
188
209
|
data = _yield$apiCall2.data;
|
|
189
210
|
ok = _yield$apiCall2.ok;
|
|
@@ -194,18 +215,18 @@ var PowrBaseChat = function PowrBaseChat(_ref) {
|
|
|
194
215
|
console.error('Invalid users data:', data);
|
|
195
216
|
setUsers([]);
|
|
196
217
|
}
|
|
197
|
-
_context2.n =
|
|
218
|
+
_context2.n = 4;
|
|
198
219
|
break;
|
|
199
|
-
case
|
|
200
|
-
_context2.p =
|
|
220
|
+
case 3:
|
|
221
|
+
_context2.p = 3;
|
|
201
222
|
_t2 = _context2.v;
|
|
202
223
|
console.error('Error fetching users:', _t2);
|
|
203
224
|
setUsers([]);
|
|
204
225
|
onError === null || onError === void 0 || onError(_t2);
|
|
205
|
-
case
|
|
226
|
+
case 4:
|
|
206
227
|
return _context2.a(2);
|
|
207
228
|
}
|
|
208
|
-
}, _callee2, null, [[
|
|
229
|
+
}, _callee2, null, [[1, 3]]);
|
|
209
230
|
}));
|
|
210
231
|
return function fetchUsers() {
|
|
211
232
|
return _ref3.apply(this, arguments);
|
|
@@ -424,20 +445,22 @@ var PowrBaseChat = function PowrBaseChat(_ref) {
|
|
|
424
445
|
}
|
|
425
446
|
}, [selectedChat]);
|
|
426
447
|
|
|
427
|
-
// Initial load of conversations
|
|
448
|
+
// Initial load of conversations; reset project group selection when project changes
|
|
428
449
|
(0, _react.useEffect)(function () {
|
|
429
|
-
|
|
430
|
-
|
|
450
|
+
hasSelectedProjectGroup.current = false;
|
|
451
|
+
if (projectId && apiUrl) fetchConversations();
|
|
452
|
+
}, [projectId]);
|
|
431
453
|
|
|
432
454
|
// Poll for new conversations every 30 seconds
|
|
433
455
|
(0, _react.useEffect)(function () {
|
|
456
|
+
if (!projectId || !apiUrl) return;
|
|
434
457
|
var conversationPolling = setInterval(function () {
|
|
435
458
|
fetchConversations();
|
|
436
459
|
}, 30000);
|
|
437
460
|
return function () {
|
|
438
461
|
return clearInterval(conversationPolling);
|
|
439
462
|
};
|
|
440
|
-
}, []);
|
|
463
|
+
}, [projectId]);
|
|
441
464
|
var filteredConversations = Array.isArray(conversations) ? conversations.filter(function (conv) {
|
|
442
465
|
return (conv.name || '').toLowerCase().includes((searchQuery || '').toLowerCase());
|
|
443
466
|
}) : [];
|
|
@@ -626,9 +649,27 @@ var PowrBaseChat = function PowrBaseChat(_ref) {
|
|
|
626
649
|
style: styles.sidebar
|
|
627
650
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
628
651
|
style: styles.header
|
|
652
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
653
|
+
style: {
|
|
654
|
+
display: 'flex',
|
|
655
|
+
alignItems: 'center',
|
|
656
|
+
justifyContent: 'space-between',
|
|
657
|
+
marginBottom: '12px'
|
|
658
|
+
}
|
|
629
659
|
}, /*#__PURE__*/_react["default"].createElement("h2", {
|
|
630
|
-
style: styles.title
|
|
631
|
-
|
|
660
|
+
style: _objectSpread(_objectSpread({}, styles.title), {}, {
|
|
661
|
+
margin: 0
|
|
662
|
+
})
|
|
663
|
+
}, "Messages"), /*#__PURE__*/_react["default"].createElement("button", {
|
|
664
|
+
onClick: function onClick() {
|
|
665
|
+
if (!showNewChat) fetchUsers();
|
|
666
|
+
setShowNewChat(true);
|
|
667
|
+
},
|
|
668
|
+
style: _objectSpread(_objectSpread({}, styles.sendButton), {}, {
|
|
669
|
+
padding: '8px 14px',
|
|
670
|
+
fontSize: '13px'
|
|
671
|
+
})
|
|
672
|
+
}, "New Chat")), /*#__PURE__*/_react["default"].createElement("input", {
|
|
632
673
|
type: "text",
|
|
633
674
|
placeholder: "Search conversations...",
|
|
634
675
|
value: searchQuery,
|
|
@@ -636,51 +677,125 @@ var PowrBaseChat = function PowrBaseChat(_ref) {
|
|
|
636
677
|
return setSearchQuery(e.target.value);
|
|
637
678
|
},
|
|
638
679
|
style: styles.searchInput
|
|
639
|
-
}), /*#__PURE__*/_react["default"].createElement("
|
|
640
|
-
onClick: function onClick() {
|
|
641
|
-
if (!showNewChat) {
|
|
642
|
-
fetchUsers(); // Load users only when opening new chat
|
|
643
|
-
}
|
|
644
|
-
setShowNewChat(!showNewChat);
|
|
645
|
-
},
|
|
646
|
-
style: _objectSpread(_objectSpread({}, styles.sendButton), {}, {
|
|
647
|
-
marginTop: '12px',
|
|
648
|
-
width: '100%'
|
|
649
|
-
})
|
|
650
|
-
}, showNewChat ? 'Cancel' : 'New Chat')), /*#__PURE__*/_react["default"].createElement("div", {
|
|
680
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
651
681
|
style: styles.conversationList
|
|
652
682
|
}, showNewChat && /*#__PURE__*/_react["default"].createElement("div", {
|
|
653
683
|
style: {
|
|
654
|
-
|
|
655
|
-
|
|
684
|
+
position: 'fixed',
|
|
685
|
+
inset: 0,
|
|
686
|
+
zIndex: 50,
|
|
687
|
+
display: 'flex',
|
|
688
|
+
alignItems: 'center',
|
|
689
|
+
justifyContent: 'center',
|
|
690
|
+
backgroundColor: 'rgba(0,0,0,0.5)'
|
|
691
|
+
},
|
|
692
|
+
onClick: function onClick() {
|
|
693
|
+
return setShowNewChat(false);
|
|
694
|
+
}
|
|
695
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
696
|
+
style: {
|
|
697
|
+
backgroundColor: '#fff',
|
|
698
|
+
borderRadius: '8px',
|
|
699
|
+
padding: '24px',
|
|
700
|
+
maxWidth: '28rem',
|
|
701
|
+
maxHeight: '80vh',
|
|
702
|
+
overflow: 'hidden',
|
|
703
|
+
display: 'flex',
|
|
704
|
+
flexDirection: 'column',
|
|
705
|
+
boxShadow: '0 25px 50px -12px rgba(0,0,0,0.25)'
|
|
706
|
+
},
|
|
707
|
+
onClick: function onClick(e) {
|
|
708
|
+
return e.stopPropagation();
|
|
709
|
+
}
|
|
710
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
711
|
+
style: {
|
|
712
|
+
display: 'flex',
|
|
713
|
+
justifyContent: 'space-between',
|
|
714
|
+
alignItems: 'center',
|
|
715
|
+
marginBottom: '16px'
|
|
656
716
|
}
|
|
657
717
|
}, /*#__PURE__*/_react["default"].createElement("h3", {
|
|
658
718
|
style: {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
719
|
+
margin: 0,
|
|
720
|
+
fontSize: '18px',
|
|
721
|
+
fontWeight: 600
|
|
722
|
+
}
|
|
723
|
+
}, "New Chat"), /*#__PURE__*/_react["default"].createElement("button", {
|
|
724
|
+
onClick: function onClick() {
|
|
725
|
+
return setShowNewChat(false);
|
|
726
|
+
},
|
|
727
|
+
style: {
|
|
728
|
+
background: 'none',
|
|
729
|
+
border: 'none',
|
|
730
|
+
cursor: 'pointer',
|
|
731
|
+
fontSize: '20px',
|
|
732
|
+
fontWeight: 300
|
|
662
733
|
}
|
|
663
|
-
}, "
|
|
734
|
+
}, "\xD7")), /*#__PURE__*/_react["default"].createElement("div", {
|
|
664
735
|
style: {
|
|
665
736
|
display: 'flex',
|
|
666
|
-
|
|
667
|
-
|
|
737
|
+
gap: '4px',
|
|
738
|
+
marginBottom: '16px'
|
|
668
739
|
}
|
|
669
|
-
},
|
|
740
|
+
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
741
|
+
onClick: function onClick() {
|
|
742
|
+
return setNewChatTab('chat');
|
|
743
|
+
},
|
|
744
|
+
style: {
|
|
745
|
+
flex: 1,
|
|
746
|
+
padding: '8px 12px',
|
|
747
|
+
border: 'none',
|
|
748
|
+
borderRadius: '6px',
|
|
749
|
+
cursor: 'pointer',
|
|
750
|
+
fontWeight: 500,
|
|
751
|
+
backgroundColor: newChatTab === 'chat' ? '#eff6ff' : '#f3f4f6',
|
|
752
|
+
color: newChatTab === 'chat' ? '#1d4ed8' : '#6b7280'
|
|
753
|
+
}
|
|
754
|
+
}, "Direct message"), /*#__PURE__*/_react["default"].createElement("button", {
|
|
755
|
+
onClick: function onClick() {
|
|
756
|
+
return setNewChatTab('project');
|
|
757
|
+
},
|
|
758
|
+
style: {
|
|
759
|
+
flex: 1,
|
|
760
|
+
padding: '8px 12px',
|
|
761
|
+
border: 'none',
|
|
762
|
+
borderRadius: '6px',
|
|
763
|
+
cursor: 'pointer',
|
|
764
|
+
fontWeight: 500,
|
|
765
|
+
backgroundColor: newChatTab === 'project' ? '#eff6ff' : '#f3f4f6',
|
|
766
|
+
color: newChatTab === 'project' ? '#1d4ed8' : '#6b7280'
|
|
767
|
+
}
|
|
768
|
+
}, "Project")), /*#__PURE__*/_react["default"].createElement("div", {
|
|
769
|
+
style: {
|
|
770
|
+
flex: 1,
|
|
771
|
+
overflowY: 'auto',
|
|
772
|
+
maxHeight: '50vh'
|
|
773
|
+
}
|
|
774
|
+
}, newChatTab === 'chat' && (projectId ? users.length === 0 ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
670
775
|
style: {
|
|
671
776
|
textAlign: 'center',
|
|
672
777
|
color: '#6b7280',
|
|
673
|
-
padding: '
|
|
778
|
+
padding: '24px',
|
|
779
|
+
fontSize: '14px'
|
|
674
780
|
}
|
|
675
781
|
}, /*#__PURE__*/_react["default"].createElement("p", null, "No users available"), /*#__PURE__*/_react["default"].createElement("p", {
|
|
676
782
|
style: {
|
|
677
|
-
fontSize: '12px'
|
|
783
|
+
fontSize: '12px',
|
|
784
|
+
marginTop: '4px'
|
|
785
|
+
}
|
|
786
|
+
}, "Select a project first or add users to your project")) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
787
|
+
style: {
|
|
788
|
+
display: 'flex',
|
|
789
|
+
flexDirection: 'column',
|
|
790
|
+
gap: '8px'
|
|
678
791
|
}
|
|
679
|
-
},
|
|
792
|
+
}, users.map(function (user) {
|
|
680
793
|
var _user$name;
|
|
681
794
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
682
795
|
key: user.id,
|
|
683
|
-
style: _objectSpread(_objectSpread({}, styles.conversationItem), styles.conversationItemHover),
|
|
796
|
+
style: _objectSpread(_objectSpread(_objectSpread({}, styles.conversationItem), styles.conversationItemHover), {}, {
|
|
797
|
+
padding: '12px'
|
|
798
|
+
}),
|
|
684
799
|
onClick: function onClick() {
|
|
685
800
|
return createConversation(user.id);
|
|
686
801
|
}
|
|
@@ -699,26 +814,81 @@ var PowrBaseChat = function PowrBaseChat(_ref) {
|
|
|
699
814
|
display: 'flex',
|
|
700
815
|
alignItems: 'center',
|
|
701
816
|
justifyContent: 'center',
|
|
702
|
-
color: '#
|
|
703
|
-
fontWeight:
|
|
817
|
+
color: '#fff',
|
|
818
|
+
fontWeight: 600,
|
|
704
819
|
fontSize: '14px'
|
|
705
820
|
}
|
|
706
821
|
}, (_user$name = user.name) === null || _user$name === void 0 ? void 0 : _user$name.split(' ').map(function (n) {
|
|
707
822
|
return n[0];
|
|
708
823
|
}).join('')), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("p", {
|
|
709
824
|
style: {
|
|
710
|
-
margin:
|
|
711
|
-
fontWeight:
|
|
825
|
+
margin: 0,
|
|
826
|
+
fontWeight: 500,
|
|
712
827
|
fontSize: '14px'
|
|
713
828
|
}
|
|
714
829
|
}, user.name), /*#__PURE__*/_react["default"].createElement("p", {
|
|
715
830
|
style: {
|
|
716
|
-
margin:
|
|
831
|
+
margin: 0,
|
|
717
832
|
fontSize: '12px',
|
|
718
833
|
color: '#6b7280'
|
|
719
834
|
}
|
|
720
835
|
}, user.username))));
|
|
721
|
-
}))
|
|
836
|
+
})) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
837
|
+
style: {
|
|
838
|
+
textAlign: 'center',
|
|
839
|
+
color: '#6b7280',
|
|
840
|
+
padding: '24px',
|
|
841
|
+
fontSize: '14px'
|
|
842
|
+
}
|
|
843
|
+
}, /*#__PURE__*/_react["default"].createElement("p", null, "Select a project first"))), newChatTab === 'project' && ((projects === null || projects === void 0 ? void 0 : projects.length) > 0 ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
844
|
+
style: {
|
|
845
|
+
display: 'flex',
|
|
846
|
+
flexDirection: 'column',
|
|
847
|
+
gap: '8px'
|
|
848
|
+
}
|
|
849
|
+
}, projects.map(function (project) {
|
|
850
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
851
|
+
key: project._id,
|
|
852
|
+
style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, styles.conversationItem), styles.conversationItemHover), (selectedProject === null || selectedProject === void 0 ? void 0 : selectedProject._id) === project._id ? styles.conversationItemSelected : {}), {}, {
|
|
853
|
+
padding: '12px'
|
|
854
|
+
}),
|
|
855
|
+
onClick: function onClick() {
|
|
856
|
+
onProjectChange === null || onProjectChange === void 0 || onProjectChange(project);
|
|
857
|
+
setShowNewChat(false);
|
|
858
|
+
}
|
|
859
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
860
|
+
style: {
|
|
861
|
+
display: 'flex',
|
|
862
|
+
alignItems: 'center',
|
|
863
|
+
gap: '12px'
|
|
864
|
+
}
|
|
865
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
866
|
+
style: {
|
|
867
|
+
width: '40px',
|
|
868
|
+
height: '40px',
|
|
869
|
+
borderRadius: '8px',
|
|
870
|
+
backgroundColor: '#10b981',
|
|
871
|
+
display: 'flex',
|
|
872
|
+
alignItems: 'center',
|
|
873
|
+
justifyContent: 'center',
|
|
874
|
+
color: '#fff',
|
|
875
|
+
fontSize: '18px'
|
|
876
|
+
}
|
|
877
|
+
}, "\uD83D\uDC65"), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("p", {
|
|
878
|
+
style: {
|
|
879
|
+
margin: 0,
|
|
880
|
+
fontWeight: 500,
|
|
881
|
+
fontSize: '14px'
|
|
882
|
+
}
|
|
883
|
+
}, project.name))));
|
|
884
|
+
})) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
885
|
+
style: {
|
|
886
|
+
textAlign: 'center',
|
|
887
|
+
color: '#6b7280',
|
|
888
|
+
padding: '24px',
|
|
889
|
+
fontSize: '14px'
|
|
890
|
+
}
|
|
891
|
+
}, /*#__PURE__*/_react["default"].createElement("p", null, "No projects available")))))), filteredConversations.map(function (conversation) {
|
|
722
892
|
var _conversation$name;
|
|
723
893
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
724
894
|
key: conversation.id,
|
|
@@ -885,7 +1055,32 @@ var PowrBaseChat = function PowrBaseChat(_ref) {
|
|
|
885
1055
|
onClick: handleSendMessage,
|
|
886
1056
|
disabled: sending || !message.trim(),
|
|
887
1057
|
style: _objectSpread(_objectSpread({}, styles.sendButton), sending || !message.trim() ? styles.sendButtonDisabled : {})
|
|
888
|
-
}, sending ? 'Sending...' : 'Send'))) :
|
|
1058
|
+
}, sending ? 'Sending...' : 'Send'))) : projects !== null && projects !== void 0 && projects.length && !selectedProject ?
|
|
1059
|
+
/*#__PURE__*/
|
|
1060
|
+
/* No project selected - prompt to select */
|
|
1061
|
+
_react["default"].createElement("div", {
|
|
1062
|
+
style: styles.emptyState
|
|
1063
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
1064
|
+
style: {
|
|
1065
|
+
textAlign: 'center'
|
|
1066
|
+
}
|
|
1067
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
1068
|
+
style: {
|
|
1069
|
+
fontSize: '48px',
|
|
1070
|
+
marginBottom: '16px'
|
|
1071
|
+
}
|
|
1072
|
+
}, "\uD83D\uDC65"), /*#__PURE__*/_react["default"].createElement("h3", {
|
|
1073
|
+
style: {
|
|
1074
|
+
margin: '0 0 8px 0',
|
|
1075
|
+
fontSize: '18px',
|
|
1076
|
+
fontWeight: '600'
|
|
1077
|
+
}
|
|
1078
|
+
}, "Select a project"), /*#__PURE__*/_react["default"].createElement("p", {
|
|
1079
|
+
style: {
|
|
1080
|
+
margin: '0',
|
|
1081
|
+
fontSize: '14px'
|
|
1082
|
+
}
|
|
1083
|
+
}, "Click \"Select project\" in the sidebar to choose a project and start chatting"))) :
|
|
889
1084
|
/*#__PURE__*/
|
|
890
1085
|
/* Empty State */
|
|
891
1086
|
_react["default"].createElement("div", {
|
|
@@ -917,6 +1112,12 @@ PowrBaseChat.propTypes = {
|
|
|
917
1112
|
apiUrl: _propTypes["default"].string,
|
|
918
1113
|
projectGroupName: _propTypes["default"].string,
|
|
919
1114
|
participantIds: _propTypes["default"].arrayOf(_propTypes["default"].string),
|
|
1115
|
+
projects: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
1116
|
+
_id: _propTypes["default"].string,
|
|
1117
|
+
name: _propTypes["default"].string
|
|
1118
|
+
})),
|
|
1119
|
+
selectedProject: _propTypes["default"].object,
|
|
1120
|
+
onProjectChange: _propTypes["default"].func,
|
|
920
1121
|
onMessageSent: _propTypes["default"].func,
|
|
921
1122
|
onConversationCreated: _propTypes["default"].func,
|
|
922
1123
|
onError: _propTypes["default"].func,
|