2
0

🚸 (typebotLink) Exclude current bot name from select list

This commit is contained in:
Baptiste Arnaud
2023-02-17 11:27:57 +01:00
parent 4a0dd0b3dd
commit 962438768e
2 changed files with 18 additions and 13 deletions

View File

@ -22,6 +22,7 @@ export const TypebotLinkForm = ({ options, onOptionsChange }: Props) => {
<Stack> <Stack>
{typebot && ( {typebot && (
<TypebotsDropdown <TypebotsDropdown
idsToExclude={[typebot.id]}
typebotId={options.typebotId} typebotId={options.typebotId}
onSelectTypebotId={handleTypebotIdChange} onSelectTypebotId={handleTypebotIdChange}
currentWorkspaceId={typebot.workspaceId as string} currentWorkspaceId={typebot.workspaceId as string}

View File

@ -10,12 +10,14 @@ import { SearchableDropdown } from '@/components/SearchableDropdown'
import { EmojiOrImageIcon } from '@/components/EmojiOrImageIcon' import { EmojiOrImageIcon } from '@/components/EmojiOrImageIcon'
type Props = { type Props = {
idsToExclude: string[]
typebotId?: string | 'current' typebotId?: string | 'current'
currentWorkspaceId: string currentWorkspaceId: string
onSelectTypebotId: (typebotId: string | 'current') => void onSelectTypebotId: (typebotId: string | 'current') => void
} }
export const TypebotsDropdown = ({ export const TypebotsDropdown = ({
idsToExclude,
typebotId, typebotId,
onSelectTypebotId, onSelectTypebotId,
currentWorkspaceId, currentWorkspaceId,
@ -51,19 +53,21 @@ export const TypebotsDropdown = ({
label: 'Current typebot', label: 'Current typebot',
value: 'Current typebot', value: 'Current typebot',
}, },
...(typebots ?? []).map((typebot) => ({ ...(typebots ?? [])
value: typebot.name, .filter((typebot) => !idsToExclude.includes(typebot.id))
label: ( .map((typebot) => ({
<HStack as="span" spacing="2"> value: typebot.name,
<EmojiOrImageIcon label: (
icon={typebot.icon} <HStack as="span" spacing="2">
boxSize="18px" <EmojiOrImageIcon
emojiFontSize="18px" icon={typebot.icon}
/> boxSize="18px"
<Text>{typebot.name}</Text> emojiFontSize="18px"
</HStack> />
), <Text>{typebot.name}</Text>
})), </HStack>
),
})),
]} ]}
onValueChange={handleTypebotSelect} onValueChange={handleTypebotSelect}
placeholder={'Select a typebot'} placeholder={'Select a typebot'}