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>
{typebot && (
<TypebotsDropdown
idsToExclude={[typebot.id]}
typebotId={options.typebotId}
onSelectTypebotId={handleTypebotIdChange}
currentWorkspaceId={typebot.workspaceId as string}

View File

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