diff --git a/frontend/src/components/visual-editor/form/inputs/triggers/PatternInput.tsx b/frontend/src/components/visual-editor/form/inputs/triggers/PatternInput.tsx index 3e7f3ed..1f63454 100644 --- a/frontend/src/components/visual-editor/form/inputs/triggers/PatternInput.tsx +++ b/frontend/src/components/visual-editor/form/inputs/triggers/PatternInput.tsx @@ -23,7 +23,7 @@ import { PayloadPattern, } from "@/types/block.types"; -import { PostbackInputV2 } from "./PostbackInputV2"; +import { PostbackInput } from "./PostbackInput"; const isRegex = (str: Pattern) => { return typeof str === "string" && str.startsWith("/") && str.endsWith("/"); @@ -150,7 +150,7 @@ const PatternInput: FC = ({ /> )} {["payload", "content", "menu"].includes(patternType) ? ( - { payload && setPattern(payload); }} diff --git a/frontend/src/components/visual-editor/form/inputs/triggers/PostbackInputV2.tsx b/frontend/src/components/visual-editor/form/inputs/triggers/PostbackInput.tsx similarity index 95% rename from frontend/src/components/visual-editor/form/inputs/triggers/PostbackInputV2.tsx rename to frontend/src/components/visual-editor/form/inputs/triggers/PostbackInput.tsx index 68dccd1..a326dd1 100644 --- a/frontend/src/components/visual-editor/form/inputs/triggers/PostbackInputV2.tsx +++ b/frontend/src/components/visual-editor/form/inputs/triggers/PostbackInput.tsx @@ -30,18 +30,12 @@ type PayloadOption = { group?: string; }; -type ContentPayloadOption = { - id: string; - label: string; - group?: string; -}; - type PostbackInputProps = { value?: string | null; onChange: (pattern: PayloadPattern) => void; }; -export const PostbackInputV2 = ({ value, onChange }: PostbackInputProps) => { +export const PostbackInput = ({ value, onChange }: PostbackInputProps) => { const block = useBlock(); const getBlockFromCache = useGetFromCache(EntityType.BLOCK); const { data: menu } = useFind( @@ -176,7 +170,7 @@ export const PostbackInputV2 = ({ value, onChange }: PostbackInputProps) => { return acc; }, payloads); - }, [] as ContentPayloadOption[]); + }, [] as PayloadOption[]); }) .flat(), [block?.previousBlocks, contents, getBlockFromCache], @@ -189,9 +183,9 @@ export const PostbackInputV2 = ({ value, onChange }: PostbackInputProps) => { ...menuOptions, ...contentOptions, ]; - const existOption = options.find((e) => e.id === value); + const isOptionsReady = options.find((e) => e.id === value); - if (!existOption) { + if (!isOptionsReady) { return ( ); @@ -206,7 +200,7 @@ export const PostbackInputV2 = ({ value, onChange }: PostbackInputProps) => { label={t("label.postback")} multiple={false} onChange={(_e, content) => { - if (content) { + content && onChange({ label: content.label, value: content.id, @@ -214,7 +208,6 @@ export const PostbackInputV2 = ({ value, onChange }: PostbackInputProps) => { ? content.group : undefined, } as PayloadPattern); - } }} groupBy={(option) => { return option.group ?? t("label.other");