export type FilterValue = string | number | boolean | string[] | undefined | null;
export type FilterParams = Record<string, FilterValue>;

export const cleanFilterParams = <T extends object>(params: T): Partial<T> =>
  Object.fromEntries(
    Object.entries(params).filter(([, value]) => {
      if (value === null || value === undefined || value === "") return false;
      if (Array.isArray(value) && value.length === 0) return false;
      return true;
    }),
  ) as Partial<T>;
