💄 Fix groups dropdown displaying ID instead of title
Some checks failed
Create Tag / create-tag (push) Has been cancelled
Deploy Partykit server / deploy (push) Has been cancelled

This commit is contained in:
Baptiste Arnaud 2025-06-10 16:57:53 +02:00
parent 1e01d43219
commit 0ee75cf974
No known key found for this signature in database
3 changed files with 20 additions and 31 deletions

View File

@ -9,12 +9,11 @@ import React, { useMemo } from "react";
import { GroupsDropdown } from "../../typebotLink/components/GroupsDropdown";
type Props = {
groupId: string;
options: JumpBlock["options"];
onOptionsChange: (options: JumpBlock["options"]) => void;
};
export const JumpSettings = ({ groupId, options, onOptionsChange }: Props) => {
export const JumpSettings = ({ options, onOptionsChange }: Props) => {
const { typebot } = useTypebot();
const handleGroupIdChange = (groupId?: string) =>
@ -36,18 +35,19 @@ export const JumpSettings = ({ groupId, options, onOptionsChange }: Props) => {
groupId={options?.groupId}
onChange={handleGroupIdChange}
/>
{selectedGroup && selectedGroup.blocks.length > 1 && (
<Select
selectedItem={options?.blockId}
items={selectedGroup.blocks.map((block, index) => ({
label: `Block #${(index + 1).toString()}`,
value: block.id,
icon: <BlockIcon type={block.type} />,
}))}
onSelect={handleBlockIdChange}
placeholder="Select a block"
/>
)}
{selectedGroup &&
(selectedGroup.blocks.length > 1 || options?.blockId) && (
<Select
selectedItem={options?.blockId}
items={selectedGroup.blocks.map((block, index) => ({
label: `Block #${(index + 1).toString()}`,
value: block.id,
icon: <BlockIcon type={block.type} />,
}))}
onSelect={handleBlockIdChange}
placeholder="Select a block"
/>
)}
</Stack>
);
};

View File

@ -1,7 +1,6 @@
import { BasicSelect } from "@/components/inputs/BasicSelect";
import { Input } from "@chakra-ui/react";
import type { Group } from "@typebot.io/groups/schemas";
import { isNotEmpty } from "@typebot.io/lib/utils";
type Props = {
groups: Group[];
@ -21,12 +20,10 @@ export const GroupsDropdown = ({
return <Input value="No groups found" isDisabled />;
return (
<BasicSelect
items={groups
.filter((group) => group.id !== groupId && isNotEmpty(group.title))
.map((group) => ({
label: group.title,
value: group.id,
}))}
items={groups.map((group) => ({
label: group.title,
value: group.id,
}))}
defaultValue={groupId}
onChange={onChange}
placeholder="Select a group"

View File

@ -144,11 +144,9 @@ export const SettingsPopoverContent = ({ isOpen, ...props }: Props) => {
export const NodeSettings = ({
node,
groupId,
onNodeChange,
}: {
node: BlockWithOptions | TEventWithOptions;
groupId: string | undefined;
onNodeChange: (node: Partial<BlockWithOptions | TEventWithOptions>) => void;
}): JSX.Element | null => {
const updateOptions = (
@ -300,14 +298,8 @@ export const NodeSettings = ({
);
}
case LogicBlockType.JUMP: {
return groupId ? (
<JumpSettings
groupId={groupId}
options={node.options}
onOptionsChange={updateOptions}
/>
) : (
<></>
return (
<JumpSettings options={node.options} onOptionsChange={updateOptions} />
);
}
case LogicBlockType.AB_TEST: {