import XEUtils from 'xe-utils'

export const useSymbolOptions = (candidateFields: CandidateField[]) => {
  const SymbolOptionsList = [
    { label: '≤', value: 'lte' },
    { label: '<', value: 'lt' },
    { label: '=', value: 'eq' },
    { label: '≥', value: 'gte' },
    { label: '>', value: 'gt' },
    // { label: '范围内', value: 'between' },
    // { label: '范围外', value: 'not_between' },
    // { label: '包含', value: 'in' },
    // { label: '不包含', value: 'not_in' }
  ]

  //const getFieldInfo = (field: string) => {
  //  return XEUtils.find(candidateFields, (item) => item.value === field) || SymbolOptionsList
  //}
  const getFieldInfo = (field: string) => {
    const foundItem = XEUtils.find(candidateFields, (item) => item.value === field);
    if (foundItem) {
     return foundItem;
    }
  }
  const getSymbolOptions = (field: string) => {
    const FieldInfo = getFieldInfo(field)
    //console.log('FieldInfo',FieldInfo);
    //console.log('type',FieldInfo.type);
    if (FieldInfo.type === 'array')
      return [
        { label: '包含', value: 'in' },
        { label: '不包含', value: 'not_in' },
      ]
    return SymbolOptionsList
  }
  return { getSymbolOptions, getFieldInfo }
}
