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,7 +53,9 @@ export const TypebotsDropdown = ({
label: 'Current typebot', label: 'Current typebot',
value: 'Current typebot', value: 'Current typebot',
}, },
...(typebots ?? []).map((typebot) => ({ ...(typebots ?? [])
.filter((typebot) => !idsToExclude.includes(typebot.id))
.map((typebot) => ({
value: typebot.name, value: typebot.name,
label: ( label: (
<HStack as="span" spacing="2"> <HStack as="span" spacing="2">