mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-06-25 21:01:54 +08:00
💄 Fix groups dropdown displaying ID instead of title
This commit is contained in:
parent
1e01d43219
commit
0ee75cf974
@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user