Update InputGlobalComponent to handle unavaliableFields in useGlobalVariablesStore

This commit is contained in:
anovazzi1 2024-04-30 15:11:26 -03:00
commit 6261c71e01

View file

@ -23,6 +23,7 @@ export default function InputGlobalComponent({
); );
const getVariableId = useGlobalVariablesStore((state) => state.getVariableId); const getVariableId = useGlobalVariablesStore((state) => state.getVariableId);
const unavaliableFields = useGlobalVariablesStore((state) => state.unavaliableFields);
const removeGlobalVariable = useGlobalVariablesStore( const removeGlobalVariable = useGlobalVariablesStore(
(state) => state.removeGlobalVariable (state) => state.removeGlobalVariable
); );
@ -39,6 +40,15 @@ export default function InputGlobalComponent({
} }
}, [globalVariablesEntries]); }, [globalVariablesEntries]);
useEffect(() => {
if (!data.node?.template[name].value && data.node?.template[name].display_name) {
if(unavaliableFields[data.node?.template[name].display_name!]){
setDb(true);
onChange(unavaliableFields[data.node?.template[name].display_name!]);
}
}
},[unavaliableFields]);
function handleDelete(key: string) { function handleDelete(key: string) {
const id = getVariableId(key); const id = getVariableId(key);
if (id !== undefined) { if (id !== undefined) {