Skip to content

Commit

Permalink
🚸 (typebotLink) Exclude current bot name from select list
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 17, 2023
1 parent 4a0dd0b commit 9624387
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'}
Expand Down

0 comments on commit 9624387

Please sign in to comment.