From 28dc3e0e4fd4e3910eceb5fc62b7046be22ad5e8 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Wed, 27 Nov 2024 15:13:04 +0100 Subject: [PATCH] fix: feedback updates v0.0.1 --- .../visual-editor/form/inputs/triggers/PatternInput.tsx | 9 +++------ .../visual-editor/form/inputs/triggers/PostbackInput.tsx | 8 +++++--- 2 files changed, 8 insertions(+), 9 deletions(-) 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 1f63454..2e9f4a6 100644 --- a/frontend/src/components/visual-editor/form/inputs/triggers/PatternInput.tsx +++ b/frontend/src/components/visual-editor/form/inputs/triggers/PatternInput.tsx @@ -68,6 +68,7 @@ const PatternInput: FC = ({ // const getNlpEntityFromCache = useGetFromCache(EntityType.NLP_ENTITY); const [pattern, setPattern] = useState(value); const [patternType, setPatternType] = useState(getType(value)); + const isPostbackType = ["payload", "content", "menu"].includes(patternType); const types = [ { value: "text", label: t("label.match_sound") }, { value: "regex", label: t("label.regex") }, @@ -104,11 +105,7 @@ const PatternInput: FC = ({ { const selected = e.target.value as PatternType; @@ -149,7 +146,7 @@ const PatternInput: FC = ({ onChange={setPattern} /> )} - {["payload", "content", "menu"].includes(patternType) ? ( + {isPostbackType ? ( { payload && setPattern(payload); diff --git a/frontend/src/components/visual-editor/form/inputs/triggers/PostbackInput.tsx b/frontend/src/components/visual-editor/form/inputs/triggers/PostbackInput.tsx index 82022f2..e609afb 100644 --- a/frontend/src/components/visual-editor/form/inputs/triggers/PostbackInput.tsx +++ b/frontend/src/components/visual-editor/form/inputs/triggers/PostbackInput.tsx @@ -16,6 +16,8 @@ import { useTranslate } from "@/hooks/useTranslate"; import { EntityType, Format } from "@/services/types"; import { IBlock, PayloadPattern } from "@/types/block.types"; import { + ButtonType, + PayloadType, PostBackButton, StdOutgoingButtonsMessage, StdOutgoingQuickRepliesMessage, @@ -81,7 +83,7 @@ export const PostbackInput = ({ value, onChange }: PostbackInputProps) => { const postbackButtons = ( (b.message as StdOutgoingButtonsMessage)?.buttons || [] ) - .filter((btn) => btn.type === "postback") + .filter((btn) => btn.type === ButtonType.postback) .map((btn) => { return { ...btn, group: b.name }; }); @@ -205,9 +207,9 @@ export const PostbackInput = ({ value, onChange }: PostbackInputProps) => { label: content.label, value: content.id, type: ["content", "menu"].includes(content.group || "") - ? content.group + ? PayloadType[content?.group || ""] : undefined, - } as PayloadPattern); + }); }} groupBy={(option) => { return option.group ?? t("label.other");