Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
GCL_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
안형욱
2021-06-12 19:09:18 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b9d1e781c4d9a6f3c58a0ecd602026c68a1ccd7e
b9d1e781
1 parent
8afe686e
feat: search logic 추가
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
57 additions
and
8 deletions
frontend/src/components/Header.js
frontend/src/components/common/Input.js
frontend/src/features/parsedDocumentsSlice.js
frontend/src/index.js
frontend/src/pages/HomePage.js
frontend/src/pages/SearchPage.js
frontend/src/reducers/index.js
frontend/src/components/Header.js
View file @
b9d1e78
...
...
@@ -134,9 +134,7 @@ const Header = () => {
/
>
<
/DropDownWrap
>
<
/DropDownContainer
>
<
InputBlock
color
=
"blue"
fontsize
=
"20px"
width
=
"850px"
display
=
""
>
<
input
/>
<
/InputBlock
>
<
InputBlock
color
=
"blue"
fontsize
=
"20px"
width
=
"850px"
display
=
""
/>
<
/SearchContainer
>
<
MenuContainer
>
<
ul
>
...
...
frontend/src/components/common/Input.js
View file @
b9d1e78
...
...
@@ -2,8 +2,11 @@ import React, { useState, useEffect } from 'react';
import
{
TextInput
}
from
'@mantine/core'
;
import
styled
from
'styled-components'
;
import
{
useHistory
,
useLocation
}
from
'react-router-dom'
;
import
{
useDispatch
}
from
'react-redux'
;
import
SearchBox
from
'./SearchBox'
;
import
{
inputColorMap
}
from
'../../lib/styles/palette'
;
import
{
esApi
}
from
'../../lib/api/elasticsearch'
;
import
{
setParsedDocuments
}
from
'../../features/parsedDocumentsSlice'
;
const
InputBlock
=
styled
.
div
`
width:
${
props
=>
props
.
width
}
;
...
...
@@ -40,10 +43,16 @@ const MyInput = ({
const
history
=
useHistory
();
const
search
=
useLocation
();
const
name
=
search
.
search
.
substring
(
7
);
const
dispatch
=
useDispatch
();
useEffect
(()
=>
{
const
setSearchDatas
=
async
()
=>
{
const
{
results
}
=
await
esApi
.
search
(
name
);
dispatch
(
setParsedDocuments
(
results
));
};
setQuery
(
name
);
},
[]
);
setSearchDatas
(
);
},
[
name
]);
return
(
<
InputBlock
color
=
{
color
}
...
...
frontend/src/features/parsedDocumentsSlice.js
0 → 100644
View file @
b9d1e78
import
{
createSlice
}
from
'@reduxjs/toolkit'
;
const
parsedDocumentsSlice
=
createSlice
({
name
:
'parsedDocuments'
,
initialState
:
{
documents
:
[],
},
reducers
:
{
setParsedDocuments
:
(
state
,
action
)
=>
{
state
.
documents
=
action
.
payload
;
},
},
});
export
const
{
setParsedDocuments
}
=
parsedDocumentsSlice
.
actions
;
export
default
parsedDocumentsSlice
.
reducer
;
frontend/src/index.js
View file @
b9d1e78
import
React
from
'react'
;
import
ReactDOM
from
'react-dom'
;
import
{
configureStore
}
from
'@reduxjs/toolkit'
;
import
{
Provider
}
from
'react-redux'
;
import
App
from
'./App'
;
import
rootReducer
from
'./reducers'
;
const
store
=
configureStore
({
reducer
:
rootReducer
,
});
ReactDOM
.
render
(
<
React
.
StrictMode
>
<
App
/>
<
Provider
store
=
{
store
}
>
<
App
/>
<
/Provider
>
<
/React.StrictMode>
,
document
.
getElementById
(
'root'
)
);
...
...
frontend/src/pages/HomePage.js
View file @
b9d1e78
...
...
@@ -9,7 +9,6 @@ const Main = styled.div`
display: flex;
align-items: center;
justify-content: center;
padding-left: 7%;
`
;
const
Container
=
styled
.
div
`
...
...
frontend/src/pages/SearchPage.js
View file @
b9d1e78
import
React
from
'react'
;
import
{
useSelector
}
from
'react-redux'
;
import
Header
from
'../components/Header'
;
import
Main
from
'../components/document
/index
'
;
import
Main
from
'../components/document'
;
const
SearchPage
=
()
=>
{
const
parsedDocuments
=
useSelector
(
state
=>
state
.
parsedDocuments
);
if
(
parsedDocuments
.
length
===
0
)
{
return
(
<>
<
Header
/>
<
div
>
검색
결과가
없습니다
.
<
/div
>
<
/
>
);
}
return
(
<>
<
Header
/>
...
...
frontend/src/reducers/index.js
0 → 100644
View file @
b9d1e78
import
{
combineReducers
}
from
'redux'
;
import
parsedDocumentsReducer
from
'../features/parsedDocumentsSlice'
;
export
default
combineReducers
({
parsedDocuments
:
parsedDocumentsReducer
,
});
Please
register
or
login
to post a comment