Skip to content

Commit

Permalink
Removed: Search type dropdown from search bar (#306)
Browse files Browse the repository at this point in the history
Co-authored-by: Spyros <[email protected]>
  • Loading branch information
john681611 and northdpole committed Jun 27, 2023
1 parent 63580af commit b350e47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
36 changes: 9 additions & 27 deletions application/frontend/src/pages/Search/components/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,27 @@ import './SearchBar.scss';

import React, { useState } from 'react';
import { useHistory } from 'react-router-dom';
import { Button, Dropdown, Form, Icon, Input } from 'semantic-ui-react';
import { Button, Form, Icon, Input } from 'semantic-ui-react';

import { CODE, CRE, SEARCH, STANDARD, TOOL } from '../../../const';

const SEARCH_TYPES = {
topicText: { key: 'topicText', text: 'Topic text', value: 'topicText', path: SEARCH },
standard: { key: 'standard', text: 'Standard', value: 'standard', path: '/node' + STANDARD },
tool: { key: 'tool', text: 'tool', value: 'tool', path: '/node' + TOOL },
code: { key: 'code', text: 'code', value: 'code', path: '/node' + CODE },
creId: { key: 'creId', text: 'CRE ID', value: 'creId', path: CRE },
};
import { SEARCH } from '../../../const';

interface SearchBarState {
term: string;
type: string;
error: string;
}

const DEFAULT_SEARCH_BAR_STATE: SearchBarState = { term: '', type: SEARCH_TYPES['topicText'].key, error: '' };
const DEFAULT_SEARCH_BAR_STATE: SearchBarState = { term: '', error: '' };

export const SearchBar = () => {
const [search, setSearch] = useState<SearchBarState>(DEFAULT_SEARCH_BAR_STATE);
const history = useHistory();

const onSubmit = () => {
const { term, type } = search;
const { term } = search;

if (Boolean(search.term)) {
setSearch(DEFAULT_SEARCH_BAR_STATE);
history.push(`${SEARCH_TYPES[type].path}/${term}`);
history.push(`${SEARCH}/${term}`);
} else {
setSearch({
...search,
Expand All @@ -40,12 +31,6 @@ export const SearchBar = () => {
}
};

const onChange = (_, { value }) => {
setSearch({
...search,
type: value as string,
});
};

return (
<Form onSubmit={onSubmit}>
Expand All @@ -60,17 +45,14 @@ export const SearchBar = () => {
term: e.target.value,
});
}}
label={<Dropdown options={Object.values(SEARCH_TYPES)} value={search.type} onChange={onChange} />}
label={<Button primary onSubmit={onSubmit}>
<Icon name="search" />
Search
</Button>}
labelPosition="right"
placeholder="Search..."
/>
</Form.Field>
<Form.Field id="SearchButton">
<Button primary onSubmit={onSubmit}>
<Icon name="search" />
Search
</Button>
</Form.Field>
</Form.Group>
</Form>
);
Expand Down
2 changes: 1 addition & 1 deletion application/frontend/src/scaffolding/Header/header.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.header__nav-bar {

padding: 0 10px;
&.ui.secondary.menu {
margin-top: 0px;
border-bottom: none;
Expand Down

0 comments on commit b350e47

Please sign in to comment.