mirror of
https://github.com/hexastack/hexabot
synced 2024-12-02 00:54:56 +00:00
fix: code syntax
This commit is contained in:
parent
2a3290be4b
commit
8ac62d796f
@ -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);
|
||||
}}
|
||||
|
@ -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");
|
Loading…
Reference in New Issue
Block a user