@sawport/react-sdk 0.1.0-alpha.45 → 0.1.0-alpha.46
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/index.js +175 -20
- package/dist/index.umd.js +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42290,7 +42290,8 @@ const Offline = react.exports.memo(({
|
|
|
42290
42290
|
toTime,
|
|
42291
42291
|
fromTime,
|
|
42292
42292
|
toDay,
|
|
42293
|
-
fromDay
|
|
42293
|
+
fromDay,
|
|
42294
|
+
callRequestOptions
|
|
42294
42295
|
}) => {
|
|
42295
42296
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
42296
42297
|
const [{
|
|
@@ -42591,11 +42592,12 @@ const Offline = react.exports.memo(({
|
|
|
42591
42592
|
}), /* @__PURE__ */ jsx(FInput, {
|
|
42592
42593
|
style: {
|
|
42593
42594
|
borderRight: void 0,
|
|
42594
|
-
fontSize: 16
|
|
42595
|
-
height: 60
|
|
42595
|
+
fontSize: 16
|
|
42596
42596
|
},
|
|
42597
|
-
label: "Reason For Call",
|
|
42597
|
+
label: "Select A Reason For Call",
|
|
42598
42598
|
name: "reason",
|
|
42599
|
+
type: "select",
|
|
42600
|
+
options: callRequestOptions,
|
|
42599
42601
|
placeholder: "Why did you want to call?",
|
|
42600
42602
|
handleChange,
|
|
42601
42603
|
handleBlur,
|
|
@@ -42658,6 +42660,7 @@ const Schedules = react.exports.memo(function({
|
|
|
42658
42660
|
const join2 = react.exports.useCallback(async ({
|
|
42659
42661
|
conversation
|
|
42660
42662
|
}) => {
|
|
42663
|
+
var _a, _b;
|
|
42661
42664
|
try {
|
|
42662
42665
|
dataRef.current = {
|
|
42663
42666
|
customer,
|
|
@@ -42665,7 +42668,8 @@ const Schedules = react.exports.memo(function({
|
|
|
42665
42668
|
customer,
|
|
42666
42669
|
conversation: {
|
|
42667
42670
|
id: conversation == null ? void 0 : conversation.id
|
|
42668
|
-
}
|
|
42671
|
+
},
|
|
42672
|
+
id: (_b = (_a = conversation == null ? void 0 : conversation.waitLists) == null ? void 0 : _a[0]) == null ? void 0 : _b.id
|
|
42669
42673
|
}
|
|
42670
42674
|
};
|
|
42671
42675
|
setParentState({
|
|
@@ -42814,6 +42818,7 @@ const FInput = react.exports.memo(({
|
|
|
42814
42818
|
type,
|
|
42815
42819
|
style: style2 = {},
|
|
42816
42820
|
disabled,
|
|
42821
|
+
options,
|
|
42817
42822
|
...p2
|
|
42818
42823
|
}) => {
|
|
42819
42824
|
const regexPattern = /^[a-zA-Z\s]*$/;
|
|
@@ -42841,7 +42846,25 @@ const FInput = react.exports.memo(({
|
|
|
42841
42846
|
})
|
|
42842
42847
|
}), /* @__PURE__ */ jsxs(InputGroup$1, {
|
|
42843
42848
|
className: "mt-n3",
|
|
42844
|
-
children: [/* @__PURE__ */ jsx(Input$1, {
|
|
42849
|
+
children: [type === "select" ? /* @__PURE__ */ jsx(Input$1, {
|
|
42850
|
+
...p2,
|
|
42851
|
+
style: style2,
|
|
42852
|
+
className: styles$1.offline_input,
|
|
42853
|
+
name,
|
|
42854
|
+
disabled,
|
|
42855
|
+
onChange: ["full_name", "name"].includes(name) ? onNameChange : onChange || handleChange,
|
|
42856
|
+
onBlur: onBlur || handleBlur,
|
|
42857
|
+
value: values[name],
|
|
42858
|
+
valid: touched[name] && !errors[name],
|
|
42859
|
+
invalid: touched[name] && !!errors[name],
|
|
42860
|
+
placeholder,
|
|
42861
|
+
type,
|
|
42862
|
+
bsSize: "sm",
|
|
42863
|
+
children: options.map((value2, index) => /* @__PURE__ */ jsx("option", {
|
|
42864
|
+
value: value2,
|
|
42865
|
+
children: value2
|
|
42866
|
+
}, index))
|
|
42867
|
+
}) : /* @__PURE__ */ jsx(Input$1, {
|
|
42845
42868
|
...p2,
|
|
42846
42869
|
style: style2,
|
|
42847
42870
|
className: styles$1.offline_input,
|
|
@@ -43041,10 +43064,10 @@ function WidgetOfflineHeader({
|
|
|
43041
43064
|
children: "Video Banking Offline"
|
|
43042
43065
|
})
|
|
43043
43066
|
}), /* @__PURE__ */ jsx(SubTitle, {
|
|
43044
|
-
from_day: company == null ? void 0 : company.from_day,
|
|
43045
|
-
to_day: company == null ? void 0 : company.to_day,
|
|
43046
|
-
from_time: hooks("2020-04-04 " + (company == null ? void 0 : company.from_time)).format("
|
|
43047
|
-
to_time: hooks("2020-04-04 " + (company == null ? void 0 : company.to_time)).format("
|
|
43067
|
+
from_day: company == null ? void 0 : company.from_day.substring(0, 3),
|
|
43068
|
+
to_day: company == null ? void 0 : company.to_day.substring(0, 3),
|
|
43069
|
+
from_time: hooks("2020-04-04 " + (company == null ? void 0 : company.from_time)).format("hh:mm A"),
|
|
43070
|
+
to_time: hooks("2020-04-04 " + (company == null ? void 0 : company.to_time)).format("hh:mm A")
|
|
43048
43071
|
})]
|
|
43049
43072
|
})
|
|
43050
43073
|
});
|
|
@@ -46808,6 +46831,7 @@ const createFeedback = (params) => api("feedbacks", params, "post");
|
|
|
46808
46831
|
const getWaitConnectors = async (data2) => api("wait-connectors", data2);
|
|
46809
46832
|
const getLongestWaitTime = async (data2) => api("waits/longest", data2);
|
|
46810
46833
|
const updateWait = async (id2, data2) => api(`waits/${id2}`, data2, "put");
|
|
46834
|
+
const getConnectedWait = async (data2) => api("waits/connected", data2);
|
|
46811
46835
|
function Feedback({
|
|
46812
46836
|
agent: agent_,
|
|
46813
46837
|
quickStopChat,
|
|
@@ -49917,7 +49941,7 @@ const WidgetFormDisplay = react.exports.memo(({
|
|
|
49917
49941
|
setIsWidgetLaunched,
|
|
49918
49942
|
isWidgetLaunched
|
|
49919
49943
|
}) => {
|
|
49920
|
-
var _a, _b, _c, _d;
|
|
49944
|
+
var _a, _b, _c, _d, _e;
|
|
49921
49945
|
const {
|
|
49922
49946
|
socket: socket2
|
|
49923
49947
|
} = useSocket();
|
|
@@ -50052,29 +50076,160 @@ const WidgetFormDisplay = react.exports.memo(({
|
|
|
50052
50076
|
toTime: company == null ? void 0 : company.to_time,
|
|
50053
50077
|
fromTime: company == null ? void 0 : company.from_time,
|
|
50054
50078
|
toDay: company == null ? void 0 : company.to_day,
|
|
50055
|
-
fromDay: company == null ? void 0 : company.from_day
|
|
50079
|
+
fromDay: company == null ? void 0 : company.from_day,
|
|
50080
|
+
callRequestOptions: ((_d = company == null ? void 0 : company.options) == null ? void 0 : _d.callRequestOptions) || []
|
|
50056
50081
|
}) : chatInit && !chatClose ? /* @__PURE__ */ jsx(Feedback$1, {
|
|
50057
50082
|
quickStopChat,
|
|
50058
50083
|
agent,
|
|
50059
|
-
conversation_id: (
|
|
50060
|
-
}) :
|
|
50084
|
+
conversation_id: (_e = dataRef.current) == null ? void 0 : _e.wait.conversation.id
|
|
50085
|
+
}) : /* @__PURE__ */ jsx(ChatMode, {
|
|
50086
|
+
chatInit,
|
|
50061
50087
|
company_id,
|
|
50062
50088
|
companyUser,
|
|
50063
50089
|
dataRef,
|
|
50064
50090
|
setState,
|
|
50065
50091
|
setIsScheduling,
|
|
50066
|
-
|
|
50067
|
-
widgetColor: company == null ? void 0 : company.hex_code
|
|
50068
|
-
}) : /* @__PURE__ */ jsx(ChatWidgetScreen$1, {
|
|
50069
|
-
welcome_message: company == null ? void 0 : company.welcome_message,
|
|
50070
|
-
dataRef,
|
|
50092
|
+
company,
|
|
50071
50093
|
setChatClose,
|
|
50072
50094
|
agent,
|
|
50073
|
-
videoRef
|
|
50095
|
+
videoRef,
|
|
50096
|
+
customer
|
|
50074
50097
|
})
|
|
50075
50098
|
}), /* @__PURE__ */ jsx(Footer, {})]
|
|
50076
50099
|
});
|
|
50077
50100
|
});
|
|
50101
|
+
const ChatMode = react.exports.memo(({
|
|
50102
|
+
chatInit,
|
|
50103
|
+
company_id,
|
|
50104
|
+
companyUser,
|
|
50105
|
+
dataRef,
|
|
50106
|
+
setState,
|
|
50107
|
+
setIsScheduling,
|
|
50108
|
+
company,
|
|
50109
|
+
setChatClose,
|
|
50110
|
+
agent,
|
|
50111
|
+
videoRef,
|
|
50112
|
+
customer
|
|
50113
|
+
}) => {
|
|
50114
|
+
var _a, _b, _c;
|
|
50115
|
+
const {
|
|
50116
|
+
state: {
|
|
50117
|
+
data: data2
|
|
50118
|
+
},
|
|
50119
|
+
setState: _setState
|
|
50120
|
+
} = useRequest({
|
|
50121
|
+
asyncRequest: getConnectedWait,
|
|
50122
|
+
params: [{
|
|
50123
|
+
customer: customer == null ? void 0 : customer.id
|
|
50124
|
+
}]
|
|
50125
|
+
});
|
|
50126
|
+
const agent_ = react.exports.useMemo(() => {
|
|
50127
|
+
var _a2, _b2;
|
|
50128
|
+
const connectors = (_a2 = data2 == null ? void 0 : data2[0]) == null ? void 0 : _a2.connectors;
|
|
50129
|
+
return (_b2 = connectors == null ? void 0 : connectors[(connectors == null ? void 0 : connectors.length) - 1]) == null ? void 0 : _b2.agent;
|
|
50130
|
+
}, [data2]);
|
|
50131
|
+
return !chatInit ? (data2 == null ? void 0 : data2.length) ? /* @__PURE__ */ jsx(OngoingChat, {
|
|
50132
|
+
waitId: (_a = data2 == null ? void 0 : data2[0]) == null ? void 0 : _a.id,
|
|
50133
|
+
conversationId: (_c = (_b = data2 == null ? void 0 : data2[0]) == null ? void 0 : _b.conversation) == null ? void 0 : _c.id,
|
|
50134
|
+
agent: agent_,
|
|
50135
|
+
setState: _setState,
|
|
50136
|
+
customer,
|
|
50137
|
+
dataRef,
|
|
50138
|
+
setParentState: setState
|
|
50139
|
+
}) : /* @__PURE__ */ jsx(WidgetInitForm$1, {
|
|
50140
|
+
company_id,
|
|
50141
|
+
companyUser,
|
|
50142
|
+
dataRef,
|
|
50143
|
+
setState,
|
|
50144
|
+
setIsScheduling,
|
|
50145
|
+
fields: company == null ? void 0 : company.fields,
|
|
50146
|
+
widgetColor: company == null ? void 0 : company.hex_code
|
|
50147
|
+
}) : /* @__PURE__ */ jsx(ChatWidgetScreen$1, {
|
|
50148
|
+
welcome_message: company == null ? void 0 : company.welcome_message,
|
|
50149
|
+
dataRef,
|
|
50150
|
+
setChatClose,
|
|
50151
|
+
agent,
|
|
50152
|
+
videoRef
|
|
50153
|
+
});
|
|
50154
|
+
});
|
|
50155
|
+
const OngoingChat = ({
|
|
50156
|
+
setState,
|
|
50157
|
+
waitId,
|
|
50158
|
+
dataRef,
|
|
50159
|
+
customer,
|
|
50160
|
+
conversationId,
|
|
50161
|
+
setParentState,
|
|
50162
|
+
agent
|
|
50163
|
+
}) => {
|
|
50164
|
+
const {
|
|
50165
|
+
socket: socket2
|
|
50166
|
+
} = useSocket();
|
|
50167
|
+
const endChat = () => {
|
|
50168
|
+
t$1.emit("chat-ended");
|
|
50169
|
+
updateWait(waitId, {
|
|
50170
|
+
status: "ended"
|
|
50171
|
+
});
|
|
50172
|
+
setState({
|
|
50173
|
+
data: []
|
|
50174
|
+
});
|
|
50175
|
+
resume({
|
|
50176
|
+
chatClose: false
|
|
50177
|
+
});
|
|
50178
|
+
};
|
|
50179
|
+
const resume = ({
|
|
50180
|
+
chatClose
|
|
50181
|
+
} = {}) => {
|
|
50182
|
+
try {
|
|
50183
|
+
dataRef.current = {
|
|
50184
|
+
customer,
|
|
50185
|
+
wait: {
|
|
50186
|
+
customer,
|
|
50187
|
+
conversation: {
|
|
50188
|
+
id: conversationId
|
|
50189
|
+
},
|
|
50190
|
+
id: waitId
|
|
50191
|
+
}
|
|
50192
|
+
};
|
|
50193
|
+
const updates = {
|
|
50194
|
+
chatInit: true,
|
|
50195
|
+
companyClosed: false,
|
|
50196
|
+
agent
|
|
50197
|
+
};
|
|
50198
|
+
setState({
|
|
50199
|
+
data: []
|
|
50200
|
+
});
|
|
50201
|
+
chatClose !== void 0 && (updates.chatClose = chatClose);
|
|
50202
|
+
setParentState(updates);
|
|
50203
|
+
socket2.emit("customer-joined-conversation", {
|
|
50204
|
+
conversation: conversationId,
|
|
50205
|
+
customer: customer == null ? void 0 : customer.id
|
|
50206
|
+
});
|
|
50207
|
+
} catch (error) {
|
|
50208
|
+
console.log(error);
|
|
50209
|
+
}
|
|
50210
|
+
};
|
|
50211
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
50212
|
+
className: "p-4 d-flex flex-column align-items-center justify-content-center",
|
|
50213
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
50214
|
+
className: "my-2",
|
|
50215
|
+
children: "You have an ongoing chat!"
|
|
50216
|
+
}), /* @__PURE__ */ jsx("h4", {
|
|
50217
|
+
className: "mb-5",
|
|
50218
|
+
children: "Would you like to resume the chat?"
|
|
50219
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
50220
|
+
className: "mt-5 mb-3 d-flex align-items-center justify-content-center",
|
|
50221
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
50222
|
+
onClick: endChat,
|
|
50223
|
+
className: "btn btn-danger",
|
|
50224
|
+
children: "End Chat"
|
|
50225
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
50226
|
+
onClick: resume,
|
|
50227
|
+
className: "btn btn-primary ml-4",
|
|
50228
|
+
children: "Resume"
|
|
50229
|
+
})]
|
|
50230
|
+
})]
|
|
50231
|
+
});
|
|
50232
|
+
};
|
|
50078
50233
|
const Footer = () => /* @__PURE__ */ jsx("div", {
|
|
50079
50234
|
className: "widget-footer-container",
|
|
50080
50235
|
children: /* @__PURE__ */ jsxs("div", {
|