- saving progress;
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useDrag, useDrop } from 'react-dnd'
|
||||
import { ItemTypes } from '../ItemTypes';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { head, isEmpty } from 'ramda';
|
||||
import { head, isEmpty, pathOr } from 'ramda';
|
||||
import { klona } from 'klona';
|
||||
|
||||
// store
|
||||
@@ -22,6 +22,7 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
const ref = useRef(null);
|
||||
const elements = useStore().main.formElements();
|
||||
const element = head(elements.filter(o => o.id === id));
|
||||
const elementSettings = pathOr([], ['settings'], element);
|
||||
const [isVariable, setIsVariable] = useState('secondary');
|
||||
const [isFormula, setIsFormula] = useState('secondary');
|
||||
const [variableName, setVariableName] = useState('secondary');
|
||||
@@ -134,10 +135,10 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
drag(drop(ref));
|
||||
|
||||
useEffect(() => {
|
||||
const variable = head(element.settings.filter(o => o.name === 'variable'));
|
||||
const formula = head(element.settings.filter(o => o.name === 'formula'));
|
||||
const isRequestedAmount = head(element.settings.filter(o => o.name === 'isRequestedAmount'));
|
||||
const isDelegation = head(element.settings.filter(o => o.name === 'isDelegation'));
|
||||
const variable = head(elementSettings.filter(o => o.name === 'variable'));
|
||||
const formula = head(elementSettings.filter(o => o.name === 'formula'));
|
||||
const isRequestedAmount = head(elementSettings.filter(o => o.name === 'isRequestedAmount'));
|
||||
const isDelegation = head(elementSettings.filter(o => o.name === 'isDelegation'));
|
||||
|
||||
if (variable && !isEmpty(variable.value)) {
|
||||
setIsVariable('warning');
|
||||
@@ -151,12 +152,16 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
|
||||
if (isRequestedAmount && !isEmpty(isRequestedAmount.value) && isRequestedAmount.value) {
|
||||
setIsRequestedAmount('tertiary');
|
||||
} else {
|
||||
setIsRequestedAmount(false);
|
||||
}
|
||||
|
||||
if (isDelegation && !isEmpty(isDelegation.value) && isDelegation.value) {
|
||||
setIsDelegation('tertiary');
|
||||
} else {
|
||||
setIsDelegation(false);
|
||||
}
|
||||
}, [elements]);
|
||||
}, [elementSettings]);
|
||||
|
||||
return (
|
||||
draggingElementId === id
|
||||
|
||||
Reference in New Issue
Block a user