Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,26 @@ import {
import React from 'react'
import { byIdOrToken, isNotDefined } from 'utils'

import { Persons } from 'services/octadesk/persons/persons'

type Props = {
item: ConditionItem
}

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()

Expand All @@ -22,7 +38,16 @@ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useTypebot } from 'contexts/TypebotContext'
import { useEffect, useState } from 'react'
import CustomFields from 'services/octadesk/customFields/customFields'
import { CustomFieldTypes } from 'enums/customFieldsEnum'
import { basicOptions } from 'components/shared/Graph/Nodes/ItemNode/ItemNodeContent/contents/ConditionNodeContent'

export const ComparisonItem = ({
item,
Expand Down Expand Up @@ -120,10 +121,10 @@ export const ComparisonItem = ({
}

const resolveOperators = () => {
function isStringArray(){
function isStringArray() {
return Number(myVariable?.type) === CustomFieldTypes.Text || Number(myVariable?.type) === CustomFieldTypes.MultiText
}
function isNumberArray(){
function isNumberArray() {
return Number(myVariable?.type) === CustomFieldTypes.Numbers || Number(myVariable?.type) === CustomFieldTypes.Decimal || Number(myVariable?.type) === CustomFieldTypes.Date
}
const allTypesArray = [
Expand Down Expand Up @@ -191,6 +192,8 @@ export const ComparisonItem = ({
onItemChange({ ...item, secondaryValue: undefined })
}, [needSecondaryValue])



const typeOfInputValue = () => {
const onSelect = (e: React.ChangeEvent<HTMLSelectElement>) => {
handleChangeValue(e.target.value)
Expand Down Expand Up @@ -220,10 +223,6 @@ export const ComparisonItem = ({
}

if (myVariable?.token === '#status-do-contato') {
const basicOptions = [
{ key: 0, value: 'Lead', label: 'Lead' },
{ key: 1, value: 'Cliente', label: 'Cliente' }
]

return (
<Select
Expand Down
25 changes: 25 additions & 0 deletions apps/builder/services/octadesk/persons/persons.ts
Original file line number Diff line number Diff line change
@@ -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<Record<string, string>> => {
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
3 changes: 3 additions & 0 deletions apps/builder/services/octadesk/persons/types.persons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface PersonsServicesInterface {
getStatusContact: () => Promise<any>
}
Loading