seanprashad/leetcode-patterns

Add functionality to filter by a company

seanprashad opened this issue · 5 comments

With the refactoring of questions.json in #210, the filtering capability for companies broke and no longer works. For now, I've disabled it as it's redundant, but we should look to fix this in the future.

See #180 for an example of how we can accomplish this - we can introduce a new filter to parse and populate the dropdown list, based on all companies:

export function SelectCompanyColumnFilter({
  column: { filterValue, setFilter, preFilteredRows, id },
}) {
  const options = React.useMemo(() => {
    const set = new Set();

    preFilteredRows.forEach(row => {
      const companies = [...row.values.companies];

      companies.forEach(company => {
        set.add(company.name);
      });
    });

    return [...set.values()].sort();
  }, [id, preFilteredRows]);

  return CreateDropDownListHelper(options, filterValue, setFilter, id);
}

However, this isn't the full solution as we need a custom filter method - again see #180 for support!

cc @leo-step - you might have some ideas here !

Have a solution for this but we should check issue #221 first.

Even if #221 is a bug, do you think we should have a 'None' option in the company filter dropdown?

I haven't actually seen a question that has no companies attached to it - the new questions might, but all of the ones in this list have been around for sometime and are commonly asked (or variants are asked). Let's hold off on a None option for now, until I understand what's happening in #221