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:
-
To get all the items modified within the last 7 days, you can use
User Modified Date{' '}
> 7.days.ago
-
To get all the items created before June 2022, you can use
Created At <{' '}
06/01/2022
)}
>
)
}
export default observer(CompoundPredicateBuilder)