= ({
Search Holdingpen
{
- dispatch(push(HOLDINGPEN_SEARCH_NEW));
- }}
- onSearch={() => {
- dispatch(push(HOLDINGPEN_SEARCH_NEW));
- }}
+ placeholder="Search Holdingpen"
+ onPressEnter={(event) =>
+ handleSearchEvent(event?.currentTarget?.value)
+ }
+ onSearch={handleSearchEvent}
/>
Overview
@@ -186,9 +233,10 @@ const DashboardPageContainer: React.FC
= ({
);
};
-const stateToProps = (state: RootStateOrAny) => ({
+const mapStateToProps = (state: RootStateOrAny) => ({
facets: state.holdingpen.get('facets'),
loading: state.holdingpen.get('loading'),
+ query: state.holdingpen.get('query'),
});
-export default connect(stateToProps)(DashboardPageContainer);
+export default connect(mapStateToProps)(DashboardPageContainer);
diff --git a/ui/src/holdingpen-new/utils/__tests__/utils.test.tsx b/ui/src/holdingpen-new/utils/__tests__/utils.test.tsx
index aa86723fd..e72471732 100644
--- a/ui/src/holdingpen-new/utils/__tests__/utils.test.tsx
+++ b/ui/src/holdingpen-new/utils/__tests__/utils.test.tsx
@@ -2,20 +2,12 @@ import React from 'react';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
-import { getIcon, refreshToken, COLLECTIONS } from '../utils';
+import { getIcon, refreshToken } from '../utils';
import storage from '../../../common/storage';
import { BACKOFFICE_LOGIN } from '../../../common/routes';
jest.mock('../../../common/storage');
-describe('COLLECTIONS', () => {
- it('should have the correct values', () => {
- expect(COLLECTIONS.AUTHOR_CREATE).toBe('new authors');
- expect(COLLECTIONS.AUTHOR_UPDATE).toBe('author updates');
- expect(COLLECTIONS.HEP_CREATE).toBe('new literature submissions');
- });
-});
-
describe('getIcon', () => {
it('should return HourglassOutlined for approval status', () => {
const { container } = render(getIcon('approval') as React.ReactElement);
diff --git a/ui/src/holdingpen-new/utils/utils.tsx b/ui/src/holdingpen-new/utils/utils.tsx
index fb9423a79..e97b4cd9b 100644
--- a/ui/src/holdingpen-new/utils/utils.tsx
+++ b/ui/src/holdingpen-new/utils/utils.tsx
@@ -5,15 +5,35 @@ import {
HourglassOutlined,
LoadingOutlined,
} from '@ant-design/icons';
+import { push } from 'connected-react-router';
+import { Action, ActionCreator } from 'redux';
import storage from '../../common/storage';
-import { BACKOFFICE_LOGIN, HOLDINGPEN_LOGIN_NEW } from '../../common/routes';
+import {
+ BACKOFFICE_LOGIN,
+ HOLDINGPEN_LOGIN_NEW,
+ HOLDINGPEN_SEARCH_NEW,
+} from '../../common/routes';
+import { searchQueryUpdate } from '../../actions/holdingpen';
-export const COLLECTIONS: Record = {
- AUTHOR_CREATE: 'new authors',
- AUTHOR_UPDATE: 'author updates',
- HEP_CREATE: 'new literature submissions',
-};
+export const COLLECTIONS = [
+ {
+ key: 'all collections',
+ value: undefined,
+ },
+ {
+ key: 'new authors',
+ value: 'AUTHOR_CREATE',
+ },
+ {
+ key: 'author updates',
+ value: 'AUTHOR_UPDATE',
+ },
+ {
+ key: 'new literature submissions',
+ value: 'HEP_CREATE',
+ },
+];
export const getIcon = (status: string) => {
switch (status?.toLowerCase()) {
@@ -70,3 +90,18 @@ export const resolveDecision = (decision: string | number) => {
};
return decisions[decision] || null;
};
+
+export const handleSearch = (
+ dispatch: ActionCreator,
+ type: string,
+ searchValue: string
+) => {
+ const query = {
+ page: 1,
+ search: searchValue,
+ workflow_type: type,
+ };
+
+ dispatch(searchQueryUpdate(query));
+ dispatch(push(HOLDINGPEN_SEARCH_NEW));
+};