import { pickBy } from 'lodash'

export const filterEmptyStrings = <T extends object>(obj: T): Partial<T> => {
  return pickBy(obj, value => value !== '') as Partial<T>
}

export const areAllCheckersFilled = (target: string, obj: Record<string, any>) => {
  return Object.keys(obj)
    .filter(key => key.endsWith(`-${target}`))
    .every(key => {
      const value = obj[key]
      return value !== undefined && value !== ''
    })
}
