fix: code syntax

This commit is contained in:
yassinedorbozgithub 2024-11-27 14:48:28 +01:00
parent 2a3290be4b
commit 8ac62d796f
2 changed files with 7 additions and 14 deletions

View File

@ -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<PatternInputProps> = ({
/>
)}
{["payload", "content", "menu"].includes(patternType) ? (
<PostbackInputV2
<PostbackInput
onChange={(payload) => {
payload && setPattern(payload);
}}

View File

@ -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 (
<Skeleton animation="wave" variant="rounded" width="100%" height={40} />
);
@ -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");