@sawport/react-sdk 0.1.0-alpha.50 → 0.1.0-alpha.51
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/README.md +32 -9
- package/dist/index.js +65 -37
- package/dist/index.umd.js +2 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,24 +7,47 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo
|
|
|
7
7
|
```html
|
|
8
8
|
<html>
|
|
9
9
|
<head>
|
|
10
|
-
<link href="https://
|
|
11
|
-
<script src="https://{WIDGET_HOST_DOMAIN}/widget/index.js"></script>
|
|
10
|
+
<link href="https://unpkg.com/@sawport/react-sdk/dist/style.css" rel="stylesheet" />
|
|
12
11
|
...
|
|
13
12
|
```
|
|
14
|
-
|
|
13
|
+
|
|
14
|
+
### Put the widget into a container id of `sawport-widget`
|
|
15
|
+
```html
|
|
16
|
+
...
|
|
17
|
+
<div id="sawport-widget"></div>
|
|
18
|
+
</body>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Pull in ther sawport SDK into your website
|
|
22
|
+
> Mount the sawport widget when document is fully loaded and with default configurations.
|
|
15
23
|
```html
|
|
16
24
|
...
|
|
17
|
-
<
|
|
25
|
+
<script type="module" src="https://unpkg.com/@sawport/react-sdk@latest/dist/index.js"></script>
|
|
26
|
+
|
|
27
|
+
<script>function docReady(fn) {
|
|
28
|
+
['complete', 'interactive'].includes(document.readyState)
|
|
29
|
+
? setTimeout(fn, 1)
|
|
30
|
+
: document.addEventListener('DOMContentLoaded', fn);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
docReady(() => sawportSDK.mountWidget({
|
|
34
|
+
baseURL: 'https://{DASHBOARD_HOST_DOMAIN}',
|
|
35
|
+
apiURL: 'https://{DASHBOARD_HOST_DOMAIN}/api/v1/',
|
|
36
|
+
projectId: XXXXXXXXXXXXXX,
|
|
37
|
+
user: {email: 'example@emai.lcom', phone: '080XXXXXXXXX', name: 'Firstname Lastname'}, // optional
|
|
38
|
+
}, 'sawport-widget'))
|
|
39
|
+
</script>
|
|
18
40
|
</body>
|
|
19
41
|
```
|
|
20
42
|
|
|
21
43
|
### Setting up enterprise credentials
|
|
22
|
-
|
|
44
|
+
> Call the Sawport function `setSawportConfig` to set the enterprise credential.
|
|
23
45
|
```js
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
46
|
+
docReady(() => sawportSDK.setSawportConfig({
|
|
47
|
+
baseURL: 'https://{DASHBOARD_HOST_DOMAIN}',
|
|
48
|
+
apiURL: 'https://{DASHBOARD_HOST_DOMAIN}/api/v1/',
|
|
49
|
+
projectId: XXXXXXXXXXXXXX,
|
|
50
|
+
user: {email: 'example@emai.lcom', phone: '080XXXXXXXXX', name: 'Firstname Lastname'}
|
|
28
51
|
})
|
|
29
52
|
})
|
|
30
53
|
```
|
package/dist/index.js
CHANGED
|
@@ -60918,10 +60918,13 @@ const Offline = react.exports.memo(({
|
|
|
60918
60918
|
fromTime,
|
|
60919
60919
|
toDay,
|
|
60920
60920
|
fromDay,
|
|
60921
|
-
options
|
|
60921
|
+
options,
|
|
60922
|
+
customer,
|
|
60923
|
+
fields
|
|
60922
60924
|
}) => {
|
|
60923
60925
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
60924
60926
|
const callRequestOptions = [...(options == null ? void 0 : options.enableVoicenote) ? ["Leave a voice note"] : [], ...options.callRequestOptions || []];
|
|
60927
|
+
const user2 = (customer == null ? void 0 : customer.email) ? customer : companyUser;
|
|
60925
60928
|
const [{
|
|
60926
60929
|
ipAddress,
|
|
60927
60930
|
country,
|
|
@@ -60929,7 +60932,6 @@ const Offline = react.exports.memo(({
|
|
|
60929
60932
|
latitude,
|
|
60930
60933
|
location: location2,
|
|
60931
60934
|
country_code,
|
|
60932
|
-
mobile,
|
|
60933
60935
|
isLoading,
|
|
60934
60936
|
scheduled,
|
|
60935
60937
|
continent,
|
|
@@ -60941,7 +60943,6 @@ const Offline = react.exports.memo(({
|
|
|
60941
60943
|
latitude: "",
|
|
60942
60944
|
location: "",
|
|
60943
60945
|
country_code: "",
|
|
60944
|
-
mobile: "",
|
|
60945
60946
|
isLoading: false,
|
|
60946
60947
|
scheduled: false,
|
|
60947
60948
|
continent: void 0,
|
|
@@ -60965,6 +60966,14 @@ const Offline = react.exports.memo(({
|
|
|
60965
60966
|
}),
|
|
60966
60967
|
reason: create$4().min(1).required("Reason is required")
|
|
60967
60968
|
});
|
|
60969
|
+
const emptyFields = react.exports.useMemo(() => {
|
|
60970
|
+
const filledState = {};
|
|
60971
|
+
fields && Object.keys(fields || {}).map((key2) => {
|
|
60972
|
+
var _a2;
|
|
60973
|
+
return filledState[key2] = user2[key2] || ((_a2 = user2 == null ? void 0 : user2.credentials) == null ? void 0 : _a2[key2]) || "";
|
|
60974
|
+
});
|
|
60975
|
+
return filledState;
|
|
60976
|
+
}, [fields, user2]);
|
|
60968
60977
|
react.exports.useEffect(() => {
|
|
60969
60978
|
axios.get("https://ipapi.co/json/").then((data2) => {
|
|
60970
60979
|
const {
|
|
@@ -61014,7 +61023,8 @@ const Offline = react.exports.memo(({
|
|
|
61014
61023
|
account,
|
|
61015
61024
|
date: date4,
|
|
61016
61025
|
time: time2,
|
|
61017
|
-
reason: reason2
|
|
61026
|
+
reason: reason2,
|
|
61027
|
+
mobile
|
|
61018
61028
|
}, {
|
|
61019
61029
|
resetForm
|
|
61020
61030
|
}) => {
|
|
@@ -61072,7 +61082,7 @@ const Offline = react.exports.memo(({
|
|
|
61072
61082
|
autoClose: 2e3
|
|
61073
61083
|
});
|
|
61074
61084
|
}
|
|
61075
|
-
}, [country, latitude, longitude, location2, ipAddress, calendar2,
|
|
61085
|
+
}, [country, latitude, longitude, location2, ipAddress, calendar2, timezone2, continent, recordingBlob, clearRecording]);
|
|
61076
61086
|
const {
|
|
61077
61087
|
handleSubmit,
|
|
61078
61088
|
handleChange,
|
|
@@ -61083,7 +61093,9 @@ const Offline = react.exports.memo(({
|
|
|
61083
61093
|
} = useFormik({
|
|
61084
61094
|
initialValues: {
|
|
61085
61095
|
company: company_id,
|
|
61086
|
-
|
|
61096
|
+
...emptyFields,
|
|
61097
|
+
email: user2 == null ? void 0 : user2.email,
|
|
61098
|
+
full_name: (user2 == null ? void 0 : user2.name) || ((user2 == null ? void 0 : user2.first_name) || "") + " " + ((user2 == null ? void 0 : user2.last_name) || ""),
|
|
61087
61099
|
reason: calendar2 == null ? void 0 : calendar2.reason,
|
|
61088
61100
|
...calendar2 ? {
|
|
61089
61101
|
date: hooks(calendar2 == null ? void 0 : calendar2.scheduledAt).format("yyyy-MM-DD"),
|
|
@@ -61100,9 +61112,9 @@ const Offline = react.exports.memo(({
|
|
|
61100
61112
|
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
61101
61113
|
setState({
|
|
61102
61114
|
full_name: (((_a2 = calendar2 == null ? void 0 : calendar2.customer) == null ? void 0 : _a2.first_name) || "") + " " + (((_b2 = calendar2 == null ? void 0 : calendar2.customer) == null ? void 0 : _b2.last_name) || "") || "",
|
|
61103
|
-
email:
|
|
61104
|
-
mobile: ((_d2 = (_c2 = calendar2 == null ? void 0 : calendar2.customer) == null ? void 0 : _c2.credentials) == null ? void 0 : _d2.mobile) || (
|
|
61105
|
-
account: ((_f2 = (_e2 = calendar2 == null ? void 0 : calendar2.customer) == null ? void 0 : _e2.credentials) == null ? void 0 : _f2.account) || (
|
|
61115
|
+
email: user2 == null ? void 0 : user2.email,
|
|
61116
|
+
mobile: ((_d2 = (_c2 = calendar2 == null ? void 0 : calendar2.customer) == null ? void 0 : _c2.credentials) == null ? void 0 : _d2.mobile) || (user2 == null ? void 0 : user2.mobile),
|
|
61117
|
+
account: ((_f2 = (_e2 = calendar2 == null ? void 0 : calendar2.customer) == null ? void 0 : _e2.credentials) == null ? void 0 : _f2.account) || (user2 == null ? void 0 : user2.account),
|
|
61106
61118
|
date: (calendar2 == null ? void 0 : calendar2.scheduledAt) ? hooks(calendar2 == null ? void 0 : calendar2.scheduledAt).format("yyyy-MM-DD") : "",
|
|
61107
61119
|
time: (calendar2 == null ? void 0 : calendar2.scheduledAt) ? hooks(calendar2 == null ? void 0 : calendar2.scheduledAt).format("HH:mm") : "",
|
|
61108
61120
|
reason: (calendar2 == null ? void 0 : calendar2.reason) || "",
|
|
@@ -61137,7 +61149,7 @@ const Offline = react.exports.memo(({
|
|
|
61137
61149
|
}), /* @__PURE__ */ jsx(FInput, {
|
|
61138
61150
|
label: "Email",
|
|
61139
61151
|
name: "email",
|
|
61140
|
-
disabled: !!(
|
|
61152
|
+
disabled: !!(user2 == null ? void 0 : user2.email),
|
|
61141
61153
|
placeholder: "Example@gmail.com",
|
|
61142
61154
|
style: {
|
|
61143
61155
|
borderRadius: 50,
|
|
@@ -61167,21 +61179,20 @@ const Offline = react.exports.memo(({
|
|
|
61167
61179
|
}), /* @__PURE__ */ jsx(InputGroup$1, {
|
|
61168
61180
|
className: "mt-n3",
|
|
61169
61181
|
children: /* @__PURE__ */ jsx(PhoneInput$1, {
|
|
61170
|
-
country: country_code.toLowerCase(),
|
|
61182
|
+
country: country_code.toLowerCase() || "ng",
|
|
61171
61183
|
style: {
|
|
61172
61184
|
borderRadius: 50,
|
|
61173
61185
|
fontSize: 16
|
|
61174
61186
|
},
|
|
61175
61187
|
placeholder: "Enter Phone No",
|
|
61176
|
-
value: mobile,
|
|
61188
|
+
value: values.mobile,
|
|
61177
61189
|
inputProps: {
|
|
61178
61190
|
name: "mobile",
|
|
61179
|
-
required: true
|
|
61191
|
+
required: true,
|
|
61192
|
+
onBlur: handleBlur
|
|
61180
61193
|
},
|
|
61181
61194
|
enableSearch: true,
|
|
61182
|
-
onChange: (
|
|
61183
|
-
mobile: mobile2
|
|
61184
|
-
})
|
|
61195
|
+
onChange: (value2) => handleChange("mobile")(value2)
|
|
61185
61196
|
})
|
|
61186
61197
|
}), errors.mobile ? /* @__PURE__ */ jsx(FormFeedback$1, {
|
|
61187
61198
|
invalid: true,
|
|
@@ -61510,8 +61521,10 @@ function WidgetInitForm({
|
|
|
61510
61521
|
setState: setParentState,
|
|
61511
61522
|
setIsScheduling,
|
|
61512
61523
|
fields,
|
|
61513
|
-
widgetColor
|
|
61524
|
+
widgetColor,
|
|
61525
|
+
customer
|
|
61514
61526
|
}) {
|
|
61527
|
+
const user2 = (customer == null ? void 0 : customer.email) ? customer : companyUser;
|
|
61515
61528
|
const [{
|
|
61516
61529
|
ipAddress,
|
|
61517
61530
|
country,
|
|
@@ -61531,7 +61544,6 @@ function WidgetInitForm({
|
|
|
61531
61544
|
continent: void 0,
|
|
61532
61545
|
timezone: void 0
|
|
61533
61546
|
});
|
|
61534
|
-
const [mobile, setMobile] = useState("");
|
|
61535
61547
|
const validSchema = react.exports.useMemo(() => {
|
|
61536
61548
|
const shape = {
|
|
61537
61549
|
name: create$4().min(3).required(),
|
|
@@ -61540,9 +61552,10 @@ function WidgetInitForm({
|
|
|
61540
61552
|
};
|
|
61541
61553
|
const possibleShape = {
|
|
61542
61554
|
account: create$3().required().min(10).positive(),
|
|
61543
|
-
bvn: create$3().required().min(11).positive()
|
|
61555
|
+
bvn: create$3().required().min(11).positive(),
|
|
61556
|
+
mobile: create$3().required().min(5).positive()
|
|
61544
61557
|
};
|
|
61545
|
-
const fieldKeys = ["account", "bvn"];
|
|
61558
|
+
const fieldKeys = ["account", "bvn", "mobile"];
|
|
61546
61559
|
fieldKeys.map((key2) => {
|
|
61547
61560
|
var _a, _b;
|
|
61548
61561
|
if (((_a = fields == null ? void 0 : fields[key2]) == null ? void 0 : _a.show) || ((_b = fields == null ? void 0 : fields[key2]) == null ? void 0 : _b.show) === void 0) {
|
|
@@ -61551,6 +61564,14 @@ function WidgetInitForm({
|
|
|
61551
61564
|
});
|
|
61552
61565
|
return create$1().shape(shape);
|
|
61553
61566
|
}, [fields]);
|
|
61567
|
+
const emptyFields = react.exports.useMemo(() => {
|
|
61568
|
+
const filledState = {};
|
|
61569
|
+
fields && Object.keys(fields || {}).map((key2) => {
|
|
61570
|
+
var _a;
|
|
61571
|
+
return filledState[key2] = user2[key2] || ((_a = user2 == null ? void 0 : user2.credentials) == null ? void 0 : _a[key2]) || "";
|
|
61572
|
+
});
|
|
61573
|
+
return filledState;
|
|
61574
|
+
}, [fields, user2]);
|
|
61554
61575
|
react.exports.useEffect(() => {
|
|
61555
61576
|
axios.get("https://ipapi.co/json/").then((data2) => {
|
|
61556
61577
|
const {
|
|
@@ -61595,7 +61616,8 @@ function WidgetInitForm({
|
|
|
61595
61616
|
name,
|
|
61596
61617
|
email: email2,
|
|
61597
61618
|
message,
|
|
61598
|
-
|
|
61619
|
+
mobile,
|
|
61620
|
+
...emptyFields2
|
|
61599
61621
|
}) => {
|
|
61600
61622
|
var _a, _b;
|
|
61601
61623
|
const phoneNumberRegex = /^[0-9]{1,4}[-\s]?[0-9]{6,12}$/;
|
|
@@ -61617,9 +61639,9 @@ function WidgetInitForm({
|
|
|
61617
61639
|
email: email2,
|
|
61618
61640
|
credentials: mobile ? {
|
|
61619
61641
|
mobile,
|
|
61620
|
-
...
|
|
61642
|
+
...emptyFields2
|
|
61621
61643
|
} : {
|
|
61622
|
-
...
|
|
61644
|
+
...emptyFields2
|
|
61623
61645
|
},
|
|
61624
61646
|
message,
|
|
61625
61647
|
company: company_id,
|
|
@@ -61643,7 +61665,7 @@ function WidgetInitForm({
|
|
|
61643
61665
|
onSuccess: async ({
|
|
61644
61666
|
status,
|
|
61645
61667
|
...data2
|
|
61646
|
-
}) => {
|
|
61668
|
+
} = {}) => {
|
|
61647
61669
|
if (status) {
|
|
61648
61670
|
dataRef.current = data2;
|
|
61649
61671
|
setParentState({
|
|
@@ -61658,11 +61680,10 @@ function WidgetInitForm({
|
|
|
61658
61680
|
validationSchema: validSchema,
|
|
61659
61681
|
onSubmit: mutate,
|
|
61660
61682
|
initialValues: {
|
|
61661
|
-
|
|
61662
|
-
|
|
61663
|
-
bvn: companyUser == null ? void 0 : companyUser.bvn,
|
|
61683
|
+
...emptyFields,
|
|
61684
|
+
email: user2 == null ? void 0 : user2.email,
|
|
61664
61685
|
message: "",
|
|
61665
|
-
name: ""
|
|
61686
|
+
name: (user2 == null ? void 0 : user2.name) || ((user2 == null ? void 0 : user2.first_name) || "") + " " + ((user2 == null ? void 0 : user2.last_name) || "")
|
|
61666
61687
|
},
|
|
61667
61688
|
children: (formik) => /* @__PURE__ */ jsxs(Form$2, {
|
|
61668
61689
|
onSubmit: formik.handleSubmit,
|
|
@@ -61719,15 +61740,16 @@ function WidgetInitForm({
|
|
|
61719
61740
|
}), /* @__PURE__ */ jsx(InputGroup$1, {
|
|
61720
61741
|
className: "mt-n3",
|
|
61721
61742
|
children: /* @__PURE__ */ jsx(PhoneInput, {
|
|
61722
|
-
country: country_code == null ? void 0 : country_code.toLowerCase(),
|
|
61743
|
+
country: (country_code == null ? void 0 : country_code.toLowerCase()) || "ng",
|
|
61723
61744
|
placeholder: fields[key2].placeholder || `Enter ${key2}`,
|
|
61724
|
-
value:
|
|
61745
|
+
value: formik.values[key2],
|
|
61725
61746
|
inputProps: {
|
|
61726
61747
|
name: key2,
|
|
61727
|
-
|
|
61748
|
+
defaultValue: formik.values[key2],
|
|
61749
|
+
onBlur: formik.handleBlur
|
|
61728
61750
|
},
|
|
61729
61751
|
enableSearch: true,
|
|
61730
|
-
onChange:
|
|
61752
|
+
onChange: (value2) => formik.handleChange(key2)(value2)
|
|
61731
61753
|
})
|
|
61732
61754
|
}), formik.errors[key2] ? /* @__PURE__ */ jsx(FormFeedback$1, {
|
|
61733
61755
|
invalid: true,
|
|
@@ -68055,7 +68077,8 @@ const IncomingVideoCallModal = react.exports.memo(({
|
|
|
68055
68077
|
style: {
|
|
68056
68078
|
color: "#FF0000",
|
|
68057
68079
|
fontStyle: "italic",
|
|
68058
|
-
fontSize: 13
|
|
68080
|
+
fontSize: 13,
|
|
68081
|
+
margin: "20px auto"
|
|
68059
68082
|
},
|
|
68060
68083
|
children: "Call may be recorded"
|
|
68061
68084
|
})]
|
|
@@ -68305,7 +68328,8 @@ function UnwrapWidget({
|
|
|
68305
68328
|
loadOnMount: !!company_id
|
|
68306
68329
|
}, [company_id]);
|
|
68307
68330
|
const {
|
|
68308
|
-
hex_code
|
|
68331
|
+
hex_code,
|
|
68332
|
+
tooltip_message
|
|
68309
68333
|
} = company;
|
|
68310
68334
|
const companyIsClosed = react.exports.useMemo(() => {
|
|
68311
68335
|
if (!isLoadingCompany && (company == null ? void 0 : company.name)) {
|
|
@@ -68375,7 +68399,7 @@ function UnwrapWidget({
|
|
|
68375
68399
|
width: 240,
|
|
68376
68400
|
fontWeight: 600
|
|
68377
68401
|
},
|
|
68378
|
-
children:
|
|
68402
|
+
children: tooltip_message
|
|
68379
68403
|
})]
|
|
68380
68404
|
})]
|
|
68381
68405
|
})]
|
|
@@ -68467,7 +68491,8 @@ const WidgetFormDisplay = react.exports.memo(({
|
|
|
68467
68491
|
} = await getWaitList({
|
|
68468
68492
|
status: "waiting",
|
|
68469
68493
|
orderBy: "createdAt",
|
|
68470
|
-
order: "ASC"
|
|
68494
|
+
order: "ASC",
|
|
68495
|
+
limit: 1e3
|
|
68471
68496
|
});
|
|
68472
68497
|
const position2 = data22.findIndex((waitlist) => {
|
|
68473
68498
|
var _a2, _b2;
|
|
@@ -68592,6 +68617,8 @@ const WidgetFormDisplay = react.exports.memo(({
|
|
|
68592
68617
|
hexcode: company == null ? void 0 : company.hex_code
|
|
68593
68618
|
}) : companyClosed ? /* @__PURE__ */ jsx(Offline, {
|
|
68594
68619
|
companyUser,
|
|
68620
|
+
customer,
|
|
68621
|
+
fields: company == null ? void 0 : company.fields,
|
|
68595
68622
|
company_id,
|
|
68596
68623
|
calendar: calendar2,
|
|
68597
68624
|
hexcode: company == null ? void 0 : company.hex_code,
|
|
@@ -68666,7 +68693,8 @@ const ChatMode = react.exports.memo(({
|
|
|
68666
68693
|
setState,
|
|
68667
68694
|
setIsScheduling,
|
|
68668
68695
|
fields: company == null ? void 0 : company.fields,
|
|
68669
|
-
widgetColor: company == null ? void 0 : company.hex_code
|
|
68696
|
+
widgetColor: company == null ? void 0 : company.hex_code,
|
|
68697
|
+
customer
|
|
68670
68698
|
}) : /* @__PURE__ */ jsx(ChatWidgetScreen$1, {
|
|
68671
68699
|
welcome_message: company == null ? void 0 : company.welcome_message,
|
|
68672
68700
|
dataRef,
|