From f020995cbd4dc78c6bd4c51b75b191ceb4bd4b90 Mon Sep 17 00:00:00 2001 From: Murilo Oliveira Date: Mon, 3 Nov 2025 14:17:50 -0300 Subject: [PATCH 1/7] fix: using id to validade contact --- .../bodies/ConditionSettingsBody/ComparisonsItem.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/builder/components/shared/Graph/Nodes/StepNode/SettingsPopoverContent/bodies/ConditionSettingsBody/ComparisonsItem.tsx b/apps/builder/components/shared/Graph/Nodes/StepNode/SettingsPopoverContent/bodies/ConditionSettingsBody/ComparisonsItem.tsx index 4c2a593f38..4fc14660f2 100644 --- a/apps/builder/components/shared/Graph/Nodes/StepNode/SettingsPopoverContent/bodies/ConditionSettingsBody/ComparisonsItem.tsx +++ b/apps/builder/components/shared/Graph/Nodes/StepNode/SettingsPopoverContent/bodies/ConditionSettingsBody/ComparisonsItem.tsx @@ -215,8 +215,8 @@ export const ComparisonItem = ({ if (myVariable?.token === '#status-do-contato') { const basicOptions = [ - { key: 0, value: 'Lead', label: 'Lead' }, - { key: 1, value: 'Cliente', label: 'Cliente' } + { key: 0, value: '724d3f8a-867c-4c82-ab7a-84342bfe147d', label: 'Lead' }, + { key: 1, value: 'd6770ab0-251c-47b3-85c5-d0b66eae4812', label: 'Cliente' } ] return ( From d36ec3fbc7208e1dfcd2cd1eb7b6d165edd8e4e7 Mon Sep 17 00:00:00 2001 From: Murilo Oliveira Date: Thu, 6 Nov 2025 15:04:18 -0300 Subject: [PATCH 2/7] fix: using label --- .../contents/ConditionNodeContent.tsx | 14 +++++++++++++- .../ConditionSettingsBody/ComparisonsItem.tsx | 8 ++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx b/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx index 6463f86543..355f58b7f1 100644 --- a/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx +++ b/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx @@ -13,6 +13,10 @@ import { byIdOrToken, isNotDefined } from 'utils' type Props = { item: ConditionItem } +export const basicOptions = [ + { key: 0, value: '724d3f8a-867c-4c82-ab7a-84342bfe147d', label: 'Lead' }, + { key: 1, value: 'd6770ab0-251c-47b3-85c5-d0b66eae4812', label: 'Cliente' } +] export const ConditionNodeContent = ({ item }: Props) => { const { typebot, customVariables } = useTypebot() @@ -22,7 +26,15 @@ export const ConditionNodeContent = ({ item }: Props) => { comparison: Comparison ) => { if (variable?.token === '#status-do-contato') { - return comparison.value + if (comparison.value === basicOptions[0].value) { + return basicOptions[0].label + } + if (comparison.value === basicOptions[1].value) { + return basicOptions[1].label + } + else { + return comparison.value + } } if (variable?.type !== 'select' || !variable) return comparison.value diff --git a/apps/builder/components/shared/Graph/Nodes/StepNode/SettingsPopoverContent/bodies/ConditionSettingsBody/ComparisonsItem.tsx b/apps/builder/components/shared/Graph/Nodes/StepNode/SettingsPopoverContent/bodies/ConditionSettingsBody/ComparisonsItem.tsx index 4fc14660f2..bb64b44194 100644 --- a/apps/builder/components/shared/Graph/Nodes/StepNode/SettingsPopoverContent/bodies/ConditionSettingsBody/ComparisonsItem.tsx +++ b/apps/builder/components/shared/Graph/Nodes/StepNode/SettingsPopoverContent/bodies/ConditionSettingsBody/ComparisonsItem.tsx @@ -8,6 +8,8 @@ import { Comparison, Variable, ComparisonOperators } from 'models' import { useTypebot } from 'contexts/TypebotContext' import { useEffect, useState } from 'react' import CustomFields from 'services/octadesk/customFields/customFields' +import { basicOptions } from 'components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent' + export const ComparisonItem = ({ item, @@ -185,6 +187,8 @@ export const ComparisonItem = ({ onItemChange({ ...item, secondaryValue: undefined }) }, [needSecondaryValue]) + + const typeOfInputValue = () => { const onSelect = (e: React.ChangeEvent) => { handleChangeValue(e.target.value) @@ -214,10 +218,6 @@ export const ComparisonItem = ({ } if (myVariable?.token === '#status-do-contato') { - const basicOptions = [ - { key: 0, value: '724d3f8a-867c-4c82-ab7a-84342bfe147d', label: 'Lead' }, - { key: 1, value: 'd6770ab0-251c-47b3-85c5-d0b66eae4812', label: 'Cliente' } - ] return ( Date: Tue, 11 Nov 2025 09:41:23 -0300 Subject: [PATCH 5/7] fix: using enum --- .../contents/ConditionNodeContent.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx b/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx index 355f58b7f1..7f44c604d2 100644 --- a/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx +++ b/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx @@ -13,9 +13,14 @@ import { byIdOrToken, isNotDefined } from 'utils' type Props = { item: ConditionItem } + +export enum ContactStatus { + LEAD = '724d3f8a-867c-4c82-ab7a-84342bfe147d', + CLIENT = 'd6770ab0-251c-47b3-85c5-d0b66eae4812', +} export const basicOptions = [ - { key: 0, value: '724d3f8a-867c-4c82-ab7a-84342bfe147d', label: 'Lead' }, - { key: 1, value: 'd6770ab0-251c-47b3-85c5-d0b66eae4812', label: 'Cliente' } + { key: 0, value: ContactStatus.LEAD, label: 'Lead' }, + { key: 1, value: ContactStatus.CLIENT, label: 'Cliente' } ] export const ConditionNodeContent = ({ item }: Props) => { @@ -26,10 +31,10 @@ export const ConditionNodeContent = ({ item }: Props) => { comparison: Comparison ) => { if (variable?.token === '#status-do-contato') { - if (comparison.value === basicOptions[0].value) { + if (comparison.value === ContactStatus.LEAD) { return basicOptions[0].label } - if (comparison.value === basicOptions[1].value) { + if (comparison.value === ContactStatus.CLIENT) { return basicOptions[1].label } else { From 405e4acd278848883d8195c6dc30b0040b5290b5 Mon Sep 17 00:00:00 2001 From: Murilo Oliveira Date: Thu, 13 Nov 2025 10:30:53 -0300 Subject: [PATCH 6/7] fix: using person request --- .../contents/ConditionNodeContent.tsx | 32 ++++++++++++------- .../services/octadesk/persons/persons.ts | 25 +++++++++++++++ .../octadesk/persons/types.persons.ts | 3 ++ 3 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 apps/builder/services/octadesk/persons/persons.ts create mode 100644 apps/builder/services/octadesk/persons/types.persons.ts diff --git a/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx b/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx index 7f44c604d2..80f5204f76 100644 --- a/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx +++ b/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx @@ -10,18 +10,25 @@ import { import React from 'react' import { byIdOrToken, isNotDefined } from 'utils' +import { Persons } from 'services/octadesk/persons/persons' + type Props = { item: ConditionItem } -export enum ContactStatus { - LEAD = '724d3f8a-867c-4c82-ab7a-84342bfe147d', - CLIENT = 'd6770ab0-251c-47b3-85c5-d0b66eae4812', -} -export const basicOptions = [ - { key: 0, value: ContactStatus.LEAD, label: 'Lead' }, - { key: 1, value: ContactStatus.CLIENT, label: 'Cliente' } -] +type BasicOption = { key: number; value: string; label: string } + +export let basicOptions: BasicOption[] = [] + + ; (async () => { + const { getStatusContact } = Persons() + const ContactStatus = await getStatusContact() + + basicOptions = [ + { key: 0, value: ContactStatus.Lead, label: 'Lead' }, + { key: 1, value: ContactStatus.Cliente, label: 'Cliente' } + ] + })() export const ConditionNodeContent = ({ item }: Props) => { const { typebot, customVariables } = useTypebot() @@ -31,11 +38,12 @@ export const ConditionNodeContent = ({ item }: Props) => { comparison: Comparison ) => { if (variable?.token === '#status-do-contato') { - if (comparison.value === ContactStatus.LEAD) { - return basicOptions[0].label + if (comparison.value === basicOptions[0].value + ) { + return basicOptions[0].value } - if (comparison.value === ContactStatus.CLIENT) { - return basicOptions[1].label + if (comparison.value === basicOptions[1].value) { + return basicOptions[1].value } else { return comparison.value diff --git a/apps/builder/services/octadesk/persons/persons.ts b/apps/builder/services/octadesk/persons/persons.ts new file mode 100644 index 0000000000..36c62e96ff --- /dev/null +++ b/apps/builder/services/octadesk/persons/persons.ts @@ -0,0 +1,25 @@ +import { getBaseClient } from '../http' +import { loadParameterHeader } from '../helpers/headers' +import { PersonsServicesInterface } from './types.persons' + +const getPersonsClient = () => getBaseClient('persons') + +export const Persons = (): PersonsServicesInterface => { + + const getStatusContact = async (): Promise> => { + const client = await getPersonsClient() + client.defaults.baseURL = client.defaults.baseURL?.replace('/api', '') || '' + const res = await client.get('contact-status', loadParameterHeader()); + const data = res.data; + + const ContactStatus = Object.fromEntries( + data.map((item: any) => [item.name, item.id]) + ); + + return ContactStatus; + }; + + return { getStatusContact } +} + +export default Persons \ No newline at end of file diff --git a/apps/builder/services/octadesk/persons/types.persons.ts b/apps/builder/services/octadesk/persons/types.persons.ts new file mode 100644 index 0000000000..652d1b4b6d --- /dev/null +++ b/apps/builder/services/octadesk/persons/types.persons.ts @@ -0,0 +1,3 @@ +export interface PersonsServicesInterface { + getStatusContact: () => Promise +} \ No newline at end of file From 0249f9ecfccc88ca8c0dff535fdc908a304ef57f Mon Sep 17 00:00:00 2001 From: Murilo Oliveira Date: Thu, 13 Nov 2025 10:44:17 -0300 Subject: [PATCH 7/7] fix: using basicOptions.label --- .../ItemNodeContent/contents/ConditionNodeContent.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx b/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx index 80f5204f76..75fe4ef1be 100644 --- a/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx +++ b/apps/builder/components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent.tsx @@ -40,10 +40,10 @@ export const ConditionNodeContent = ({ item }: Props) => { if (variable?.token === '#status-do-contato') { if (comparison.value === basicOptions[0].value ) { - return basicOptions[0].value + return basicOptions[0].label } if (comparison.value === basicOptions[1].value) { - return basicOptions[1].value + return basicOptions[1].label } else { return comparison.value