SearchWrapper.tsx 632 B

12345678910111213141516171819202122
  1. import React, { FC, memo } from 'react';
  2. import { useUrlParams } from 'app/core/navigation/hooks';
  3. import { defaultQueryParams } from '../reducers/searchQueryReducer';
  4. import DashboardSearch from './DashboardSearch';
  5. export const SearchWrapper: FC = memo(() => {
  6. const [params, updateUrlParams] = useUrlParams();
  7. const isOpen = params.get('search') === 'open';
  8. const closeSearch = () => {
  9. if (isOpen) {
  10. updateUrlParams({ search: null, folder: null, ...defaultQueryParams });
  11. }
  12. };
  13. return isOpen ? <DashboardSearch onCloseSearch={closeSearch} /> : null;
  14. });
  15. SearchWrapper.displayName = 'SearchWrapper';