-
Notifications
You must be signed in to change notification settings - Fork 1
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 #28 from team1-booklog/dev
main으로 변경사항 반영
- Loading branch information
Showing
13 changed files
with
440 additions
and
27 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,42 @@ | ||
import { useSearchBookByName } from '../../../hooks/UseSearchBookbyName'; | ||
import { BookData } from '../../../model/BookData'; | ||
import BookCardComponent from '../../common/BookCardComponent'; | ||
|
||
interface SearchResultsProps { | ||
searchText: string; | ||
onResultClick: (result: string) => void; | ||
setBookIsbn: (value: string) => void; | ||
} | ||
|
||
export default function SearchResults({ searchText, onResultClick, setBookIsbn }: SearchResultsProps) { | ||
const { books, error, loading } = useSearchBookByName(searchText); | ||
|
||
const handleBookClick = (book:any) => { | ||
onResultClick(book.title); | ||
setBookIsbn(book.isbn); | ||
}; | ||
|
||
return ( | ||
<div className="p-4 relative"> | ||
{loading && <p className="text-center">Loading...</p>} | ||
{error && <p className="text-center text-red-500">{error}</p>} | ||
|
||
{/* 검색 결과 목록 */} | ||
<div | ||
className="absolute top-0 left-0 w-full bg-white shadow-lg rounded-lg z-50 mt-2" | ||
style={{ zIndex: 1 }} | ||
> | ||
<div className="grid grid-cols-3 xl:grid-cols-4 gap-4 max-w-4xl mx-auto px-4"> | ||
{!loading && !error && books.map((book: BookData, index: number) => ( | ||
<BookCardComponent | ||
key={index} | ||
title={book.title} | ||
imageUrl={book.image} | ||
onClick={() => handleBookClick(book)} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
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,49 @@ | ||
import cn from '../../libs/cn'; | ||
import Back from '../../assets/icons/Back.svg'; | ||
|
||
interface FooterProps { | ||
isPostOk: boolean; | ||
onPost: () => void; | ||
onCancel: () => void; | ||
} | ||
|
||
export default function Footer({isPostOk, onPost, onCancel}: FooterProps) { | ||
|
||
const handlePostButton = () => { | ||
if (isPostOk) { | ||
onPost(); | ||
} else { | ||
alert('제목과 내용을 입력해주세요.'); | ||
} | ||
}; | ||
|
||
return ( | ||
<footer | ||
className={cn( | ||
"bg-[#2B5877] flex justify-between p-2 md:p-5 w-full", | ||
"fixed bottom-0 left-0 h-[60px] md:h-[80px]" | ||
)} | ||
> | ||
<button | ||
onClick={onCancel} | ||
className='text-white font-semibold flex items-center' | ||
> | ||
<img | ||
src={Back} | ||
alt="Back" | ||
className="w-4 md:w-6 h-4 md:h-6 inline mr-2" | ||
/> | ||
작성취소 | ||
</button> | ||
<button | ||
onClick={handlePostButton} | ||
className={cn( | ||
"bg-white border rounded-lg p-2", | ||
`${isPostOk ? 'text-[#EC6B53] border-[#EC6B53]' : 'text-gray-400 border-gray-400'}` | ||
)} | ||
> | ||
게시하기 | ||
</button> | ||
</footer> | ||
); | ||
} |
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,60 @@ | ||
import { useState, useEffect } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
import SearchBar from './BookReportHeader/SearchBar'; | ||
import SearchResults from './BookReportHeader/SearchResults'; | ||
|
||
interface SearchProps { | ||
setBookIsbn: (isbn: string) => void; | ||
} | ||
|
||
export default function Search({setBookIsbn}: SearchProps) { | ||
const [readBookTitle, setReadBookTitle] = useState<string>(''); | ||
const [searchText, setSearchText] = useState<string>(''); // 검색어 상태 추가 | ||
|
||
const location = useLocation(); | ||
const searchParams = new URLSearchParams(location.search); | ||
const isbnFromUrl = searchParams.get('isbn'); | ||
const bookTitleFromUrl = searchParams.get('bookTitle'); | ||
|
||
useEffect(() => { | ||
if (isbnFromUrl) { | ||
setBookIsbn(isbnFromUrl); | ||
console.log('isbnFromUrl : ', isbnFromUrl); | ||
} else { | ||
console.log('isbnFromUrl is null'); | ||
} | ||
if (bookTitleFromUrl) { | ||
setReadBookTitle(bookTitleFromUrl); | ||
console.log('bookTitleFromUrl : ', bookTitleFromUrl); | ||
} else { | ||
console.log('bookTitleFromUrl is null'); | ||
} | ||
}, [isbnFromUrl, bookTitleFromUrl]); | ||
|
||
const handleSearch = (text: string) => { | ||
setSearchText(text); | ||
}; | ||
|
||
const handleResultClick = (result: string) => { | ||
setReadBookTitle(result); | ||
setSearchText(''); | ||
}; | ||
|
||
return ( | ||
<> | ||
{/* SearchBar 컴포넌트 */} | ||
<SearchBar | ||
readBookTitle={readBookTitle} | ||
setReadBookTitle={setReadBookTitle} | ||
onSearch={handleSearch} | ||
/> | ||
|
||
{/* SearchResults 컴포넌트에 검색어 전달 */} | ||
<SearchResults | ||
searchText={searchText} | ||
onResultClick={handleResultClick} | ||
setBookIsbn={setBookIsbn} | ||
/> | ||
</> | ||
); | ||
} |
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
Oops, something went wrong.