@sevenfold/setto-client 0.22.0 → 0.22.1
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/setto-client.js +5 -4
- package/dist/setto-client.js.map +1 -1
- package/package.json +1 -1
package/dist/setto-client.js
CHANGED
|
@@ -22060,6 +22060,7 @@ function contactTeam() {
|
|
|
22060
22060
|
function SettoChat() {
|
|
22061
22061
|
const { config } = useSetto();
|
|
22062
22062
|
const { i18n } = useTranslation();
|
|
22063
|
+
const apiUrl = config.apiUrl.replace(/\/+$/, "");
|
|
22063
22064
|
const [settings, setSettings] = useState(null);
|
|
22064
22065
|
const [open, setOpen] = useState(false);
|
|
22065
22066
|
const [messages, setMessages] = useState([]);
|
|
@@ -22076,7 +22077,7 @@ function SettoChat() {
|
|
|
22076
22077
|
useEffect(() => {
|
|
22077
22078
|
if (window.location.pathname.startsWith("/setto")) return;
|
|
22078
22079
|
let cancelled = false;
|
|
22079
|
-
fetch(`${
|
|
22080
|
+
fetch(`${apiUrl}/sites/${encodeURIComponent(config.siteId)}/chat/settings/public`, {
|
|
22080
22081
|
headers: { Accept: "application/json" }
|
|
22081
22082
|
}).then(async (response) => response.ok ? await response.json() : null).then((next) => {
|
|
22082
22083
|
if (!cancelled && next?.enabled) setSettings(next);
|
|
@@ -22085,7 +22086,7 @@ function SettoChat() {
|
|
|
22085
22086
|
return () => {
|
|
22086
22087
|
cancelled = true;
|
|
22087
22088
|
};
|
|
22088
|
-
}, [
|
|
22089
|
+
}, [apiUrl, config.siteId]);
|
|
22089
22090
|
useEffect(() => {
|
|
22090
22091
|
if (!open || messages.length > 0 || !settings) return;
|
|
22091
22092
|
setMessages([{ role: "assistant", content: intro(i18n.language, settings.displayName) }]);
|
|
@@ -22150,7 +22151,7 @@ function SettoChat() {
|
|
|
22150
22151
|
visitor.current ??= visitorId();
|
|
22151
22152
|
try {
|
|
22152
22153
|
const response = await fetch(
|
|
22153
|
-
`${
|
|
22154
|
+
`${apiUrl}/sites/${encodeURIComponent(config.siteId)}/chat/messages`,
|
|
22154
22155
|
{
|
|
22155
22156
|
method: "POST",
|
|
22156
22157
|
headers: { "Content-Type": "application/json", Accept: "text/plain, application/json" },
|
|
@@ -22200,7 +22201,7 @@ function SettoChat() {
|
|
|
22200
22201
|
}
|
|
22201
22202
|
setLeadStatus("sending");
|
|
22202
22203
|
try {
|
|
22203
|
-
const response = await fetch(`${
|
|
22204
|
+
const response = await fetch(`${apiUrl}/sites/${encodeURIComponent(config.siteId)}/chat/leads`, {
|
|
22204
22205
|
method: "POST",
|
|
22205
22206
|
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
22206
22207
|
body: JSON.stringify({
|