Skip to content

Commit

Permalink
Merge pull request #211 from soham4abc/demodularise-search
Browse files Browse the repository at this point in the history
fix(update): Exported constants from the search component

Reviewed-by: [email protected]
Tested-by: [email protected]
  • Loading branch information
GMishx authored Jun 7, 2022
2 parents fc33c1f + ab104d1 commit e7a6576
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 36 deletions.
35 changes: 35 additions & 0 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,38 @@ export const initialMessage = {
type: "success",
text: "",
};

export const initialState = {
searchType: "allfiles",
uploadId: "",
filename: "",
tag: "",
filesizemin: "",
filesizemax: "",
license: "",
copyright: "",
page: 1,
limit: 10,
};
export const initialMessageSearch = {
type: "danger",
text: "",
};
export const entriesOptionsSearch = [
{
id: 10,
entry: "10",
},
{
id: 25,
entry: "25",
},
{
id: 50,
entry: "50",
},
{
id: 100,
entry: "100",
},
];
45 changes: 9 additions & 36 deletions src/pages/Search/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,14 @@ import { Alert, Button, InputContainer, Spinner } from "components/Widgets";
// Required functions for calling APIs
import search from "services/search";

// Required constants
import {
initialState,
initialMessageSearch,
entriesOptionsSearch,
} from "../../constants/constants";

const Search = () => {
const initialState = {
searchType: "allfiles",
uploadId: "",
filename: "",
tag: "",
filesizemin: "",
filesizemax: "",
license: "",
copyright: "",
page: 1,
limit: 10,
};
const initialMessage = {
type: "danger",
text: "",
};
const entriesOptions = [
{
id: 10,
entry: "10",
},
{
id: 25,
entry: "25",
},
{
id: 50,
entry: "50",
},
{
id: 100,
entry: "100",
},
];
// Data for searching specific uploads
const [searchData, setSearchData] = useState(initialState);

Expand All @@ -74,7 +47,7 @@ const Search = () => {
// State Variables for handling Error Boundaries
const [loading, setLoading] = useState(false);
const [showMessage, setShowMessage] = useState(false);
const [message, setMessage] = useState(initialMessage);
const [message, setMessage] = useState(initialMessageSearch);

const handleSubmit = (e) => {
e.preventDefault();
Expand Down Expand Up @@ -146,7 +119,7 @@ const Search = () => {
name="limit"
type="select"
onChange={(e) => handleChange(e)}
options={entriesOptions}
options={entriesOptionsSearch}
property="entry"
>
Show entries:
Expand Down

0 comments on commit e7a6576

Please sign in to comment.