feat(editor): ♿️ Add 'Current' to Link typebot
This commit is contained in:
@ -23,6 +23,7 @@ export const BlocksDropdown = ({
|
||||
)
|
||||
|
||||
const handleBlockSelect = (title: string) => {
|
||||
console.log(title)
|
||||
const id = blocks?.find((b) => b.title === title)?.id
|
||||
if (id) onBlockIdSelected(id)
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ export const TypebotLinkSettingsForm = ({
|
||||
}: Props) => {
|
||||
const { linkedTypebots, typebot } = useTypebot()
|
||||
|
||||
const handleTypebotIdChange = (typebotId: string) =>
|
||||
const handleTypebotIdChange = (typebotId: string | 'current') =>
|
||||
onOptionsChange({ ...options, typebotId })
|
||||
const handleBlockIdChange = (blockId: string) =>
|
||||
onOptionsChange({ ...options, blockId })
|
||||
@ -29,7 +29,8 @@ export const TypebotLinkSettingsForm = ({
|
||||
/>
|
||||
<BlocksDropdown
|
||||
blocks={
|
||||
typebot && options.typebotId === typebot.id
|
||||
typebot &&
|
||||
(options.typebotId === typebot.id || options.typebotId === 'current')
|
||||
? typebot.blocks
|
||||
: linkedTypebots?.find(byId(options.typebotId))?.blocks ?? []
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import { byId } from 'utils'
|
||||
|
||||
type Props = {
|
||||
typebotId?: string
|
||||
onSelectTypebotId: (typebotId: string) => void
|
||||
onSelectTypebotId: (typebotId: string | 'current') => void
|
||||
}
|
||||
|
||||
export const TypebotsDropdown = ({ typebotId, onSelectTypebotId }: Props) => {
|
||||
@ -28,6 +28,7 @@ export const TypebotsDropdown = ({ typebotId, onSelectTypebotId }: Props) => {
|
||||
)
|
||||
|
||||
const handleTypebotSelect = (name: string) => {
|
||||
if (name === 'Current typebot') return onSelectTypebotId('current')
|
||||
const id = typebots?.find((s) => s.name === name)?.id
|
||||
if (id) onSelectTypebotId(id)
|
||||
}
|
||||
@ -39,7 +40,7 @@ export const TypebotsDropdown = ({ typebotId, onSelectTypebotId }: Props) => {
|
||||
<HStack>
|
||||
<SearchableDropdown
|
||||
selectedItem={currentTypebot?.name}
|
||||
items={(typebots ?? []).map((t) => t.name)}
|
||||
items={['Current typebot', ...(typebots ?? []).map((t) => t.name)]}
|
||||
onValueChange={handleTypebotSelect}
|
||||
placeholder={'Select a typebot'}
|
||||
/>
|
||||
|
Reference in New Issue
Block a user