fix prompt variables

This commit is contained in:
anovazzi1 2024-06-14 17:21:35 -03:00
commit e8d673debf

View file

@ -47,7 +47,7 @@ export default function GenericModal({
const [myModalType] = useState(type); const [myModalType] = useState(type);
const [inputValue, setInputValue] = useState(value); const [inputValue, setInputValue] = useState(value);
const [isEdit, setIsEdit] = useState(true); const [isEdit, setIsEdit] = useState(true);
const [wordsHighlight, setWordsHighlight] = useState<string[]>([]); const [wordsHighlight, setWordsHighlight] = useState<Set<string>>(new Set());
const setSuccessData = useAlertStore((state) => state.setSuccessData); const setSuccessData = useAlertStore((state) => state.setSuccessData);
const setErrorData = useAlertStore((state) => state.setErrorData); const setErrorData = useAlertStore((state) => state.setErrorData);
const setNoticeData = useAlertStore((state) => state.setNoticeData); const setNoticeData = useAlertStore((state) => state.setNoticeData);
@ -82,8 +82,8 @@ export default function GenericModal({
} }
} }
const filteredWordsHighlight = matches.filter( const filteredWordsHighlight = new Set(
(word) => !invalid_chars.includes(word) matches.filter((word) => !invalid_chars.includes(word)),
); );
setWordsHighlight(filteredWordsHighlight); setWordsHighlight(filteredWordsHighlight);
@ -134,7 +134,7 @@ export default function GenericModal({
// to the first key of the custom_fields object // to the first key of the custom_fields object
if (field_name === "") { if (field_name === "") {
field_name = Array.isArray( field_name = Array.isArray(
apiReturn.data?.frontend_node?.custom_fields?.[""] apiReturn.data?.frontend_node?.custom_fields?.[""],
) )
? apiReturn.data?.frontend_node?.custom_fields?.[""][0] ?? "" ? apiReturn.data?.frontend_node?.custom_fields?.[""][0] ?? ""
: apiReturn.data?.frontend_node?.custom_fields?.[""] ?? ""; : apiReturn.data?.frontend_node?.custom_fields?.[""] ?? "";
@ -209,7 +209,7 @@ export default function GenericModal({
<div <div
className={classNames( className={classNames(
!isEdit ? "rounded-lg border" : "", !isEdit ? "rounded-lg border" : "",
"flex h-full max-h-[85%] w-full" "flex h-full max-h-[85%] w-full",
)} )}
> >
{type === TypeModal.PROMPT && isEdit && !readonly ? ( {type === TypeModal.PROMPT && isEdit && !readonly ? (
@ -279,7 +279,7 @@ export default function GenericModal({
Prompt Variables: Prompt Variables:
</span> </span>
{wordsHighlight.map((word, index) => ( {Array.from(wordsHighlight).map((word, index) => (
<ShadTooltip <ShadTooltip
key={index} key={index}
content={word.replace(/[{}]/g, "")} content={word.replace(/[{}]/g, "")}