import { useMemo, useState } from 'react';
import { IItemPack } from '@rpg-engine/shared';

export const usePackFiltering = (packs: IItemPack[]) => {
  const [searchQuery, setSearchQuery] = useState('');

  const filteredPacks = useMemo(
    () =>
      packs.filter(pack =>
        pack.title.toLowerCase().includes(searchQuery.toLowerCase())
      ),
    [packs, searchQuery]
  );

  return {
    searchQuery,
    setSearchQuery,
    filteredPacks,
  };
};
