import { AllNonCompoundPredicateOperators, PredicateCompoundOperator, PredicateOperator } from '@standardnotes/snjs' import { observer } from 'mobx-react-lite' import Button from '../Button/Button' import Icon from '../Icon/Icon' import { CompoundPredicateBuilderController } from './CompoundPredicateBuilderController' import { PredicateKeypath, PredicateKeypathLabels, PredicateKeypathTypes } from './PredicateKeypaths' import PredicateValue from './PredicateValue' type Props = { controller: CompoundPredicateBuilderController } const CompoundPredicateBuilder = ({ controller }: Props) => { const { operator, setOperator, predicates, setPredicate, changePredicateKeypath, addPredicate, removePredicate } = controller return ( <>
{predicates.map((predicate, index) => (
{index !== 0 &&
{operator === 'and' ? 'AND' : 'OR'}
} {predicate.keypath && ( { setPredicate(index, { value }) }} /> )} {index !== 0 && ( )}
{index === predicates.length - 1 && ( )}
))} {predicates.some((predicate) => PredicateKeypathTypes[predicate.keypath as PredicateKeypath] === 'date') && (
Date Examples:
)} ) } export default observer(CompoundPredicateBuilder)