<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit - Refactor: Transitioned to a new translation library (`@tolgee/react`) across the application, enhancing the localization capabilities and consistency. - New Feature: Introduced a JSON configuration file for application settings, improving customization and flexibility. - Refactor: Updated SVG attribute naming convention in the `WhatsAppLogo` component to align with React standards. - Chore: Adjusted the `.gitignore` file and added a new line at the end. - Documentation: Added instructions for setting up environment variables for the Tolgee i18n contribution dev tool, improving the self-hosting configuration guide. - Style: Updated the `CollaborationMenuButton` to hide the `PopoverContent` component by scaling it down to zero. - Refactor: Simplified error handling logic for fetching and updating typebots in `TypebotProvider.tsx`, improving code readability and maintenance. - Refactor: Removed the dependency on the `parseGroupTitle` function, simplifying the code in several components. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { Select } from '@/components/inputs/Select'
|
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
|
import { Stack } from '@chakra-ui/react'
|
|
import { JumpBlock } from '@typebot.io/schemas/features/blocks/logic/jump'
|
|
import React from 'react'
|
|
import { byId } from '@typebot.io/lib'
|
|
|
|
type Props = {
|
|
groupId: string
|
|
options: JumpBlock['options']
|
|
onOptionsChange: (options: JumpBlock['options']) => void
|
|
}
|
|
|
|
export const JumpSettings = ({ groupId, options, onOptionsChange }: Props) => {
|
|
const { typebot } = useTypebot()
|
|
|
|
const handleGroupIdChange = (groupId?: string) =>
|
|
onOptionsChange({ ...options, groupId })
|
|
|
|
const handleBlockIdChange = (blockId?: string) =>
|
|
onOptionsChange({ ...options, blockId })
|
|
|
|
const currentGroupId = typebot?.groups.find(byId(groupId))?.id
|
|
|
|
const selectedGroup = typebot?.groups.find(byId(options.groupId))
|
|
|
|
if (!typebot) return null
|
|
|
|
return (
|
|
<Stack spacing={4}>
|
|
<Select
|
|
items={typebot.groups
|
|
.filter((group) => group.id !== currentGroupId)
|
|
.map((group) => ({
|
|
label: group.title,
|
|
value: group.id,
|
|
}))}
|
|
selectedItem={selectedGroup?.id}
|
|
onSelect={handleGroupIdChange}
|
|
placeholder="Select a group"
|
|
/>
|
|
{selectedGroup && selectedGroup.blocks.length > 1 && (
|
|
<Select
|
|
selectedItem={options.blockId}
|
|
items={selectedGroup.blocks.map((block, index) => ({
|
|
label: `Block #${(index + 1).toString()}`,
|
|
value: block.id,
|
|
}))}
|
|
onSelect={handleBlockIdChange}
|
|
placeholder="Select a block"
|
|
/>
|
|
)}
|
|
</Stack>
|
|
)
|
|
}
|