Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
butter-studio
Commits
89ada388
Commit
89ada388
authored
Jul 20, 2021
by
Kim, Subin
Browse files
Search
parent
df6380f2
Changes
2
Show whitespace changes
Inline
Side-by-side
client/src/components/Search/Search.js
View file @
89ada388
...
@@ -10,11 +10,11 @@ const Search = ({ type, search, setSearch, handleClick }) => {
...
@@ -10,11 +10,11 @@ const Search = ({ type, search, setSearch, handleClick }) => {
<
div
className
=
"
d-flex
"
>
<
div
className
=
"
d-flex
"
>
{
type
===
"
home
"
?
null
:
{
type
===
"
home
"
?
null
:
<
select
className
=
{
`form-select
${
styles
.
search
}
`
}
name
=
"
kind
"
aria
-
label
=
"
select search
"
onChange
=
{
handleSearch
}
>
<
select
className
=
{
`form-select
${
styles
.
search
}
`
}
name
=
"
kind
"
aria
-
label
=
"
select search
"
onChange
=
{
handleSearch
}
>
<
option
selected
value
=
"
title
"
>
제목
<
/option
>
<
option
value
=
"
title
"
>
제목
<
/option
>
<
option
value
=
"
director
"
>
감독명
<
/option
>
<
option
value
=
"
director
"
>
감독명
<
/option
>
<
/select
>
<
/select
>
}
}
<
input
className
=
{
`form-control
${
type
===
"
home
"
?
styles
.
searchWhite
:
`
${
styles
.
search
}
`
}
`
}
name
=
"
keyword
"
type
=
"
text
"
onChange
=
{
handleSearch
}
/
>
<
input
className
=
{
`form-control
${
type
===
"
home
"
?
styles
.
searchWhite
:
`
${
styles
.
search
}
`
}
`
}
name
=
"
keyword
"
type
=
"
text
"
autoComplete
=
"
off
"
onChange
=
{
handleSearch
}
/
>
<
i
className
=
{
`bi bi-search align-self-center
${
type
===
"
home
"
?
"
text-white
"
:
"
mx-2
"
}
${
styles
.
icon
}
`
}
onClick
=
{
handleClick
}
style
=
{{
fontSize
:
"
1.3rem
"
}}
><
/i
>
<
i
className
=
{
`bi bi-search align-self-center
${
type
===
"
home
"
?
"
text-white
"
:
"
mx-2
"
}
${
styles
.
icon
}
`
}
onClick
=
{
handleClick
}
style
=
{{
fontSize
:
"
1.3rem
"
}}
><
/i
>
<
/div
>
<
/div
>
)
)
...
...
client/src/components/SearchResult.js
View file @
89ada388
import
{
useLocation
}
from
'
react-router-dom
'
;
import
{
useState
,
useEffect
}
from
'
react
'
import
queryString
from
'
query-string
'
;
import
{
useLocation
}
from
'
react-router-dom
'
import
MovieChart
from
"
./MovieChart/index.js
"
;
import
queryString
from
'
query-string
'
import
MovieCard
from
"
./MovieCard/index.js
"
import
movieApi
from
'
../apis/movie.api.js
'
import
catchErrors
from
'
../utils/catchErrors.js
'
const
SearchResult
=
()
=>
{
const
SearchResult
=
()
=>
{
const
[
result
,
setResult
]
=
useState
([])
const
[
error
,
setError
]
=
useState
(
""
)
const
{
search
}
=
useLocation
()
const
{
search
}
=
useLocation
()
const
{
title
}
=
queryString
.
parse
(
search
)
const
{
title
}
=
queryString
.
parse
(
search
)
console
.
log
(
"
search==
"
,
search
,
"
title==
"
,
title
)
useEffect
(()
=>
{
findforKeyword
()
},
[
search
])
async
function
findforKeyword
()
{
try
{
setError
(
""
)
const
data
=
await
movieApi
.
search
(
title
)
setResult
([...
data
])
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
console
.
log
(
"
search==
"
,
search
,
"
title==
"
,
title
)
return
(
return
(
<>
{
result
.
length
!==
0
?
(
<>
<>
<
h3
className
=
"
text-white text-center my-5
"
>
'
{title}
'
에
관한
검색
결과입니다
.
<
/h3
>
<
h3
className
=
"
text-white text-center my-5
"
>
'
{title}
'
에
관한
검색
결과입니다
.
<
/h3
>
<
MovieChart
/>
<
MovieCard
list
=
{
result
}
/
>
<
/
>
)
:
<
h3
className
=
"
text-white text-center my-5
"
>
'
{title}
'
에
관한
검색
결과가
존재하지
않습니다
.
<
/h3>
}
<
/
>
<
/
>
)
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment