teableio/teable

View on GitHub
apps/nextjs-app/src/features/app/blocks/setting/query-builder/SearchBuilder.tsx

Summary

Maintainability
A
0 mins
Test Coverage
import { SearchInput } from '@teable/sdk/components';
import { useSearch } from '@teable/sdk/hooks';
import { isEqual } from 'lodash';
import { useEffect } from 'react';

export const SearchBuilder = ({
  search,
  onChange,
}: {
  search?: [string, string] | [string];
  onChange: (search?: [string, string] | [string]) => void;
}) => {
  const { searchQuery } = useSearch();

  useEffect(() => {
    if (!isEqual(searchQuery, search)) {
      onChange(searchQuery);
    }
  }, [onChange, search, searchQuery]);

  return <SearchInput className="w-80" />;
};