From 27b6ccaff8e73be6d82445aa79308059afa79d7d Mon Sep 17 00:00:00 2001 From: sbilketay Date: Mon, 17 Nov 2025 22:13:18 +0300 Subject: [PATCH] =?UTF-8?q?Kitap=20arama=20lsitesi=20z-index=20d=C3=BCzenl?= =?UTF-8?q?endi.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/UploadStep.jsx | 256 +++++++++++++++++++--------------- 1 file changed, 143 insertions(+), 113 deletions(-) diff --git a/src/components/UploadStep.jsx b/src/components/UploadStep.jsx index 3f313c0..82b1bb7 100644 --- a/src/components/UploadStep.jsx +++ b/src/components/UploadStep.jsx @@ -7,6 +7,7 @@ import { CardActionArea, CardContent, CardMedia, + ClickAwayListener, Divider, Grid, LinearProgress, @@ -43,6 +44,7 @@ const UploadStep = () => { const [searchError, setSearchError] = useState(null); const [selectedBookId, setSelectedBookId] = useState(bookMetadata?.id || null); const skipSearchRef = useRef(false); + const [showResults, setShowResults] = useState(false); const onDrop = useCallback( (acceptedFiles) => { @@ -110,6 +112,7 @@ const UploadStep = () => { setSearchResults([]); setSearchError(null); setSearching(false); + setShowResults(false); return; } const controller = new AbortController(); @@ -128,6 +131,7 @@ const UploadStep = () => { const items = Array.isArray(payload.items) ? payload.items : []; const normalized = items.map((item) => normalizeVolume(item)); setSearchResults(normalized); + setShowResults(Boolean(normalized.length)); if (!normalized.length) { setSearchError('Bu başlıkla eşleşen bir kayıt bulunamadı.'); } @@ -135,6 +139,7 @@ const UploadStep = () => { if (controller.signal.aborted) return; setSearchResults([]); setSearchError(error.message || 'Google Books araması başarısız oldu.'); + setShowResults(false); } finally { if (!controller.signal.aborted) { setSearching(false); @@ -164,10 +169,12 @@ const UploadStep = () => { setSelectedBookId(null); setSearchResults([]); setSearchError(null); + setShowResults(false); } else if (bookMetadata && bookMetadata.title !== value) { setBookMetadata(null); setSelectedBookId(null); } + setShowResults(Boolean(value?.trim())); }; const handleSelectBook = (book) => { @@ -177,6 +184,7 @@ const UploadStep = () => { setBookTitle(book.title || ''); setSearchResults([]); setSearchError(null); + setShowResults(false); }; const selectedBookSummary = useMemo(() => { @@ -200,17 +208,144 @@ const UploadStep = () => { {bookMetadata.authors?.length ? ` • ${bookMetadata.authors.join(', ')}` : ''} )} - + Kitap adı - + setShowResults(false)}> + + searchResults.length && setShowResults(true)} + InputProps={{ sx: { borderRadius: 2 } }} + /> + {showResults && searchResults.length > 0 && bookTitle?.trim() && ( + theme.shadows[6], + }} + > + + Google Books sonuçları + + + + } spacing={0}> + {searchResults.map((book) => { + const detailLine = [ + book.publisher, + book.publishedDate, + book.pageCount ? `${book.pageCount} sayfa` : null, + ] + .filter(Boolean) + .join(' • '); + const ratingLine = [ + book.averageRating ? `Puan ${book.averageRating}/5` : null, + book.ratingsCount ? `${book.ratingsCount} oy` : null, + book.language ? book.language.toUpperCase() : null, + ] + .filter(Boolean) + .join(' • '); + const isSelected = selectedBookId === book.id; + return ( + handleSelectBook(book)} + sx={{ + px: 2, + py: 2, + display: 'flex', + gap: 2, + alignItems: 'flex-start', + cursor: 'pointer', + bgcolor: isSelected ? 'rgba(231,193,121,0.15)' : 'transparent', + transition: 'background-color 0.2s ease', + }} + > + + {book.thumbnail ? ( + + ) : ( + + + Kapak yok + + + )} + + + + {book.title} + + {book.subtitle && ( + + {book.subtitle} + + )} + + {book.authors?.length ? book.authors.join(', ') : 'Yazar bilgisi bulunamadı'} + + {detailLine && ( + + {detailLine} + + )} + {ratingLine && ( + + {ratingLine} + + )} + {book.categories?.length > 0 && ( + + {book.categories.join(', ')} + + )} + + + ); + })} + + + + )} + + Google Books veritabanında arama yapmak için kitap adını yaz. Seçtiğin kaydın tüm meta bilgileri EPUB'a işlenecek. @@ -220,111 +355,6 @@ const UploadStep = () => { {searchError} )} - {searchResults.length > 0 && bookTitle?.trim() && ( - - - Google Books sonuçları - - - } spacing={0}> - {searchResults.map((book) => { - const detailLine = [ - book.publisher, - book.publishedDate, - book.pageCount ? `${book.pageCount} sayfa` : null, - ] - .filter(Boolean) - .join(' • '); - const ratingLine = [ - book.averageRating ? `Puan ${book.averageRating}/5` : null, - book.ratingsCount ? `${book.ratingsCount} oy` : null, - book.language ? book.language.toUpperCase() : null, - ] - .filter(Boolean) - .join(' • '); - const isSelected = selectedBookId === book.id; - return ( - handleSelectBook(book)} - sx={{ - px: 2, - py: 2, - display: 'flex', - gap: 2, - alignItems: 'flex-start', - cursor: 'pointer', - bgcolor: isSelected ? 'rgba(231,193,121,0.15)' : 'transparent', - transition: 'background-color 0.2s ease', - }} - > - - {book.thumbnail ? ( - - ) : ( - - - Kapak yok - - - )} - - - - {book.title} - - {book.subtitle && ( - - {book.subtitle} - - )} - - {book.authors?.length ? book.authors.join(', ') : 'Yazar bilgisi bulunamadı'} - - {detailLine && ( - - {detailLine} - - )} - {ratingLine && ( - - {ratingLine} - - )} - {book.categories?.length > 0 && ( - - {book.categories.join(', ')} - - )} - - - ); - })} - - - )}