-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #247 from LikeLion-at-DGU/dev
🚀 Deploy
- Loading branch information
Showing
12 changed files
with
135 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { instance } from "./instance"; | ||
|
||
export const getSearchContent = async (data) => { | ||
try { | ||
const res = await instance.get(`/api/search?data=${data}`); | ||
return res; | ||
} catch (err) { | ||
console.log(err); | ||
throw err; | ||
} | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from "react"; | ||
import * as S from "./styled"; | ||
import Arrow from "@/assets/Arrow.svg"; | ||
export const SearchResultStar = (src, name, profession) => { | ||
return ( | ||
<> | ||
<S.Container> | ||
<S.StarImg src={src} /> | ||
<S.info> | ||
<div>{name}</div> | ||
<div>{profession}</div> | ||
</S.info> | ||
<img src={Arrow} /> | ||
</S.Container> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useState, useEffect } from "react"; | ||
import { getSearchContent } from "@/apis/search"; | ||
import { useParams } from "react-router-dom"; | ||
|
||
export const useSearchResult = () => { | ||
const [search, setSearch] = useState(null); | ||
const { data } = useParams(); | ||
const fetchSearchData = async () => { | ||
try { | ||
const res = await getSearchContent(data); | ||
console.log("response:", res); | ||
setSearch(res); | ||
} catch (error) { | ||
console.error("error:", error); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
fetchSearchData(); | ||
}, []); | ||
|
||
return { search }; //객체로 담아서 전달해주기 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { useState } from "react"; | ||
import { useSearchResult } from "@/hooks/useSearchResult"; | ||
import { SearchResultStar } from "@/components/MyStar/SearchResultStar"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { SearchBox } from "@/components/SearchBox/SearchBox"; | ||
|
||
export const SearchResultP = () => { | ||
const navigate = useNavigate(); | ||
const { result } = useSearchResult(); | ||
const resultData = result.data; | ||
console.log("resultData:", resultData); | ||
const Category = Object.keys(resultData); | ||
|
||
const moveonStarPage = (id) => { | ||
navigate(`/api/celeb/${id}/`); | ||
}; | ||
|
||
const handlesearchClick = (data) => { | ||
navigate(`/api/search?data=${data}`); | ||
}; | ||
|
||
return ( | ||
<S.Layout> | ||
<Header $margin={"1rem 0 0 0"} $padding={"1rem 1rem 0 1rem"}> | ||
검색 | ||
</Header> | ||
<S.Container> | ||
<SearchBox onsearchResult={handlesearchClick} /> | ||
{Category.map((key, index) => ( | ||
<S.CategoryWrapper key={index}> | ||
<div className="Title">{Category[index]}</div> | ||
{resultData[key].map((item) => ( | ||
<SearchResultStar | ||
key={item.id} | ||
id={item.id} | ||
src={item.src} | ||
name={item.title} | ||
profession={item.profession} | ||
onClick={() => moveonStarPage(item.url)} | ||
/> | ||
))} | ||
</S.CategoryWrapper> | ||
))} | ||
</S.Container> | ||
</S.Layout> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters