fix: typebot e chatwoot booleans

This commit is contained in:
Gabriel Pastori 2023-11-22 10:40:22 -03:00
parent 6567fc7db0
commit 9d3dc85522
3 changed files with 36 additions and 9 deletions

View File

@ -148,6 +148,17 @@
import ChatwootConfig from "@/components/modal/ChatwootConfig.vue";
import instanceController from "@/services/instanceController";
const defaultObj = () => ({
enabled: false,
url: "",
account_id: "",
token: "",
sign_msg: true,
reopen_conversation: true,
conversation_pending: false,
});
export default {
name: "InstanceChatwoot",
props: {
@ -213,8 +224,8 @@ export default {
const chatwootData = await instanceController.chatwoot.get(
this.instance.instance.instanceName
);
this.chatwootData = Object.assign({}, chatwootData || {});
this.defaultChatwootData = Object.assign({}, chatwootData || {});
this.chatwootData = Object.assign(defaultObj(), chatwootData || {});
this.defaultChatwootData = Object.assign(defaultObj(), chatwootData || {});
} catch (e) {
this.error = e.message?.message || e.message || e;
} finally {

View File

@ -183,6 +183,17 @@
<script>
import instanceController from "@/services/instanceController";
const defaultObj = () => ({
enabled: false,
expire: 0,
delay_message: 0,
listening_from_me: false,
sessions: [],
typebot: "",
url: "",
keyword_finish: "",
unknown_message: "",
});
export default {
name: "InstanceTypebot",
@ -237,9 +248,10 @@ export default {
url: this.typebotData.url.trim().replace(/\/$/, ""),
delay_message: parseInt(this.typebotData.delay_message),
expire: parseInt(this.typebotData.expire),
listening_from_me: !!this.typebotData.listening_from_me,
}
);
this.defaultTypebotData = Object.assign({}, this.typebotData);
this.defaultTypebotData = Object.assign(defaultObj(), this.typebotData);
} catch (e) {
this.error = e.message?.message || e.message || e;
} finally {
@ -255,8 +267,8 @@ export default {
this.instance.instance.instanceName
);
this.typebotData = Object.assign({}, typebotData);
this.defaultTypebotData = Object.assign({}, typebotData);
this.typebotData = Object.assign(defaultObj(), typebotData);
this.defaultTypebotData = Object.assign(defaultObj(), typebotData);
} catch (e) {
this.error = e.message?.message || e.message || e;
} finally {

View File

@ -55,13 +55,17 @@
<p><b>Passo 5:</b> Pronto! Agora você pode receber mensagens.</p>
<v-img src="@/assets/chatwoot/chatwoot_api_3.png" />
<!-- Add link to chatwoot doc -->
<!-- Add link to chatwoot doc -->
<!-- https://www.chatwoot.com/docs/product/channels/api/create-channel -->
<v-btn size="small" variant="text" block href="https://www.chatwoot.com/docs/product/channels/api/create-channel" target="_blank">
<v-btn
size="small"
variant="text"
block
href="https://www.chatwoot.com/docs/product/channels/api/create-channel"
target="_blank"
>
Ver documentação completa
</v-btn>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>