fix: feedback updates v0.0.1

This commit is contained in:
yassinedorbozgithub 2024-11-27 15:13:04 +01:00
parent 3b72ad8ded
commit 28dc3e0e4f
2 changed files with 8 additions and 9 deletions

View File

@ -68,6 +68,7 @@ const PatternInput: FC<PatternInputProps> = ({
// const getNlpEntityFromCache = useGetFromCache(EntityType.NLP_ENTITY); // const getNlpEntityFromCache = useGetFromCache(EntityType.NLP_ENTITY);
const [pattern, setPattern] = useState<Pattern>(value); const [pattern, setPattern] = useState<Pattern>(value);
const [patternType, setPatternType] = useState<PatternType>(getType(value)); const [patternType, setPatternType] = useState<PatternType>(getType(value));
const isPostbackType = ["payload", "content", "menu"].includes(patternType);
const types = [ const types = [
{ value: "text", label: t("label.match_sound") }, { value: "text", label: t("label.match_sound") },
{ value: "regex", label: t("label.regex") }, { value: "regex", label: t("label.regex") },
@ -104,11 +105,7 @@ const PatternInput: FC<PatternInputProps> = ({
<Input <Input
select select
label={t("label.type")} label={t("label.type")}
value={ value={isPostbackType ? "payload" : patternType}
["menu", "content", "payload"].includes(patternType)
? "payload"
: patternType
}
onChange={(e) => { onChange={(e) => {
const selected = e.target.value as PatternType; const selected = e.target.value as PatternType;
@ -149,7 +146,7 @@ const PatternInput: FC<PatternInputProps> = ({
onChange={setPattern} onChange={setPattern}
/> />
)} )}
{["payload", "content", "menu"].includes(patternType) ? ( {isPostbackType ? (
<PostbackInput <PostbackInput
onChange={(payload) => { onChange={(payload) => {
payload && setPattern(payload); payload && setPattern(payload);

View File

@ -16,6 +16,8 @@ import { useTranslate } from "@/hooks/useTranslate";
import { EntityType, Format } from "@/services/types"; import { EntityType, Format } from "@/services/types";
import { IBlock, PayloadPattern } from "@/types/block.types"; import { IBlock, PayloadPattern } from "@/types/block.types";
import { import {
ButtonType,
PayloadType,
PostBackButton, PostBackButton,
StdOutgoingButtonsMessage, StdOutgoingButtonsMessage,
StdOutgoingQuickRepliesMessage, StdOutgoingQuickRepliesMessage,
@ -81,7 +83,7 @@ export const PostbackInput = ({ value, onChange }: PostbackInputProps) => {
const postbackButtons = ( const postbackButtons = (
(b.message as StdOutgoingButtonsMessage)?.buttons || [] (b.message as StdOutgoingButtonsMessage)?.buttons || []
) )
.filter((btn) => btn.type === "postback") .filter((btn) => btn.type === ButtonType.postback)
.map((btn) => { .map((btn) => {
return { ...btn, group: b.name }; return { ...btn, group: b.name };
}); });
@ -205,9 +207,9 @@ export const PostbackInput = ({ value, onChange }: PostbackInputProps) => {
label: content.label, label: content.label,
value: content.id, value: content.id,
type: ["content", "menu"].includes(content.group || "") type: ["content", "menu"].includes(content.group || "")
? content.group ? PayloadType[content?.group || ""]
: undefined, : undefined,
} as PayloadPattern); });
}} }}
groupBy={(option) => { groupBy={(option) => {
return option.group ?? t("label.other"); return option.group ?? t("label.other");