import XEUtils from 'xe-utils'

export const useSymbolOptions = (candidateFields: CandidateField[]) => {
  const SymbolOptionsList = [
    { label: '大于', value: 'gt' },
    { label: '大于等于', value: 'gte' },
    { label: '小于', value: 'lt' },
    { label: '小于等于', value: 'lte' },
    { label: '等于', value: 'eq' },
    { 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)
  }

  const getSymbolOptions = (field: string) => {
    const FieldInfo = getFieldInfo(field)
    if (FieldInfo.type === 'array')
      return [
        { label: '包含', value: 'in' },
        { label: '不包含', value: 'not_in' },
      ]
    return SymbolOptionsList
  }
  return { getSymbolOptions, getFieldInfo }
}
