Spaces:
Sleeping
Sleeping
Upload 105 files
Browse files- check_db.js +28 -28
- src/App.tsx +90 -10
- src/components/BulkEditTitleModal.tsx +204 -177
- src/components/BulkRemoveCategoryModal.tsx +265 -265
- src/components/ConfirmModal.tsx +82 -82
- src/components/CreateFolderModal.tsx +88 -0
- src/components/EtiquetadoraModal.tsx +312 -312
- src/components/LazyImageWrapper.tsx +46 -46
- src/components/MangaCard.tsx +27 -20
- src/components/MoveToFolderModal.tsx +123 -0
- src/components/SettingsModal.tsx +29 -1
- src/components/TitleManagerModal.tsx +176 -176
- src/services/manga.ts +61 -0
- src/services/reorderScript.ts +126 -126
- src/types/manga.ts +2 -0
- test_url.js +23 -23
check_db.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
| 1 |
-
import { initializeApp } from 'firebase/app';
|
| 2 |
-
import { getFirestore, collection, getDocs } from 'firebase/firestore';
|
| 3 |
-
|
| 4 |
-
const firebaseConfig = {
|
| 5 |
-
apiKey: "AIzaSyAH3jvbe0_QLzIuuv5kTMK8246HNvohvfE",
|
| 6 |
-
authDomain: "twistedbrody-9d163.firebaseapp.com",
|
| 7 |
-
projectId: "twistedbrody-9d163",
|
| 8 |
-
storageBucket: "twistedbrody-9d163.firebasestorage.app",
|
| 9 |
-
messagingSenderId: "733213514129",
|
| 10 |
-
appId: "1:733213514129:web:e9694684f5c3994ed06230",
|
| 11 |
-
measurementId: "G-N8TQ7MY42W"
|
| 12 |
-
};
|
| 13 |
-
|
| 14 |
-
const app = initializeApp(firebaseConfig);
|
| 15 |
-
const db = getFirestore(app);
|
| 16 |
-
|
| 17 |
-
async function run() {
|
| 18 |
-
const q = collection(db, "chapters");
|
| 19 |
-
const snapshot = await getDocs(q);
|
| 20 |
-
if (!snapshot.empty) {
|
| 21 |
-
const doc = snapshot.docs[0];
|
| 22 |
-
const data = doc.data();
|
| 23 |
-
console.log("Manga ID:", data.manga_id || data.mangaId);
|
| 24 |
-
console.log("Original Pages:", data.original_pages?.slice(0, 2));
|
| 25 |
-
console.log("Pages:", data.pages?.slice(0, 2));
|
| 26 |
-
}
|
| 27 |
-
}
|
| 28 |
-
run();
|
|
|
|
| 1 |
+
import { initializeApp } from 'firebase/app';
|
| 2 |
+
import { getFirestore, collection, getDocs } from 'firebase/firestore';
|
| 3 |
+
|
| 4 |
+
const firebaseConfig = {
|
| 5 |
+
apiKey: "AIzaSyAH3jvbe0_QLzIuuv5kTMK8246HNvohvfE",
|
| 6 |
+
authDomain: "twistedbrody-9d163.firebaseapp.com",
|
| 7 |
+
projectId: "twistedbrody-9d163",
|
| 8 |
+
storageBucket: "twistedbrody-9d163.firebasestorage.app",
|
| 9 |
+
messagingSenderId: "733213514129",
|
| 10 |
+
appId: "1:733213514129:web:e9694684f5c3994ed06230",
|
| 11 |
+
measurementId: "G-N8TQ7MY42W"
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
const app = initializeApp(firebaseConfig);
|
| 15 |
+
const db = getFirestore(app);
|
| 16 |
+
|
| 17 |
+
async function run() {
|
| 18 |
+
const q = collection(db, "chapters");
|
| 19 |
+
const snapshot = await getDocs(q);
|
| 20 |
+
if (!snapshot.empty) {
|
| 21 |
+
const doc = snapshot.docs[0];
|
| 22 |
+
const data = doc.data();
|
| 23 |
+
console.log("Manga ID:", data.manga_id || data.mangaId);
|
| 24 |
+
console.log("Original Pages:", data.original_pages?.slice(0, 2));
|
| 25 |
+
console.log("Pages:", data.pages?.slice(0, 2));
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
run();
|
src/App.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { Plus, Settings, Layers, User, Copy, Edit3, Tag, BookOpen } from 'lucide-react';
|
| 2 |
import { useState, useEffect, useMemo } from 'react';
|
| 3 |
import { HDComicViewer } from './components/HDComicViewer';
|
| 4 |
import { NewMangaModal } from './components/NewMangaModal';
|
|
@@ -13,6 +13,8 @@ import { CategoryFilterModal } from './components/CategoryFilterModal';
|
|
| 13 |
import { TitleManagerModal } from './components/TitleManagerModal';
|
| 14 |
import { BulkEditTitleModal } from './components/BulkEditTitleModal';
|
| 15 |
import { EtiquetadoraModal } from './components/EtiquetadoraModal';
|
|
|
|
|
|
|
| 16 |
import { Category } from './types/manga';
|
| 17 |
|
| 18 |
import { SearchBar } from './components/SearchBar';
|
|
@@ -44,6 +46,10 @@ function App() {
|
|
| 44 |
const [isCategoryMinusEnabled, setIsCategoryMinusEnabled] = useState(false);
|
| 45 |
const [isEditTitlePlusEnabled, setIsEditTitlePlusEnabled] = useState(false);
|
| 46 |
const [isEtiquetadoraEnabled, setIsEtiquetadoraEnabled] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
const [selectedComicId, setSelectedComicId] = useState<string | null>(null);
|
| 48 |
const [navigationHistory, setNavigationHistory] = useState<string[]>([]);
|
| 49 |
const [selectedChapter, setSelectedChapter] = useState<{ manga: Manga; chapter: Chapter } | null>(null);
|
|
@@ -96,6 +102,9 @@ function App() {
|
|
| 96 |
setSelectedComicId(mangaId);
|
| 97 |
setShowHD(false);
|
| 98 |
}
|
|
|
|
|
|
|
|
|
|
| 99 |
} else if (hash === 'info') {
|
| 100 |
setShowInfo(true);
|
| 101 |
}
|
|
@@ -107,6 +116,7 @@ function App() {
|
|
| 107 |
setSelectedChapter(null);
|
| 108 |
setShowInfo(false);
|
| 109 |
setShowHD(false);
|
|
|
|
| 110 |
} else if (hash.startsWith('manga/')) {
|
| 111 |
if (hash.endsWith('/hd')) {
|
| 112 |
const mangaId = hash.replace('manga/', '').replace('/hd', '');
|
|
@@ -119,10 +129,18 @@ function App() {
|
|
| 119 |
}
|
| 120 |
setSelectedChapter(null);
|
| 121 |
setShowInfo(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
} else if (hash === 'info') {
|
| 123 |
setShowInfo(true);
|
| 124 |
setSelectedComicId(null);
|
| 125 |
setSelectedChapter(null);
|
|
|
|
| 126 |
}
|
| 127 |
};
|
| 128 |
|
|
@@ -131,10 +149,10 @@ function App() {
|
|
| 131 |
}, []);
|
| 132 |
|
| 133 |
useEffect(() => {
|
| 134 |
-
if (!isCategoryPlusEnabled && !isCopyIdsEnabled && !isDeletePlusEnabled && !isCategoryMinusEnabled && !isEditTitlePlusEnabled && !isEtiquetadoraEnabled) {
|
| 135 |
setSelectedMangaIds([]);
|
| 136 |
}
|
| 137 |
-
}, [isCategoryPlusEnabled, isCopyIdsEnabled, isDeletePlusEnabled, isCategoryMinusEnabled, isEditTitlePlusEnabled, isEtiquetadoraEnabled]);
|
| 138 |
|
| 139 |
async function loadMangas() {
|
| 140 |
try {
|
|
@@ -195,11 +213,13 @@ function App() {
|
|
| 195 |
|
| 196 |
const sorted = [...items];
|
| 197 |
|
|
|
|
|
|
|
| 198 |
if (sortType === 'random') {
|
| 199 |
-
return
|
| 200 |
}
|
| 201 |
|
| 202 |
-
|
| 203 |
let compareValue = 0;
|
| 204 |
|
| 205 |
if (sortType === 'name') {
|
|
@@ -223,8 +243,8 @@ function App() {
|
|
| 223 |
return sortDirection === 'asc' ? compareValue : -compareValue;
|
| 224 |
});
|
| 225 |
|
| 226 |
-
return
|
| 227 |
-
}, [mangas, searchTerm, searchResult.items, sortType, sortDirection, selectedCategories, selectedAuthors]);
|
| 228 |
|
| 229 |
const handleEditManga = (manga: Manga) => {
|
| 230 |
setEditingManga(manga);
|
|
@@ -252,10 +272,15 @@ function App() {
|
|
| 252 |
};
|
| 253 |
|
| 254 |
const handleSelectComic = (mangaId: string) => {
|
| 255 |
-
if (isCategoryPlusEnabled || isCopyIdsEnabled || isDeletePlusEnabled || isCategoryMinusEnabled || isEditTitlePlusEnabled || isEtiquetadoraEnabled) {
|
| 256 |
toggleSelectManga(mangaId);
|
| 257 |
return;
|
| 258 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
window.location.hash = `manga/${mangaId}`;
|
| 260 |
setSelectedComicId(mangaId);
|
| 261 |
setShowHD(false);
|
|
@@ -499,6 +524,24 @@ function App() {
|
|
| 499 |
</div>
|
| 500 |
|
| 501 |
<div className="max-w-[1800px] mx-auto">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 502 |
{false ? (
|
| 503 |
<div className="hidden"></div>
|
| 504 |
) : (
|
|
@@ -512,7 +555,7 @@ function App() {
|
|
| 512 |
onSelectComic={handleSelectComic}
|
| 513 |
onEditManga={isAdmin ? handleEditManga : undefined}
|
| 514 |
onDeleteManga={isAdmin ? handleDeleteManga : undefined}
|
| 515 |
-
isCategoryPlusEnabled={isCategoryPlusEnabled || isCopyIdsEnabled || isDeletePlusEnabled || isCategoryMinusEnabled || isEditTitlePlusEnabled || isEtiquetadoraEnabled}
|
| 516 |
selectedMangaIds={selectedMangaIds}
|
| 517 |
onToggleSelectManga={toggleSelectManga}
|
| 518 |
/>
|
|
@@ -522,7 +565,7 @@ function App() {
|
|
| 522 |
</main>
|
| 523 |
|
| 524 |
{/* Bulk Action Bar */}
|
| 525 |
-
{(isCategoryPlusEnabled || isCopyIdsEnabled || isDeletePlusEnabled || isCategoryMinusEnabled || isEditTitlePlusEnabled || isEtiquetadoraEnabled) && selectedMangaIds.length > 0 && (
|
| 526 |
<div className="fixed bottom-6 left-1/2 transform -translate-x-1/2 z-40 animate-in slide-in-from-bottom-4 duration-200">
|
| 527 |
<div className="bg-[#1a1a1a] border border-gray-700/50 shadow-2xl rounded-xl px-6 py-3 flex items-center gap-4">
|
| 528 |
<div className="flex flex-col">
|
|
@@ -537,6 +580,22 @@ function App() {
|
|
| 537 |
Cancelar
|
| 538 |
</button>
|
| 539 |
<div className="flex gap-2">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
{isCategoryPlusEnabled && (
|
| 541 |
<button
|
| 542 |
onClick={() => setShowBulkModal(true)}
|
|
@@ -672,6 +731,25 @@ function App() {
|
|
| 672 |
setSelectedMangaIds([]);
|
| 673 |
}}
|
| 674 |
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 675 |
|
| 676 |
<SettingsModal
|
| 677 |
isOpen={showSettingsModal}
|
|
@@ -690,6 +768,8 @@ function App() {
|
|
| 690 |
onEditTitlePlusChange={setIsEditTitlePlusEnabled}
|
| 691 |
isEtiquetadoraEnabled={isEtiquetadoraEnabled}
|
| 692 |
onEtiquetadoraChange={setIsEtiquetadoraEnabled}
|
|
|
|
|
|
|
| 693 |
onOpenTitleManager={() => setShowTitleManagerModal(true)}
|
| 694 |
/>
|
| 695 |
|
|
|
|
| 1 |
+
import { Plus, Settings, Layers, User, Copy, Edit3, Tag, BookOpen, Folder, ArrowLeft } from 'lucide-react';
|
| 2 |
import { useState, useEffect, useMemo } from 'react';
|
| 3 |
import { HDComicViewer } from './components/HDComicViewer';
|
| 4 |
import { NewMangaModal } from './components/NewMangaModal';
|
|
|
|
| 13 |
import { TitleManagerModal } from './components/TitleManagerModal';
|
| 14 |
import { BulkEditTitleModal } from './components/BulkEditTitleModal';
|
| 15 |
import { EtiquetadoraModal } from './components/EtiquetadoraModal';
|
| 16 |
+
import { CreateFolderModal } from './components/CreateFolderModal';
|
| 17 |
+
import { MoveToFolderModal } from './components/MoveToFolderModal';
|
| 18 |
import { Category } from './types/manga';
|
| 19 |
|
| 20 |
import { SearchBar } from './components/SearchBar';
|
|
|
|
| 46 |
const [isCategoryMinusEnabled, setIsCategoryMinusEnabled] = useState(false);
|
| 47 |
const [isEditTitlePlusEnabled, setIsEditTitlePlusEnabled] = useState(false);
|
| 48 |
const [isEtiquetadoraEnabled, setIsEtiquetadoraEnabled] = useState(false);
|
| 49 |
+
const [isFolderPlusEnabled, setIsFolderPlusEnabled] = useState(false);
|
| 50 |
+
const [currentFolderId, setCurrentFolderId] = useState<string | null>(null);
|
| 51 |
+
const [showCreateFolderModal, setShowCreateFolderModal] = useState(false);
|
| 52 |
+
const [showMoveToFolderModal, setShowMoveToFolderModal] = useState(false);
|
| 53 |
const [selectedComicId, setSelectedComicId] = useState<string | null>(null);
|
| 54 |
const [navigationHistory, setNavigationHistory] = useState<string[]>([]);
|
| 55 |
const [selectedChapter, setSelectedChapter] = useState<{ manga: Manga; chapter: Chapter } | null>(null);
|
|
|
|
| 102 |
setSelectedComicId(mangaId);
|
| 103 |
setShowHD(false);
|
| 104 |
}
|
| 105 |
+
} else if (hash && hash.startsWith('folder/')) {
|
| 106 |
+
const folderId = hash.replace('folder/', '');
|
| 107 |
+
setCurrentFolderId(folderId);
|
| 108 |
} else if (hash === 'info') {
|
| 109 |
setShowInfo(true);
|
| 110 |
}
|
|
|
|
| 116 |
setSelectedChapter(null);
|
| 117 |
setShowInfo(false);
|
| 118 |
setShowHD(false);
|
| 119 |
+
setCurrentFolderId(null);
|
| 120 |
} else if (hash.startsWith('manga/')) {
|
| 121 |
if (hash.endsWith('/hd')) {
|
| 122 |
const mangaId = hash.replace('manga/', '').replace('/hd', '');
|
|
|
|
| 129 |
}
|
| 130 |
setSelectedChapter(null);
|
| 131 |
setShowInfo(false);
|
| 132 |
+
setCurrentFolderId(null);
|
| 133 |
+
} else if (hash.startsWith('folder/')) {
|
| 134 |
+
setCurrentFolderId(hash.replace('folder/', ''));
|
| 135 |
+
setSelectedComicId(null);
|
| 136 |
+
setSelectedChapter(null);
|
| 137 |
+
setShowInfo(false);
|
| 138 |
+
setShowHD(false);
|
| 139 |
} else if (hash === 'info') {
|
| 140 |
setShowInfo(true);
|
| 141 |
setSelectedComicId(null);
|
| 142 |
setSelectedChapter(null);
|
| 143 |
+
setCurrentFolderId(null);
|
| 144 |
}
|
| 145 |
};
|
| 146 |
|
|
|
|
| 149 |
}, []);
|
| 150 |
|
| 151 |
useEffect(() => {
|
| 152 |
+
if (!isCategoryPlusEnabled && !isCopyIdsEnabled && !isDeletePlusEnabled && !isCategoryMinusEnabled && !isEditTitlePlusEnabled && !isEtiquetadoraEnabled && !isFolderPlusEnabled) {
|
| 153 |
setSelectedMangaIds([]);
|
| 154 |
}
|
| 155 |
+
}, [isCategoryPlusEnabled, isCopyIdsEnabled, isDeletePlusEnabled, isCategoryMinusEnabled, isEditTitlePlusEnabled, isEtiquetadoraEnabled, isFolderPlusEnabled]);
|
| 156 |
|
| 157 |
async function loadMangas() {
|
| 158 |
try {
|
|
|
|
| 213 |
|
| 214 |
const sorted = [...items];
|
| 215 |
|
| 216 |
+
const filteredByFolder = sorted.filter(m => (m.folder_id || null) === (currentFolderId || null));
|
| 217 |
+
|
| 218 |
if (sortType === 'random') {
|
| 219 |
+
return filteredByFolder.sort(() => Math.random() - 0.5);
|
| 220 |
}
|
| 221 |
|
| 222 |
+
filteredByFolder.sort((a, b) => {
|
| 223 |
let compareValue = 0;
|
| 224 |
|
| 225 |
if (sortType === 'name') {
|
|
|
|
| 243 |
return sortDirection === 'asc' ? compareValue : -compareValue;
|
| 244 |
});
|
| 245 |
|
| 246 |
+
return filteredByFolder;
|
| 247 |
+
}, [mangas, searchTerm, searchResult.items, sortType, sortDirection, selectedCategories, selectedAuthors, currentFolderId]);
|
| 248 |
|
| 249 |
const handleEditManga = (manga: Manga) => {
|
| 250 |
setEditingManga(manga);
|
|
|
|
| 272 |
};
|
| 273 |
|
| 274 |
const handleSelectComic = (mangaId: string) => {
|
| 275 |
+
if (isCategoryPlusEnabled || isCopyIdsEnabled || isDeletePlusEnabled || isCategoryMinusEnabled || isEditTitlePlusEnabled || isEtiquetadoraEnabled || isFolderPlusEnabled) {
|
| 276 |
toggleSelectManga(mangaId);
|
| 277 |
return;
|
| 278 |
}
|
| 279 |
+
const manga = mangas.find(m => m.id === mangaId);
|
| 280 |
+
if (manga?.is_folder) {
|
| 281 |
+
window.location.hash = `folder/${mangaId}`;
|
| 282 |
+
return;
|
| 283 |
+
}
|
| 284 |
window.location.hash = `manga/${mangaId}`;
|
| 285 |
setSelectedComicId(mangaId);
|
| 286 |
setShowHD(false);
|
|
|
|
| 524 |
</div>
|
| 525 |
|
| 526 |
<div className="max-w-[1800px] mx-auto">
|
| 527 |
+
{currentFolderId && (() => {
|
| 528 |
+
const folder = mangas.find(m => m.id === currentFolderId);
|
| 529 |
+
if (!folder) return null;
|
| 530 |
+
return (
|
| 531 |
+
<div className="mb-6 flex items-center gap-4 bg-[#1a1a1a] p-4 rounded-xl border border-gray-800 animate-in slide-in-from-top-2">
|
| 532 |
+
<button onClick={() => { window.location.hash = ''; }} className="p-2 hover:bg-gray-800 rounded-lg text-white transition-colors">
|
| 533 |
+
<ArrowLeft className="w-5 h-5" />
|
| 534 |
+
</button>
|
| 535 |
+
<div className="w-10 h-10 rounded-lg bg-gray-800 flex items-center justify-center">
|
| 536 |
+
<Folder className="w-6 h-6 text-purple-400" />
|
| 537 |
+
</div>
|
| 538 |
+
<div>
|
| 539 |
+
<h2 className="text-xl font-bold text-white uppercase tracking-wider">{folder.title}</h2>
|
| 540 |
+
<p className="text-sm text-gray-400">Carpeta • {mangas.filter(m => m.folder_id === folder.id).length} elementos</p>
|
| 541 |
+
</div>
|
| 542 |
+
</div>
|
| 543 |
+
);
|
| 544 |
+
})()}
|
| 545 |
{false ? (
|
| 546 |
<div className="hidden"></div>
|
| 547 |
) : (
|
|
|
|
| 555 |
onSelectComic={handleSelectComic}
|
| 556 |
onEditManga={isAdmin ? handleEditManga : undefined}
|
| 557 |
onDeleteManga={isAdmin ? handleDeleteManga : undefined}
|
| 558 |
+
isCategoryPlusEnabled={isCategoryPlusEnabled || isCopyIdsEnabled || isDeletePlusEnabled || isCategoryMinusEnabled || isEditTitlePlusEnabled || isEtiquetadoraEnabled || isFolderPlusEnabled}
|
| 559 |
selectedMangaIds={selectedMangaIds}
|
| 560 |
onToggleSelectManga={toggleSelectManga}
|
| 561 |
/>
|
|
|
|
| 565 |
</main>
|
| 566 |
|
| 567 |
{/* Bulk Action Bar */}
|
| 568 |
+
{(isCategoryPlusEnabled || isCopyIdsEnabled || isDeletePlusEnabled || isCategoryMinusEnabled || isEditTitlePlusEnabled || isEtiquetadoraEnabled || isFolderPlusEnabled) && selectedMangaIds.length > 0 && (
|
| 569 |
<div className="fixed bottom-6 left-1/2 transform -translate-x-1/2 z-40 animate-in slide-in-from-bottom-4 duration-200">
|
| 570 |
<div className="bg-[#1a1a1a] border border-gray-700/50 shadow-2xl rounded-xl px-6 py-3 flex items-center gap-4">
|
| 571 |
<div className="flex flex-col">
|
|
|
|
| 580 |
Cancelar
|
| 581 |
</button>
|
| 582 |
<div className="flex gap-2">
|
| 583 |
+
{isFolderPlusEnabled && (
|
| 584 |
+
<>
|
| 585 |
+
<button
|
| 586 |
+
onClick={() => setShowCreateFolderModal(true)}
|
| 587 |
+
className="bg-indigo-500 hover:bg-indigo-600 text-white px-4 py-2 rounded-lg text-sm font-bold shadow-lg shadow-indigo-500/20 transition-all transform hover:scale-105 active:scale-95 flex items-center gap-2"
|
| 588 |
+
>
|
| 589 |
+
Crear Carpeta
|
| 590 |
+
</button>
|
| 591 |
+
<button
|
| 592 |
+
onClick={() => setShowMoveToFolderModal(true)}
|
| 593 |
+
className="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-bold shadow-lg shadow-blue-500/20 transition-all transform hover:scale-105 active:scale-95 flex items-center gap-2"
|
| 594 |
+
>
|
| 595 |
+
Mover a Carpeta
|
| 596 |
+
</button>
|
| 597 |
+
</>
|
| 598 |
+
)}
|
| 599 |
{isCategoryPlusEnabled && (
|
| 600 |
<button
|
| 601 |
onClick={() => setShowBulkModal(true)}
|
|
|
|
| 731 |
setSelectedMangaIds([]);
|
| 732 |
}}
|
| 733 |
/>
|
| 734 |
+
<CreateFolderModal
|
| 735 |
+
isOpen={showCreateFolderModal}
|
| 736 |
+
onClose={() => setShowCreateFolderModal(false)}
|
| 737 |
+
selectedMangaIds={selectedMangaIds}
|
| 738 |
+
onSaveComplete={() => {
|
| 739 |
+
loadMangas();
|
| 740 |
+
setSelectedMangaIds([]);
|
| 741 |
+
}}
|
| 742 |
+
/>
|
| 743 |
+
<MoveToFolderModal
|
| 744 |
+
isOpen={showMoveToFolderModal}
|
| 745 |
+
onClose={() => setShowMoveToFolderModal(false)}
|
| 746 |
+
selectedMangaIds={selectedMangaIds}
|
| 747 |
+
mangas={mangas}
|
| 748 |
+
onSaveComplete={() => {
|
| 749 |
+
loadMangas();
|
| 750 |
+
setSelectedMangaIds([]);
|
| 751 |
+
}}
|
| 752 |
+
/>
|
| 753 |
|
| 754 |
<SettingsModal
|
| 755 |
isOpen={showSettingsModal}
|
|
|
|
| 768 |
onEditTitlePlusChange={setIsEditTitlePlusEnabled}
|
| 769 |
isEtiquetadoraEnabled={isEtiquetadoraEnabled}
|
| 770 |
onEtiquetadoraChange={setIsEtiquetadoraEnabled}
|
| 771 |
+
isFolderPlusEnabled={isFolderPlusEnabled}
|
| 772 |
+
onFolderPlusChange={setIsFolderPlusEnabled}
|
| 773 |
onOpenTitleManager={() => setShowTitleManagerModal(true)}
|
| 774 |
/>
|
| 775 |
|
src/components/BulkEditTitleModal.tsx
CHANGED
|
@@ -1,177 +1,204 @@
|
|
| 1 |
-
import { useState, useMemo, useEffect } from 'react';
|
| 2 |
-
import { X, Search, Save, Edit3 } from 'lucide-react';
|
| 3 |
-
import { Manga } from '../types/manga';
|
| 4 |
-
import { toast } from 'sonner';
|
| 5 |
-
import { updateMangaTitles } from '../services/manga';
|
| 6 |
-
import { getThumbnailUrl } from '../utils/imageUtils';
|
| 7 |
-
|
| 8 |
-
interface BulkEditTitleModalProps {
|
| 9 |
-
isOpen: boolean;
|
| 10 |
-
onClose: () => void;
|
| 11 |
-
mangas: Manga[];
|
| 12 |
-
selectedMangaIds: string[];
|
| 13 |
-
onSaveComplete: () => void;
|
| 14 |
-
}
|
| 15 |
-
|
| 16 |
-
export function BulkEditTitleModal({ isOpen, onClose, mangas, selectedMangaIds, onSaveComplete }: BulkEditTitleModalProps) {
|
| 17 |
-
const [searchTerm, setSearchTerm] = useState('');
|
| 18 |
-
const [
|
| 19 |
-
const [
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
<
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useMemo, useEffect } from 'react';
|
| 2 |
+
import { X, Search, Save, Edit3 } from 'lucide-react';
|
| 3 |
+
import { Manga } from '../types/manga';
|
| 4 |
+
import { toast } from 'sonner';
|
| 5 |
+
import { updateMangaTitles } from '../services/manga';
|
| 6 |
+
import { getThumbnailUrl } from '../utils/imageUtils';
|
| 7 |
+
|
| 8 |
+
interface BulkEditTitleModalProps {
|
| 9 |
+
isOpen: boolean;
|
| 10 |
+
onClose: () => void;
|
| 11 |
+
mangas: Manga[];
|
| 12 |
+
selectedMangaIds: string[];
|
| 13 |
+
onSaveComplete: () => void;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
export function BulkEditTitleModal({ isOpen, onClose, mangas, selectedMangaIds, onSaveComplete }: BulkEditTitleModalProps) {
|
| 17 |
+
const [searchTerm, setSearchTerm] = useState('');
|
| 18 |
+
const [bulkName, setBulkName] = useState('');
|
| 19 |
+
const [edits, setEdits] = useState<Record<string, string>>({});
|
| 20 |
+
const [isSaving, setIsSaving] = useState(false);
|
| 21 |
+
|
| 22 |
+
useEffect(() => {
|
| 23 |
+
if (isOpen) {
|
| 24 |
+
setSearchTerm('');
|
| 25 |
+
setBulkName('');
|
| 26 |
+
setEdits({});
|
| 27 |
+
}
|
| 28 |
+
}, [isOpen]);
|
| 29 |
+
|
| 30 |
+
const handleApplyBulkName = () => {
|
| 31 |
+
if (!bulkName.trim()) return;
|
| 32 |
+
const newEdits = { ...edits };
|
| 33 |
+
mangas.filter(m => selectedMangaIds.includes(m.id)).forEach(m => {
|
| 34 |
+
newEdits[m.id] = bulkName;
|
| 35 |
+
});
|
| 36 |
+
setEdits(newEdits);
|
| 37 |
+
toast.success(`Nombre aplicado a ${selectedMangaIds.length} mangas localmente`);
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
const sortedAndFilteredMangas = useMemo(() => {
|
| 41 |
+
let result = mangas.filter(m => selectedMangaIds.includes(m.id));
|
| 42 |
+
if (searchTerm) {
|
| 43 |
+
const lowerQuery = searchTerm.toLowerCase();
|
| 44 |
+
result = result.filter(m => m.title.toLowerCase().includes(lowerQuery));
|
| 45 |
+
}
|
| 46 |
+
return result.sort((a, b) => a.title.localeCompare(b.title));
|
| 47 |
+
}, [mangas, selectedMangaIds, searchTerm]);
|
| 48 |
+
|
| 49 |
+
const handleTitleChange = (id: string, newTitle: string) => {
|
| 50 |
+
setEdits(prev => ({
|
| 51 |
+
...prev,
|
| 52 |
+
[id]: newTitle
|
| 53 |
+
}));
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
const handleSave = async () => {
|
| 57 |
+
const modifications = Object.entries(edits).filter(([id, newTitle]) => {
|
| 58 |
+
const originalManga = mangas.find(m => m.id === id);
|
| 59 |
+
return originalManga && originalManga.title !== newTitle.trim() && newTitle.trim() !== '';
|
| 60 |
+
});
|
| 61 |
+
|
| 62 |
+
if (modifications.length === 0) {
|
| 63 |
+
toast.info('No hay cambios para guardar');
|
| 64 |
+
return;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
try {
|
| 68 |
+
setIsSaving(true);
|
| 69 |
+
const updates = modifications.map(([id, title]) => ({ id, title: title.trim() }));
|
| 70 |
+
await updateMangaTitles(updates);
|
| 71 |
+
toast.success(`Se actualizaron ${updates.length} nombres correctamente`);
|
| 72 |
+
onSaveComplete();
|
| 73 |
+
onClose();
|
| 74 |
+
} catch (error) {
|
| 75 |
+
console.error('Error saving titles:', error);
|
| 76 |
+
toast.error('Error al guardar los cambios');
|
| 77 |
+
} finally {
|
| 78 |
+
setIsSaving(false);
|
| 79 |
+
}
|
| 80 |
+
};
|
| 81 |
+
|
| 82 |
+
if (!isOpen) return null;
|
| 83 |
+
|
| 84 |
+
return (
|
| 85 |
+
<div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-[60] p-4 animate-in fade-in duration-200">
|
| 86 |
+
<div className="bg-[#121212] rounded-2xl border border-gray-800 w-full max-w-2xl shadow-2xl overflow-hidden flex flex-col max-h-[85vh]">
|
| 87 |
+
<div className="bg-[#1a1a1a] border-b border-gray-800 px-6 py-4 flex items-center justify-between sticky top-0 z-10 flex-shrink-0">
|
| 88 |
+
<div className="flex items-center gap-3">
|
| 89 |
+
<div className="p-2 bg-pink-500/10 rounded-lg text-pink-400">
|
| 90 |
+
<Edit3 className="w-5 h-5" />
|
| 91 |
+
</div>
|
| 92 |
+
<div>
|
| 93 |
+
<h2 className="text-xl font-bold text-white">Editar Nombres</h2>
|
| 94 |
+
<p className="text-xs text-gray-400">Edita los títulos de los {selectedMangaIds.length} mangas seleccionados</p>
|
| 95 |
+
</div>
|
| 96 |
+
</div>
|
| 97 |
+
<button onClick={onClose} className="text-gray-400 hover:text-white transition-colors p-2 hover:bg-white/5 rounded-lg">
|
| 98 |
+
<X className="w-5 h-5" />
|
| 99 |
+
</button>
|
| 100 |
+
</div>
|
| 101 |
+
|
| 102 |
+
<div className="p-4 border-b border-gray-800 bg-[#121212] flex-shrink-0 space-y-3">
|
| 103 |
+
<div className="relative">
|
| 104 |
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400" />
|
| 105 |
+
<input
|
| 106 |
+
type="text"
|
| 107 |
+
value={searchTerm}
|
| 108 |
+
onChange={(e) => setSearchTerm(e.target.value)}
|
| 109 |
+
placeholder="Filtrar manga por título..."
|
| 110 |
+
className="w-full bg-[#1a1a1a] border border-gray-700 rounded-xl pl-10 pr-4 py-3 text-sm text-white focus:outline-none focus:border-pink-500 transition-colors"
|
| 111 |
+
/>
|
| 112 |
+
</div>
|
| 113 |
+
<div className="flex gap-2">
|
| 114 |
+
<input
|
| 115 |
+
type="text"
|
| 116 |
+
value={bulkName}
|
| 117 |
+
onChange={(e) => setBulkName(e.target.value)}
|
| 118 |
+
placeholder="Pon un nombre para aplicar a todos los seleccionados (Opcional)"
|
| 119 |
+
className="flex-1 bg-[#1a1a1a] border border-gray-700 rounded-xl px-4 py-3 text-sm text-white focus:outline-none focus:border-pink-500 transition-colors"
|
| 120 |
+
/>
|
| 121 |
+
<button
|
| 122 |
+
onClick={handleApplyBulkName}
|
| 123 |
+
className="bg-gray-800 hover:bg-gray-700 text-white px-6 py-3 rounded-xl text-sm font-medium transition-colors whitespace-nowrap"
|
| 124 |
+
>
|
| 125 |
+
Aplicar a todos
|
| 126 |
+
</button>
|
| 127 |
+
</div>
|
| 128 |
+
</div>
|
| 129 |
+
|
| 130 |
+
<div className="flex-1 overflow-y-auto p-4 space-y-2 custom-scrollbar">
|
| 131 |
+
{sortedAndFilteredMangas.map((manga) => {
|
| 132 |
+
const originalSrc = manga.cover_url || manga.thumbnail_url;
|
| 133 |
+
const optimizedSrc = originalSrc ? getThumbnailUrl(originalSrc) : undefined;
|
| 134 |
+
return (
|
| 135 |
+
<div key={manga.id} className="flex items-center gap-3 bg-[#1a1a1a] p-3 rounded-lg border border-gray-800/50 hover:border-gray-700 transition-colors">
|
| 136 |
+
{optimizedSrc ? (
|
| 137 |
+
<img
|
| 138 |
+
src={optimizedSrc}
|
| 139 |
+
alt=""
|
| 140 |
+
className="w-10 h-10 rounded object-cover"
|
| 141 |
+
/>
|
| 142 |
+
) : (
|
| 143 |
+
<div className="w-10 h-10 rounded bg-gray-800 flex items-center justify-center">
|
| 144 |
+
<span className="text-xs text-gray-500 text-center">Sin img</span>
|
| 145 |
+
</div>
|
| 146 |
+
)}
|
| 147 |
+
<div className="flex-1">
|
| 148 |
+
<input
|
| 149 |
+
type="text"
|
| 150 |
+
value={edits[manga.id] !== undefined ? edits[manga.id] : manga.title}
|
| 151 |
+
onChange={(e) => handleTitleChange(manga.id, e.target.value)}
|
| 152 |
+
className={`w-full bg-transparent border-b pl-2 py-1 text-sm focus:outline-none transition-colors ${
|
| 153 |
+
edits[manga.id] !== undefined && edits[manga.id].trim() !== manga.title
|
| 154 |
+
? 'border-pink-500 text-pink-300'
|
| 155 |
+
: 'border-transparent hover:border-gray-700 text-white focus:border-gray-600'
|
| 156 |
+
}`}
|
| 157 |
+
placeholder="Título del manga"
|
| 158 |
+
/>
|
| 159 |
+
</div>
|
| 160 |
+
</div>
|
| 161 |
+
);
|
| 162 |
+
})}
|
| 163 |
+
{sortedAndFilteredMangas.length === 0 && (
|
| 164 |
+
<div className="text-center py-8 text-gray-500">
|
| 165 |
+
No se encontraron mangas con ese nombre en la selección
|
| 166 |
+
</div>
|
| 167 |
+
)}
|
| 168 |
+
</div>
|
| 169 |
+
|
| 170 |
+
<div className="bg-[#1a1a1a] border-t border-gray-800 px-6 py-4 flex justify-between items-center sticky bottom-0 flex-shrink-0">
|
| 171 |
+
<span className="text-sm text-gray-400">
|
| 172 |
+
{Object.keys(edits).filter(id => edits[id].trim() !== mangas.find(m => m.id === id)?.title).length} cambios pendientes
|
| 173 |
+
</span>
|
| 174 |
+
<div className="flex gap-3">
|
| 175 |
+
<button
|
| 176 |
+
onClick={onClose}
|
| 177 |
+
className="px-4 py-2 text-sm font-semibold text-gray-300 hover:text-white transition-colors"
|
| 178 |
+
disabled={isSaving}
|
| 179 |
+
>
|
| 180 |
+
Cancelar
|
| 181 |
+
</button>
|
| 182 |
+
<button
|
| 183 |
+
onClick={handleSave}
|
| 184 |
+
disabled={isSaving}
|
| 185 |
+
className="bg-pink-600 hover:bg-pink-700 disabled:opacity-50 disabled:cursor-not-allowed text-white px-6 py-2 rounded-lg text-sm font-bold shadow-lg shadow-pink-500/20 transition-all flex items-center gap-2"
|
| 186 |
+
>
|
| 187 |
+
{isSaving ? (
|
| 188 |
+
<>
|
| 189 |
+
<div className="w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin" />
|
| 190 |
+
Guardando...
|
| 191 |
+
</>
|
| 192 |
+
) : (
|
| 193 |
+
<>
|
| 194 |
+
<Save className="w-4 h-4" />
|
| 195 |
+
Guardar Cambios
|
| 196 |
+
</>
|
| 197 |
+
)}
|
| 198 |
+
</button>
|
| 199 |
+
</div>
|
| 200 |
+
</div>
|
| 201 |
+
</div>
|
| 202 |
+
</div>
|
| 203 |
+
);
|
| 204 |
+
}
|
src/components/BulkRemoveCategoryModal.tsx
CHANGED
|
@@ -1,265 +1,265 @@
|
|
| 1 |
-
import { X, Save, Trash2 } from 'lucide-react';
|
| 2 |
-
import { toast } from 'sonner';
|
| 3 |
-
import { useState, useEffect } from 'react';
|
| 4 |
-
import { Category, Manga } from '../types/manga';
|
| 5 |
-
import { updateManga, getMangaById } from '../services/manga';
|
| 6 |
-
import { LoadingSpinner } from './LoadingSpinner';
|
| 7 |
-
|
| 8 |
-
interface BulkRemoveCategoryModalProps {
|
| 9 |
-
isOpen: boolean;
|
| 10 |
-
onClose: () => void;
|
| 11 |
-
selectedMangaIds: string[];
|
| 12 |
-
onSaveComplete: () => void;
|
| 13 |
-
}
|
| 14 |
-
|
| 15 |
-
export function BulkRemoveCategoryModal({ isOpen, onClose, selectedMangaIds, onSaveComplete }: BulkRemoveCategoryModalProps) {
|
| 16 |
-
const [availableCategories, setAvailableCategories] = useState<Category[]>([]);
|
| 17 |
-
const [availableAuthors, setAvailableAuthors] = useState<string[]>([]);
|
| 18 |
-
|
| 19 |
-
// The items the user selects TO REMOVE
|
| 20 |
-
const [selectedCategoryIdsToRemove, setSelectedCategoryIdsToRemove] = useState<string[]>([]);
|
| 21 |
-
const [selectedAuthorsToRemove, setSelectedAuthorsToRemove] = useState<string[]>([]);
|
| 22 |
-
|
| 23 |
-
const [isSaving, setIsSaving] = useState(false);
|
| 24 |
-
const [isLoading, setIsLoading] = useState(false);
|
| 25 |
-
|
| 26 |
-
useEffect(() => {
|
| 27 |
-
if (isOpen) {
|
| 28 |
-
loadMangasData();
|
| 29 |
-
setSelectedCategoryIdsToRemove([]);
|
| 30 |
-
setSelectedAuthorsToRemove([]);
|
| 31 |
-
}
|
| 32 |
-
}, [isOpen]);
|
| 33 |
-
|
| 34 |
-
const loadMangasData = async () => {
|
| 35 |
-
try {
|
| 36 |
-
setIsLoading(true);
|
| 37 |
-
const mangasData: (Manga | null)[] = await Promise.all(
|
| 38 |
-
selectedMangaIds.map(id => getMangaById(id).catch(() => null))
|
| 39 |
-
);
|
| 40 |
-
|
| 41 |
-
const validMangas = mangasData.filter(Boolean) as Manga[];
|
| 42 |
-
|
| 43 |
-
const catMap = new Map<string, Category>();
|
| 44 |
-
const authorSet = new Set<string>();
|
| 45 |
-
|
| 46 |
-
validMangas.forEach(manga => {
|
| 47 |
-
if (manga.author) authorSet.add(manga.author);
|
| 48 |
-
if (manga.categories) {
|
| 49 |
-
manga.categories.forEach(cat => catMap.set(cat.id, cat));
|
| 50 |
-
}
|
| 51 |
-
});
|
| 52 |
-
|
| 53 |
-
setAvailableCategories(Array.from(catMap.values()));
|
| 54 |
-
setAvailableAuthors(Array.from(authorSet));
|
| 55 |
-
|
| 56 |
-
} catch (error) {
|
| 57 |
-
console.error('Error loading mangas data:', error);
|
| 58 |
-
toast.error('Error al cargar datos de los mangas');
|
| 59 |
-
} finally {
|
| 60 |
-
setIsLoading(false);
|
| 61 |
-
}
|
| 62 |
-
};
|
| 63 |
-
|
| 64 |
-
const toggleCategoryRemove = (id: string) => {
|
| 65 |
-
setSelectedCategoryIdsToRemove(prev =>
|
| 66 |
-
prev.includes(id) ? prev.filter(c => c !== id) : [...prev, id]
|
| 67 |
-
);
|
| 68 |
-
};
|
| 69 |
-
|
| 70 |
-
const toggleAuthorRemove = (author: string) => {
|
| 71 |
-
setSelectedAuthorsToRemove(prev =>
|
| 72 |
-
prev.includes(author) ? prev.filter(a => a !== author) : [...prev, author]
|
| 73 |
-
);
|
| 74 |
-
};
|
| 75 |
-
|
| 76 |
-
const handleSave = async () => {
|
| 77 |
-
if (selectedCategoryIdsToRemove.length === 0 && selectedAuthorsToRemove.length === 0) {
|
| 78 |
-
toast.error('Selecciona al menos una categoría o autor para eliminar.');
|
| 79 |
-
return;
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
setIsSaving(true);
|
| 83 |
-
try {
|
| 84 |
-
const updatePromises = selectedMangaIds.map(async (mangaId) => {
|
| 85 |
-
try {
|
| 86 |
-
const manga = await getMangaById(mangaId);
|
| 87 |
-
if (!manga) return;
|
| 88 |
-
|
| 89 |
-
let needsUpdate = false;
|
| 90 |
-
const updateData: any = {
|
| 91 |
-
title: manga.title,
|
| 92 |
-
author: manga.author
|
| 93 |
-
};
|
| 94 |
-
|
| 95 |
-
if (selectedAuthorsToRemove.includes(manga.author)) {
|
| 96 |
-
updateData.author = 'Desconocido';
|
| 97 |
-
needsUpdate = true;
|
| 98 |
-
}
|
| 99 |
-
|
| 100 |
-
if (manga.categories && manga.categories.length > 0) {
|
| 101 |
-
const existingIds = manga.categories.map(c => c.id);
|
| 102 |
-
const newIds = existingIds.filter(id => !selectedCategoryIdsToRemove.includes(id));
|
| 103 |
-
|
| 104 |
-
if (newIds.length !== existingIds.length) {
|
| 105 |
-
updateData.categoryIds = newIds;
|
| 106 |
-
needsUpdate = true;
|
| 107 |
-
} else {
|
| 108 |
-
updateData.categoryIds = existingIds;
|
| 109 |
-
}
|
| 110 |
-
} else {
|
| 111 |
-
updateData.categoryIds = [];
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
if (needsUpdate) {
|
| 115 |
-
await updateManga(mangaId, updateData);
|
| 116 |
-
}
|
| 117 |
-
} catch (err) {
|
| 118 |
-
console.error(`Error updating manga ${mangaId}`, err);
|
| 119 |
-
}
|
| 120 |
-
});
|
| 121 |
-
|
| 122 |
-
await Promise.all(updatePromises);
|
| 123 |
-
toast.success('Categorías eliminadas de los mangas correctamente.');
|
| 124 |
-
onSaveComplete();
|
| 125 |
-
onClose();
|
| 126 |
-
|
| 127 |
-
} catch (error) {
|
| 128 |
-
console.error('Error bulk updating mangas:', error);
|
| 129 |
-
toast.error('Error al aplicar cambios.');
|
| 130 |
-
} finally {
|
| 131 |
-
setIsSaving(false);
|
| 132 |
-
}
|
| 133 |
-
};
|
| 134 |
-
|
| 135 |
-
if (!isOpen) return null;
|
| 136 |
-
|
| 137 |
-
const renderCategorySection = (type: 'character' | 'series' | 'genre' | 'tag', title: string, colorClass: string) => {
|
| 138 |
-
const typeCategories = availableCategories.filter(c => c.type === type);
|
| 139 |
-
if (typeCategories.length === 0) return null;
|
| 140 |
-
|
| 141 |
-
return (
|
| 142 |
-
<div className="bg-[#1f1f1f] p-4 rounded-xl border border-gray-800 space-y-3">
|
| 143 |
-
<span className="text-xs font-bold text-gray-400 uppercase tracking-wider">{title}</span>
|
| 144 |
-
<div className="flex flex-wrap gap-2">
|
| 145 |
-
{typeCategories.map(cat => {
|
| 146 |
-
const isSelected = selectedCategoryIdsToRemove.includes(cat.id);
|
| 147 |
-
return (
|
| 148 |
-
<button
|
| 149 |
-
key={cat.id}
|
| 150 |
-
onClick={() => toggleCategoryRemove(cat.id)}
|
| 151 |
-
className={`px-3 py-1.5 rounded-full text-sm font-medium flex items-center gap-2 border transition-all ${
|
| 152 |
-
isSelected
|
| 153 |
-
? 'bg-red-500/20 text-red-500 border-red-500/50 hover:bg-red-500/30'
|
| 154 |
-
: `bg-[#1a1a1a] ${colorClass} border-gray-700 hover:border-gray-500`
|
| 155 |
-
}`}
|
| 156 |
-
>
|
| 157 |
-
{cat.name}
|
| 158 |
-
{isSelected && <Trash2 className="w-3.5 h-3.5" />}
|
| 159 |
-
</button>
|
| 160 |
-
);
|
| 161 |
-
})}
|
| 162 |
-
</div>
|
| 163 |
-
</div>
|
| 164 |
-
);
|
| 165 |
-
};
|
| 166 |
-
|
| 167 |
-
return (
|
| 168 |
-
<div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4 animate-in fade-in duration-200">
|
| 169 |
-
<div className="bg-[#121212] rounded-2xl border border-gray-800 w-full max-w-2xl shadow-2xl overflow-hidden flex flex-col max-h-[90vh]">
|
| 170 |
-
|
| 171 |
-
{/* Header */}
|
| 172 |
-
<div className="bg-[#1a1a1a] border-b border-gray-800 px-6 py-4 flex items-center justify-between sticky top-0 z-10">
|
| 173 |
-
<h2 className="text-xl font-bold text-white flex items-center gap-2">
|
| 174 |
-
<Trash2 className="w-5 h-5 text-red-500"/>
|
| 175 |
-
Remover Categorías en {selectedMangaIds.length} Mangas
|
| 176 |
-
</h2>
|
| 177 |
-
<button onClick={onClose} className="text-gray-400 hover:text-white transition-colors p-2 hover:bg-white/5 rounded-lg">
|
| 178 |
-
<X className="w-5 h-5" />
|
| 179 |
-
</button>
|
| 180 |
-
</div>
|
| 181 |
-
|
| 182 |
-
<div className="p-6 overflow-y-auto custom-scrollbar flex-1">
|
| 183 |
-
{isLoading ? (
|
| 184 |
-
<div className="flex flex-col items-center justify-center py-12 gap-4">
|
| 185 |
-
<LoadingSpinner size={32} />
|
| 186 |
-
<p className="text-gray-400 text-sm">Escaneando mangas seleccionados...</p>
|
| 187 |
-
</div>
|
| 188 |
-
) : availableCategories.length === 0 && availableAuthors.length === 0 ? (
|
| 189 |
-
<div className="flex flex-col items-center justify-center py-12 text-center">
|
| 190 |
-
<Trash2 className="w-12 h-12 text-gray-600 mb-3" />
|
| 191 |
-
<h3 className="text-lg font-semibold text-white">Sin categorías</h3>
|
| 192 |
-
<p className="text-gray-400 text-sm max-w-sm mt-1">Los mangas seleccionados no tienen autores ni categorías para remover.</p>
|
| 193 |
-
</div>
|
| 194 |
-
) : (
|
| 195 |
-
<div className="space-y-6">
|
| 196 |
-
<p className="text-sm text-gray-400">
|
| 197 |
-
Selecciona los autores y categorías que deseas <b className="text-red-400">eliminar</b> de los mangas seleccionados.
|
| 198 |
-
</p>
|
| 199 |
-
|
| 200 |
-
{/* Autores */}
|
| 201 |
-
{availableAuthors.length > 0 && (
|
| 202 |
-
<div className="bg-[#1f1f1f] p-4 rounded-xl border border-gray-800 space-y-3">
|
| 203 |
-
<span className="text-xs font-bold text-gray-400 uppercase tracking-wider">Autor</span>
|
| 204 |
-
<div className="flex flex-wrap gap-2">
|
| 205 |
-
{availableAuthors.map(author => {
|
| 206 |
-
const isSelected = selectedAuthorsToRemove.includes(author);
|
| 207 |
-
return (
|
| 208 |
-
<button
|
| 209 |
-
key={author}
|
| 210 |
-
onClick={() => toggleAuthorRemove(author)}
|
| 211 |
-
className={`px-3 py-1.5 rounded-full text-sm font-medium flex items-center gap-2 border transition-all ${
|
| 212 |
-
isSelected
|
| 213 |
-
? 'bg-red-500/20 text-red-500 border-red-500/50 hover:bg-red-500/30'
|
| 214 |
-
: 'bg-[#1a1a1a] text-purple-400 border-gray-700 hover:border-gray-500'
|
| 215 |
-
}`}
|
| 216 |
-
>
|
| 217 |
-
{author}
|
| 218 |
-
{isSelected && <Trash2 className="w-3.5 h-3.5" />}
|
| 219 |
-
</button>
|
| 220 |
-
);
|
| 221 |
-
})}
|
| 222 |
-
</div>
|
| 223 |
-
<p className="text-xs text-red-500/80 mt-2">* Remover al autor lo dejará como "Desconocido".</p>
|
| 224 |
-
</div>
|
| 225 |
-
)}
|
| 226 |
-
|
| 227 |
-
{/* Categorías */}
|
| 228 |
-
{renderCategorySection('character', 'Personajes', 'text-blue-400')}
|
| 229 |
-
{renderCategorySection('series', 'Series', 'text-green-400')}
|
| 230 |
-
{renderCategorySection('genre', 'Géneros', 'text-purple-400')}
|
| 231 |
-
{renderCategorySection('tag', 'Etiquetas', 'text-pink-400')}
|
| 232 |
-
</div>
|
| 233 |
-
)}
|
| 234 |
-
</div>
|
| 235 |
-
|
| 236 |
-
<div className="p-6 border-t border-gray-800 flex justify-end gap-3 bg-[#1a1a1a]">
|
| 237 |
-
<button
|
| 238 |
-
onClick={onClose}
|
| 239 |
-
className="px-4 py-2 rounded-lg text-sm font-semibold text-gray-300 hover:text-white transition-colors"
|
| 240 |
-
>
|
| 241 |
-
Cancelar
|
| 242 |
-
</button>
|
| 243 |
-
<button
|
| 244 |
-
onClick={handleSave}
|
| 245 |
-
disabled={isSaving || (selectedCategoryIdsToRemove.length === 0 && selectedAuthorsToRemove.length === 0)}
|
| 246 |
-
className="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded-lg font-semibold text-sm transition-all shadow-lg shadow-red-600/20 flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed"
|
| 247 |
-
>
|
| 248 |
-
{isSaving ? (
|
| 249 |
-
<>
|
| 250 |
-
<LoadingSpinner size={16} />
|
| 251 |
-
Eliminando...
|
| 252 |
-
</>
|
| 253 |
-
) : (
|
| 254 |
-
<>
|
| 255 |
-
<Trash2 className="w-4 h-4" />
|
| 256 |
-
Remover Selección
|
| 257 |
-
</>
|
| 258 |
-
)}
|
| 259 |
-
</button>
|
| 260 |
-
</div>
|
| 261 |
-
|
| 262 |
-
</div>
|
| 263 |
-
</div>
|
| 264 |
-
);
|
| 265 |
-
}
|
|
|
|
| 1 |
+
import { X, Save, Trash2 } from 'lucide-react';
|
| 2 |
+
import { toast } from 'sonner';
|
| 3 |
+
import { useState, useEffect } from 'react';
|
| 4 |
+
import { Category, Manga } from '../types/manga';
|
| 5 |
+
import { updateManga, getMangaById } from '../services/manga';
|
| 6 |
+
import { LoadingSpinner } from './LoadingSpinner';
|
| 7 |
+
|
| 8 |
+
interface BulkRemoveCategoryModalProps {
|
| 9 |
+
isOpen: boolean;
|
| 10 |
+
onClose: () => void;
|
| 11 |
+
selectedMangaIds: string[];
|
| 12 |
+
onSaveComplete: () => void;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
export function BulkRemoveCategoryModal({ isOpen, onClose, selectedMangaIds, onSaveComplete }: BulkRemoveCategoryModalProps) {
|
| 16 |
+
const [availableCategories, setAvailableCategories] = useState<Category[]>([]);
|
| 17 |
+
const [availableAuthors, setAvailableAuthors] = useState<string[]>([]);
|
| 18 |
+
|
| 19 |
+
// The items the user selects TO REMOVE
|
| 20 |
+
const [selectedCategoryIdsToRemove, setSelectedCategoryIdsToRemove] = useState<string[]>([]);
|
| 21 |
+
const [selectedAuthorsToRemove, setSelectedAuthorsToRemove] = useState<string[]>([]);
|
| 22 |
+
|
| 23 |
+
const [isSaving, setIsSaving] = useState(false);
|
| 24 |
+
const [isLoading, setIsLoading] = useState(false);
|
| 25 |
+
|
| 26 |
+
useEffect(() => {
|
| 27 |
+
if (isOpen) {
|
| 28 |
+
loadMangasData();
|
| 29 |
+
setSelectedCategoryIdsToRemove([]);
|
| 30 |
+
setSelectedAuthorsToRemove([]);
|
| 31 |
+
}
|
| 32 |
+
}, [isOpen]);
|
| 33 |
+
|
| 34 |
+
const loadMangasData = async () => {
|
| 35 |
+
try {
|
| 36 |
+
setIsLoading(true);
|
| 37 |
+
const mangasData: (Manga | null)[] = await Promise.all(
|
| 38 |
+
selectedMangaIds.map(id => getMangaById(id).catch(() => null))
|
| 39 |
+
);
|
| 40 |
+
|
| 41 |
+
const validMangas = mangasData.filter(Boolean) as Manga[];
|
| 42 |
+
|
| 43 |
+
const catMap = new Map<string, Category>();
|
| 44 |
+
const authorSet = new Set<string>();
|
| 45 |
+
|
| 46 |
+
validMangas.forEach(manga => {
|
| 47 |
+
if (manga.author) authorSet.add(manga.author);
|
| 48 |
+
if (manga.categories) {
|
| 49 |
+
manga.categories.forEach(cat => catMap.set(cat.id, cat));
|
| 50 |
+
}
|
| 51 |
+
});
|
| 52 |
+
|
| 53 |
+
setAvailableCategories(Array.from(catMap.values()));
|
| 54 |
+
setAvailableAuthors(Array.from(authorSet));
|
| 55 |
+
|
| 56 |
+
} catch (error) {
|
| 57 |
+
console.error('Error loading mangas data:', error);
|
| 58 |
+
toast.error('Error al cargar datos de los mangas');
|
| 59 |
+
} finally {
|
| 60 |
+
setIsLoading(false);
|
| 61 |
+
}
|
| 62 |
+
};
|
| 63 |
+
|
| 64 |
+
const toggleCategoryRemove = (id: string) => {
|
| 65 |
+
setSelectedCategoryIdsToRemove(prev =>
|
| 66 |
+
prev.includes(id) ? prev.filter(c => c !== id) : [...prev, id]
|
| 67 |
+
);
|
| 68 |
+
};
|
| 69 |
+
|
| 70 |
+
const toggleAuthorRemove = (author: string) => {
|
| 71 |
+
setSelectedAuthorsToRemove(prev =>
|
| 72 |
+
prev.includes(author) ? prev.filter(a => a !== author) : [...prev, author]
|
| 73 |
+
);
|
| 74 |
+
};
|
| 75 |
+
|
| 76 |
+
const handleSave = async () => {
|
| 77 |
+
if (selectedCategoryIdsToRemove.length === 0 && selectedAuthorsToRemove.length === 0) {
|
| 78 |
+
toast.error('Selecciona al menos una categoría o autor para eliminar.');
|
| 79 |
+
return;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
setIsSaving(true);
|
| 83 |
+
try {
|
| 84 |
+
const updatePromises = selectedMangaIds.map(async (mangaId) => {
|
| 85 |
+
try {
|
| 86 |
+
const manga = await getMangaById(mangaId);
|
| 87 |
+
if (!manga) return;
|
| 88 |
+
|
| 89 |
+
let needsUpdate = false;
|
| 90 |
+
const updateData: any = {
|
| 91 |
+
title: manga.title,
|
| 92 |
+
author: manga.author
|
| 93 |
+
};
|
| 94 |
+
|
| 95 |
+
if (selectedAuthorsToRemove.includes(manga.author)) {
|
| 96 |
+
updateData.author = 'Desconocido';
|
| 97 |
+
needsUpdate = true;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
if (manga.categories && manga.categories.length > 0) {
|
| 101 |
+
const existingIds = manga.categories.map(c => c.id);
|
| 102 |
+
const newIds = existingIds.filter(id => !selectedCategoryIdsToRemove.includes(id));
|
| 103 |
+
|
| 104 |
+
if (newIds.length !== existingIds.length) {
|
| 105 |
+
updateData.categoryIds = newIds;
|
| 106 |
+
needsUpdate = true;
|
| 107 |
+
} else {
|
| 108 |
+
updateData.categoryIds = existingIds;
|
| 109 |
+
}
|
| 110 |
+
} else {
|
| 111 |
+
updateData.categoryIds = [];
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
if (needsUpdate) {
|
| 115 |
+
await updateManga(mangaId, updateData);
|
| 116 |
+
}
|
| 117 |
+
} catch (err) {
|
| 118 |
+
console.error(`Error updating manga ${mangaId}`, err);
|
| 119 |
+
}
|
| 120 |
+
});
|
| 121 |
+
|
| 122 |
+
await Promise.all(updatePromises);
|
| 123 |
+
toast.success('Categorías eliminadas de los mangas correctamente.');
|
| 124 |
+
onSaveComplete();
|
| 125 |
+
onClose();
|
| 126 |
+
|
| 127 |
+
} catch (error) {
|
| 128 |
+
console.error('Error bulk updating mangas:', error);
|
| 129 |
+
toast.error('Error al aplicar cambios.');
|
| 130 |
+
} finally {
|
| 131 |
+
setIsSaving(false);
|
| 132 |
+
}
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
if (!isOpen) return null;
|
| 136 |
+
|
| 137 |
+
const renderCategorySection = (type: 'character' | 'series' | 'genre' | 'tag', title: string, colorClass: string) => {
|
| 138 |
+
const typeCategories = availableCategories.filter(c => c.type === type);
|
| 139 |
+
if (typeCategories.length === 0) return null;
|
| 140 |
+
|
| 141 |
+
return (
|
| 142 |
+
<div className="bg-[#1f1f1f] p-4 rounded-xl border border-gray-800 space-y-3">
|
| 143 |
+
<span className="text-xs font-bold text-gray-400 uppercase tracking-wider">{title}</span>
|
| 144 |
+
<div className="flex flex-wrap gap-2">
|
| 145 |
+
{typeCategories.map(cat => {
|
| 146 |
+
const isSelected = selectedCategoryIdsToRemove.includes(cat.id);
|
| 147 |
+
return (
|
| 148 |
+
<button
|
| 149 |
+
key={cat.id}
|
| 150 |
+
onClick={() => toggleCategoryRemove(cat.id)}
|
| 151 |
+
className={`px-3 py-1.5 rounded-full text-sm font-medium flex items-center gap-2 border transition-all ${
|
| 152 |
+
isSelected
|
| 153 |
+
? 'bg-red-500/20 text-red-500 border-red-500/50 hover:bg-red-500/30'
|
| 154 |
+
: `bg-[#1a1a1a] ${colorClass} border-gray-700 hover:border-gray-500`
|
| 155 |
+
}`}
|
| 156 |
+
>
|
| 157 |
+
{cat.name}
|
| 158 |
+
{isSelected && <Trash2 className="w-3.5 h-3.5" />}
|
| 159 |
+
</button>
|
| 160 |
+
);
|
| 161 |
+
})}
|
| 162 |
+
</div>
|
| 163 |
+
</div>
|
| 164 |
+
);
|
| 165 |
+
};
|
| 166 |
+
|
| 167 |
+
return (
|
| 168 |
+
<div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4 animate-in fade-in duration-200">
|
| 169 |
+
<div className="bg-[#121212] rounded-2xl border border-gray-800 w-full max-w-2xl shadow-2xl overflow-hidden flex flex-col max-h-[90vh]">
|
| 170 |
+
|
| 171 |
+
{/* Header */}
|
| 172 |
+
<div className="bg-[#1a1a1a] border-b border-gray-800 px-6 py-4 flex items-center justify-between sticky top-0 z-10">
|
| 173 |
+
<h2 className="text-xl font-bold text-white flex items-center gap-2">
|
| 174 |
+
<Trash2 className="w-5 h-5 text-red-500"/>
|
| 175 |
+
Remover Categorías en {selectedMangaIds.length} Mangas
|
| 176 |
+
</h2>
|
| 177 |
+
<button onClick={onClose} className="text-gray-400 hover:text-white transition-colors p-2 hover:bg-white/5 rounded-lg">
|
| 178 |
+
<X className="w-5 h-5" />
|
| 179 |
+
</button>
|
| 180 |
+
</div>
|
| 181 |
+
|
| 182 |
+
<div className="p-6 overflow-y-auto custom-scrollbar flex-1">
|
| 183 |
+
{isLoading ? (
|
| 184 |
+
<div className="flex flex-col items-center justify-center py-12 gap-4">
|
| 185 |
+
<LoadingSpinner size={32} />
|
| 186 |
+
<p className="text-gray-400 text-sm">Escaneando mangas seleccionados...</p>
|
| 187 |
+
</div>
|
| 188 |
+
) : availableCategories.length === 0 && availableAuthors.length === 0 ? (
|
| 189 |
+
<div className="flex flex-col items-center justify-center py-12 text-center">
|
| 190 |
+
<Trash2 className="w-12 h-12 text-gray-600 mb-3" />
|
| 191 |
+
<h3 className="text-lg font-semibold text-white">Sin categorías</h3>
|
| 192 |
+
<p className="text-gray-400 text-sm max-w-sm mt-1">Los mangas seleccionados no tienen autores ni categorías para remover.</p>
|
| 193 |
+
</div>
|
| 194 |
+
) : (
|
| 195 |
+
<div className="space-y-6">
|
| 196 |
+
<p className="text-sm text-gray-400">
|
| 197 |
+
Selecciona los autores y categorías que deseas <b className="text-red-400">eliminar</b> de los mangas seleccionados.
|
| 198 |
+
</p>
|
| 199 |
+
|
| 200 |
+
{/* Autores */}
|
| 201 |
+
{availableAuthors.length > 0 && (
|
| 202 |
+
<div className="bg-[#1f1f1f] p-4 rounded-xl border border-gray-800 space-y-3">
|
| 203 |
+
<span className="text-xs font-bold text-gray-400 uppercase tracking-wider">Autor</span>
|
| 204 |
+
<div className="flex flex-wrap gap-2">
|
| 205 |
+
{availableAuthors.map(author => {
|
| 206 |
+
const isSelected = selectedAuthorsToRemove.includes(author);
|
| 207 |
+
return (
|
| 208 |
+
<button
|
| 209 |
+
key={author}
|
| 210 |
+
onClick={() => toggleAuthorRemove(author)}
|
| 211 |
+
className={`px-3 py-1.5 rounded-full text-sm font-medium flex items-center gap-2 border transition-all ${
|
| 212 |
+
isSelected
|
| 213 |
+
? 'bg-red-500/20 text-red-500 border-red-500/50 hover:bg-red-500/30'
|
| 214 |
+
: 'bg-[#1a1a1a] text-purple-400 border-gray-700 hover:border-gray-500'
|
| 215 |
+
}`}
|
| 216 |
+
>
|
| 217 |
+
{author}
|
| 218 |
+
{isSelected && <Trash2 className="w-3.5 h-3.5" />}
|
| 219 |
+
</button>
|
| 220 |
+
);
|
| 221 |
+
})}
|
| 222 |
+
</div>
|
| 223 |
+
<p className="text-xs text-red-500/80 mt-2">* Remover al autor lo dejará como "Desconocido".</p>
|
| 224 |
+
</div>
|
| 225 |
+
)}
|
| 226 |
+
|
| 227 |
+
{/* Categorías */}
|
| 228 |
+
{renderCategorySection('character', 'Personajes', 'text-blue-400')}
|
| 229 |
+
{renderCategorySection('series', 'Series', 'text-green-400')}
|
| 230 |
+
{renderCategorySection('genre', 'Géneros', 'text-purple-400')}
|
| 231 |
+
{renderCategorySection('tag', 'Etiquetas', 'text-pink-400')}
|
| 232 |
+
</div>
|
| 233 |
+
)}
|
| 234 |
+
</div>
|
| 235 |
+
|
| 236 |
+
<div className="p-6 border-t border-gray-800 flex justify-end gap-3 bg-[#1a1a1a]">
|
| 237 |
+
<button
|
| 238 |
+
onClick={onClose}
|
| 239 |
+
className="px-4 py-2 rounded-lg text-sm font-semibold text-gray-300 hover:text-white transition-colors"
|
| 240 |
+
>
|
| 241 |
+
Cancelar
|
| 242 |
+
</button>
|
| 243 |
+
<button
|
| 244 |
+
onClick={handleSave}
|
| 245 |
+
disabled={isSaving || (selectedCategoryIdsToRemove.length === 0 && selectedAuthorsToRemove.length === 0)}
|
| 246 |
+
className="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded-lg font-semibold text-sm transition-all shadow-lg shadow-red-600/20 flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed"
|
| 247 |
+
>
|
| 248 |
+
{isSaving ? (
|
| 249 |
+
<>
|
| 250 |
+
<LoadingSpinner size={16} />
|
| 251 |
+
Eliminando...
|
| 252 |
+
</>
|
| 253 |
+
) : (
|
| 254 |
+
<>
|
| 255 |
+
<Trash2 className="w-4 h-4" />
|
| 256 |
+
Remover Selección
|
| 257 |
+
</>
|
| 258 |
+
)}
|
| 259 |
+
</button>
|
| 260 |
+
</div>
|
| 261 |
+
|
| 262 |
+
</div>
|
| 263 |
+
</div>
|
| 264 |
+
);
|
| 265 |
+
}
|
src/components/ConfirmModal.tsx
CHANGED
|
@@ -1,82 +1,82 @@
|
|
| 1 |
-
import { AlertTriangle, X } from 'lucide-react';
|
| 2 |
-
|
| 3 |
-
interface ConfirmModalProps {
|
| 4 |
-
isOpen: boolean;
|
| 5 |
-
onClose: () => void;
|
| 6 |
-
onConfirm: () => void;
|
| 7 |
-
title: string;
|
| 8 |
-
message: string;
|
| 9 |
-
confirmText?: string;
|
| 10 |
-
cancelText?: string;
|
| 11 |
-
variant?: 'danger' | 'warning' | 'info';
|
| 12 |
-
}
|
| 13 |
-
|
| 14 |
-
export function ConfirmModal({
|
| 15 |
-
isOpen,
|
| 16 |
-
onClose,
|
| 17 |
-
onConfirm,
|
| 18 |
-
title,
|
| 19 |
-
message,
|
| 20 |
-
confirmText = 'Confirmar',
|
| 21 |
-
cancelText = 'Cancelar',
|
| 22 |
-
variant = 'warning',
|
| 23 |
-
}: ConfirmModalProps) {
|
| 24 |
-
if (!isOpen) return null;
|
| 25 |
-
|
| 26 |
-
const colorClasses = {
|
| 27 |
-
danger: 'from-red-500 to-red-600 shadow-red-500/20',
|
| 28 |
-
warning: 'from-[#bb86fc] to-[#9966dd] shadow-[#bb86fc]/30',
|
| 29 |
-
info: 'from-blue-500 to-blue-600 shadow-blue-500/20',
|
| 30 |
-
};
|
| 31 |
-
|
| 32 |
-
const iconClasses = {
|
| 33 |
-
danger: 'bg-red-500/10 text-red-500',
|
| 34 |
-
warning: 'bg-[#bb86fc]/10 text-[#bb86fc]',
|
| 35 |
-
info: 'bg-blue-500/10 text-blue-500',
|
| 36 |
-
};
|
| 37 |
-
|
| 38 |
-
return (
|
| 39 |
-
<div className="fixed inset-0 bg-black/70 flex items-center justify-center z-[100] p-4 backdrop-blur-sm animate-[fadeIn_0.2s_ease-out]">
|
| 40 |
-
<div className="bg-gradient-to-b from-[#1f1f1f] to-[#121212] rounded-2xl border border-gray-700/40 w-full max-w-md shadow-2xl overflow-hidden scale-in-center">
|
| 41 |
-
<div className="bg-gradient-to-b from-[#2a2a2a] to-[#1f1f1f] border-b border-gray-700/30 px-6 py-4 flex items-center justify-between">
|
| 42 |
-
<div className="flex items-center gap-3">
|
| 43 |
-
<div className={`p-2 rounded-lg ${iconClasses[variant]}`}>
|
| 44 |
-
<AlertTriangle className="w-5 h-5" />
|
| 45 |
-
</div>
|
| 46 |
-
<h2 className="text-xl font-bold text-white tracking-tight">{title}</h2>
|
| 47 |
-
</div>
|
| 48 |
-
<button
|
| 49 |
-
onClick={onClose}
|
| 50 |
-
className="text-gray-500 hover:text-white hover:bg-white/10 transition-all p-1.5 rounded-lg"
|
| 51 |
-
>
|
| 52 |
-
<X className="w-5 h-5" />
|
| 53 |
-
</button>
|
| 54 |
-
</div>
|
| 55 |
-
|
| 56 |
-
<div className="p-8">
|
| 57 |
-
<p className="text-gray-300 leading-relaxed">
|
| 58 |
-
{message}
|
| 59 |
-
</p>
|
| 60 |
-
|
| 61 |
-
<div className="flex gap-3 mt-8">
|
| 62 |
-
<button
|
| 63 |
-
onClick={onClose}
|
| 64 |
-
className="flex-1 bg-[#1a1a1a] border border-gray-600/40 hover:border-gray-500 hover:bg-[#242424] text-white px-5 py-3 rounded-xl font-semibold text-sm transition-all shadow-md active:scale-95"
|
| 65 |
-
>
|
| 66 |
-
{cancelText}
|
| 67 |
-
</button>
|
| 68 |
-
<button
|
| 69 |
-
onClick={() => {
|
| 70 |
-
onConfirm();
|
| 71 |
-
onClose();
|
| 72 |
-
}}
|
| 73 |
-
className={`flex-1 bg-gradient-to-r ${colorClasses[variant]} text-white px-5 py-3 rounded-xl font-bold text-sm transition-all shadow-lg hover:brightness-110 active:scale-95`}
|
| 74 |
-
>
|
| 75 |
-
{confirmText}
|
| 76 |
-
</button>
|
| 77 |
-
</div>
|
| 78 |
-
</div>
|
| 79 |
-
</div>
|
| 80 |
-
</div>
|
| 81 |
-
);
|
| 82 |
-
}
|
|
|
|
| 1 |
+
import { AlertTriangle, X } from 'lucide-react';
|
| 2 |
+
|
| 3 |
+
interface ConfirmModalProps {
|
| 4 |
+
isOpen: boolean;
|
| 5 |
+
onClose: () => void;
|
| 6 |
+
onConfirm: () => void;
|
| 7 |
+
title: string;
|
| 8 |
+
message: string;
|
| 9 |
+
confirmText?: string;
|
| 10 |
+
cancelText?: string;
|
| 11 |
+
variant?: 'danger' | 'warning' | 'info';
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
export function ConfirmModal({
|
| 15 |
+
isOpen,
|
| 16 |
+
onClose,
|
| 17 |
+
onConfirm,
|
| 18 |
+
title,
|
| 19 |
+
message,
|
| 20 |
+
confirmText = 'Confirmar',
|
| 21 |
+
cancelText = 'Cancelar',
|
| 22 |
+
variant = 'warning',
|
| 23 |
+
}: ConfirmModalProps) {
|
| 24 |
+
if (!isOpen) return null;
|
| 25 |
+
|
| 26 |
+
const colorClasses = {
|
| 27 |
+
danger: 'from-red-500 to-red-600 shadow-red-500/20',
|
| 28 |
+
warning: 'from-[#bb86fc] to-[#9966dd] shadow-[#bb86fc]/30',
|
| 29 |
+
info: 'from-blue-500 to-blue-600 shadow-blue-500/20',
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
const iconClasses = {
|
| 33 |
+
danger: 'bg-red-500/10 text-red-500',
|
| 34 |
+
warning: 'bg-[#bb86fc]/10 text-[#bb86fc]',
|
| 35 |
+
info: 'bg-blue-500/10 text-blue-500',
|
| 36 |
+
};
|
| 37 |
+
|
| 38 |
+
return (
|
| 39 |
+
<div className="fixed inset-0 bg-black/70 flex items-center justify-center z-[100] p-4 backdrop-blur-sm animate-[fadeIn_0.2s_ease-out]">
|
| 40 |
+
<div className="bg-gradient-to-b from-[#1f1f1f] to-[#121212] rounded-2xl border border-gray-700/40 w-full max-w-md shadow-2xl overflow-hidden scale-in-center">
|
| 41 |
+
<div className="bg-gradient-to-b from-[#2a2a2a] to-[#1f1f1f] border-b border-gray-700/30 px-6 py-4 flex items-center justify-between">
|
| 42 |
+
<div className="flex items-center gap-3">
|
| 43 |
+
<div className={`p-2 rounded-lg ${iconClasses[variant]}`}>
|
| 44 |
+
<AlertTriangle className="w-5 h-5" />
|
| 45 |
+
</div>
|
| 46 |
+
<h2 className="text-xl font-bold text-white tracking-tight">{title}</h2>
|
| 47 |
+
</div>
|
| 48 |
+
<button
|
| 49 |
+
onClick={onClose}
|
| 50 |
+
className="text-gray-500 hover:text-white hover:bg-white/10 transition-all p-1.5 rounded-lg"
|
| 51 |
+
>
|
| 52 |
+
<X className="w-5 h-5" />
|
| 53 |
+
</button>
|
| 54 |
+
</div>
|
| 55 |
+
|
| 56 |
+
<div className="p-8">
|
| 57 |
+
<p className="text-gray-300 leading-relaxed">
|
| 58 |
+
{message}
|
| 59 |
+
</p>
|
| 60 |
+
|
| 61 |
+
<div className="flex gap-3 mt-8">
|
| 62 |
+
<button
|
| 63 |
+
onClick={onClose}
|
| 64 |
+
className="flex-1 bg-[#1a1a1a] border border-gray-600/40 hover:border-gray-500 hover:bg-[#242424] text-white px-5 py-3 rounded-xl font-semibold text-sm transition-all shadow-md active:scale-95"
|
| 65 |
+
>
|
| 66 |
+
{cancelText}
|
| 67 |
+
</button>
|
| 68 |
+
<button
|
| 69 |
+
onClick={() => {
|
| 70 |
+
onConfirm();
|
| 71 |
+
onClose();
|
| 72 |
+
}}
|
| 73 |
+
className={`flex-1 bg-gradient-to-r ${colorClasses[variant]} text-white px-5 py-3 rounded-xl font-bold text-sm transition-all shadow-lg hover:brightness-110 active:scale-95`}
|
| 74 |
+
>
|
| 75 |
+
{confirmText}
|
| 76 |
+
</button>
|
| 77 |
+
</div>
|
| 78 |
+
</div>
|
| 79 |
+
</div>
|
| 80 |
+
</div>
|
| 81 |
+
);
|
| 82 |
+
}
|
src/components/CreateFolderModal.tsx
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState } from 'react';
|
| 2 |
+
import { X, FolderPlus } from 'lucide-react';
|
| 3 |
+
import { toast } from 'sonner';
|
| 4 |
+
import { createFolderAndMove } from '../services/manga';
|
| 5 |
+
|
| 6 |
+
interface CreateFolderModalProps {
|
| 7 |
+
isOpen: boolean;
|
| 8 |
+
onClose: () => void;
|
| 9 |
+
selectedMangaIds: string[];
|
| 10 |
+
onSaveComplete: () => void;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
export function CreateFolderModal({ isOpen, onClose, selectedMangaIds, onSaveComplete }: CreateFolderModalProps) {
|
| 14 |
+
const [folderName, setFolderName] = useState('');
|
| 15 |
+
const [isSaving, setIsSaving] = useState(false);
|
| 16 |
+
|
| 17 |
+
const handleSave = async () => {
|
| 18 |
+
if (!folderName.trim()) {
|
| 19 |
+
toast.error('Gamba: Escribe un nombre para la carpeta');
|
| 20 |
+
return;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
try {
|
| 24 |
+
setIsSaving(true);
|
| 25 |
+
await createFolderAndMove(folderName.trim(), selectedMangaIds);
|
| 26 |
+
toast.success(`Carpeta "${folderName}" creada exitosamente.`);
|
| 27 |
+
onSaveComplete();
|
| 28 |
+
onClose();
|
| 29 |
+
setFolderName('');
|
| 30 |
+
} catch (error) {
|
| 31 |
+
console.error('Error creating folder:', error);
|
| 32 |
+
toast.error('Error al crear la carpeta');
|
| 33 |
+
} finally {
|
| 34 |
+
setIsSaving(false);
|
| 35 |
+
}
|
| 36 |
+
};
|
| 37 |
+
|
| 38 |
+
if (!isOpen) return null;
|
| 39 |
+
|
| 40 |
+
return (
|
| 41 |
+
<div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-[70] p-4 animate-in fade-in duration-200">
|
| 42 |
+
<div className="bg-[#121212] rounded-2xl border border-gray-800 w-full max-w-sm shadow-2xl overflow-hidden flex flex-col">
|
| 43 |
+
<div className="bg-[#1a1a1a] border-b border-gray-800 px-6 py-4 flex items-center justify-between">
|
| 44 |
+
<div className="flex items-center gap-3">
|
| 45 |
+
<div className="p-2 bg-purple-500/10 rounded-lg text-purple-400">
|
| 46 |
+
<FolderPlus className="w-5 h-5" />
|
| 47 |
+
</div>
|
| 48 |
+
<div>
|
| 49 |
+
<h2 className="text-xl font-bold text-white">Crear Carpeta</h2>
|
| 50 |
+
<p className="text-xs text-gray-400">{selectedMangaIds.length} elementos seleccionados</p>
|
| 51 |
+
</div>
|
| 52 |
+
</div>
|
| 53 |
+
<button onClick={onClose} className="text-gray-400 hover:text-white transition-colors p-2 hover:bg-white/5 rounded-lg">
|
| 54 |
+
<X className="w-5 h-5" />
|
| 55 |
+
</button>
|
| 56 |
+
</div>
|
| 57 |
+
|
| 58 |
+
<div className="p-6">
|
| 59 |
+
<input
|
| 60 |
+
type="text"
|
| 61 |
+
value={folderName}
|
| 62 |
+
onChange={(e) => setFolderName(e.target.value)}
|
| 63 |
+
placeholder="Nombre de la nueva carpeta"
|
| 64 |
+
className="w-full bg-[#1a1a1a] border border-gray-700 rounded-xl px-4 py-3 text-sm text-white focus:outline-none focus:border-purple-500 transition-colors"
|
| 65 |
+
autoFocus
|
| 66 |
+
/>
|
| 67 |
+
</div>
|
| 68 |
+
|
| 69 |
+
<div className="bg-[#1a1a1a] border-t border-gray-800 px-6 py-4 flex justify-end gap-3">
|
| 70 |
+
<button
|
| 71 |
+
onClick={onClose}
|
| 72 |
+
className="px-4 py-2 text-sm font-semibold text-gray-300 hover:text-white transition-colors"
|
| 73 |
+
disabled={isSaving}
|
| 74 |
+
>
|
| 75 |
+
Cancelar
|
| 76 |
+
</button>
|
| 77 |
+
<button
|
| 78 |
+
onClick={handleSave}
|
| 79 |
+
disabled={isSaving || !folderName.trim()}
|
| 80 |
+
className="bg-purple-600 hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed text-white px-6 py-2 rounded-lg text-sm font-bold shadow-lg shadow-purple-500/20 transition-all flex items-center gap-2"
|
| 81 |
+
>
|
| 82 |
+
{isSaving ? 'Creando...' : 'Crear'}
|
| 83 |
+
</button>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
</div>
|
| 87 |
+
);
|
| 88 |
+
}
|
src/components/EtiquetadoraModal.tsx
CHANGED
|
@@ -1,312 +1,312 @@
|
|
| 1 |
-
import { X, Save, Tag } from 'lucide-react';
|
| 2 |
-
import { toast } from 'sonner';
|
| 3 |
-
import { useState, useEffect } from 'react';
|
| 4 |
-
import { getMangaById, updateManga } from '../services/manga';
|
| 5 |
-
import { LoadingSpinner } from './LoadingSpinner';
|
| 6 |
-
|
| 7 |
-
interface MangaToggles {
|
| 8 |
-
id: string;
|
| 9 |
-
title: string;
|
| 10 |
-
is_decensored: boolean;
|
| 11 |
-
is_bn: boolean;
|
| 12 |
-
is_color: boolean;
|
| 13 |
-
hasChanged: boolean;
|
| 14 |
-
}
|
| 15 |
-
|
| 16 |
-
interface EtiquetadoraModalProps {
|
| 17 |
-
isOpen: boolean;
|
| 18 |
-
onClose: () => void;
|
| 19 |
-
selectedMangaIds: string[];
|
| 20 |
-
onSaveComplete: () => void;
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
export function EtiquetadoraModal({ isOpen, onClose, selectedMangaIds, onSaveComplete }: EtiquetadoraModalProps) {
|
| 24 |
-
const [mangas, setMangas] = useState<MangaToggles[]>([]);
|
| 25 |
-
const [isLoading, setIsLoading] = useState(false);
|
| 26 |
-
const [isSaving, setIsSaving] = useState(false);
|
| 27 |
-
|
| 28 |
-
// Global toggle states
|
| 29 |
-
const [globalDecensored, setGlobalDecensored] = useState(false);
|
| 30 |
-
const [globalBn, setGlobalBn] = useState(false);
|
| 31 |
-
const [globalColor, setGlobalColor] = useState(false);
|
| 32 |
-
|
| 33 |
-
useEffect(() => {
|
| 34 |
-
if (isOpen) {
|
| 35 |
-
loadMangas();
|
| 36 |
-
setGlobalDecensored(false);
|
| 37 |
-
setGlobalBn(false);
|
| 38 |
-
setGlobalColor(false);
|
| 39 |
-
}
|
| 40 |
-
}, [isOpen, selectedMangaIds]);
|
| 41 |
-
|
| 42 |
-
const loadMangas = async () => {
|
| 43 |
-
setIsLoading(true);
|
| 44 |
-
try {
|
| 45 |
-
const loaded = await Promise.all(
|
| 46 |
-
selectedMangaIds.map(async (id) => {
|
| 47 |
-
const manga = await getMangaById(id);
|
| 48 |
-
if (!manga) return null;
|
| 49 |
-
return {
|
| 50 |
-
id: manga.id,
|
| 51 |
-
title: manga.title,
|
| 52 |
-
is_decensored: !!manga.is_decensored,
|
| 53 |
-
is_bn: !!manga.is_bn,
|
| 54 |
-
is_color: !!manga.is_color,
|
| 55 |
-
hasChanged: false,
|
| 56 |
-
} as MangaToggles;
|
| 57 |
-
})
|
| 58 |
-
);
|
| 59 |
-
setMangas(loaded.filter(m => m !== null) as MangaToggles[]);
|
| 60 |
-
} catch (error) {
|
| 61 |
-
console.error('Error loading mangas:', error);
|
| 62 |
-
toast.error('Error al cargar la información de los mangas');
|
| 63 |
-
} finally {
|
| 64 |
-
setIsLoading(false);
|
| 65 |
-
}
|
| 66 |
-
};
|
| 67 |
-
|
| 68 |
-
const handleGlobalDecensored = (checked: boolean) => {
|
| 69 |
-
setGlobalDecensored(checked);
|
| 70 |
-
setMangas(prev => prev.map(m => ({ ...m, is_decensored: checked, hasChanged: true })));
|
| 71 |
-
};
|
| 72 |
-
|
| 73 |
-
const handleGlobalBn = (checked: boolean) => {
|
| 74 |
-
setGlobalBn(checked);
|
| 75 |
-
if (checked) setGlobalColor(false);
|
| 76 |
-
setMangas(prev => prev.map(m => ({
|
| 77 |
-
...m,
|
| 78 |
-
is_bn: checked,
|
| 79 |
-
is_color: checked ? false : m.is_color,
|
| 80 |
-
hasChanged: true
|
| 81 |
-
})));
|
| 82 |
-
};
|
| 83 |
-
|
| 84 |
-
const handleGlobalColor = (checked: boolean) => {
|
| 85 |
-
setGlobalColor(checked);
|
| 86 |
-
if (checked) setGlobalBn(false);
|
| 87 |
-
setMangas(prev => prev.map(m => ({
|
| 88 |
-
...m,
|
| 89 |
-
is_color: checked,
|
| 90 |
-
is_bn: checked ? false : m.is_bn,
|
| 91 |
-
hasChanged: true
|
| 92 |
-
})));
|
| 93 |
-
};
|
| 94 |
-
|
| 95 |
-
const handleIndividualToggle = (id: string, field: 'is_decensored' | 'is_bn' | 'is_color', value: boolean) => {
|
| 96 |
-
setMangas(prev => prev.map(m => {
|
| 97 |
-
if (m.id !== id) return m;
|
| 98 |
-
|
| 99 |
-
const newM = { ...m, [field]: value, hasChanged: true };
|
| 100 |
-
|
| 101 |
-
if (field === 'is_bn' && value) newM.is_color = false;
|
| 102 |
-
if (field === 'is_color' && value) newM.is_bn = false;
|
| 103 |
-
|
| 104 |
-
return newM;
|
| 105 |
-
}));
|
| 106 |
-
};
|
| 107 |
-
|
| 108 |
-
const handleSave = async () => {
|
| 109 |
-
const changedMangas = mangas.filter(m => m.hasChanged);
|
| 110 |
-
|
| 111 |
-
if (changedMangas.length === 0) {
|
| 112 |
-
toast.info('No hay cambios para guardar');
|
| 113 |
-
onClose();
|
| 114 |
-
return;
|
| 115 |
-
}
|
| 116 |
-
|
| 117 |
-
setIsSaving(true);
|
| 118 |
-
try {
|
| 119 |
-
const promises = changedMangas.map(manga =>
|
| 120 |
-
updateManga(manga.id, {
|
| 121 |
-
is_decensored: manga.is_decensored,
|
| 122 |
-
is_bn: manga.is_bn,
|
| 123 |
-
is_color: manga.is_color
|
| 124 |
-
})
|
| 125 |
-
);
|
| 126 |
-
|
| 127 |
-
await Promise.all(promises);
|
| 128 |
-
toast.success(`Se actualizaron las etiquetas de ${changedMangas.length} mangas`);
|
| 129 |
-
onSaveComplete();
|
| 130 |
-
onClose();
|
| 131 |
-
} catch (error) {
|
| 132 |
-
console.error('Error updating mangas:', error);
|
| 133 |
-
toast.error('Ocurrió un error al guardar los cambios');
|
| 134 |
-
} finally {
|
| 135 |
-
setIsSaving(false);
|
| 136 |
-
}
|
| 137 |
-
};
|
| 138 |
-
|
| 139 |
-
if (!isOpen) return null;
|
| 140 |
-
|
| 141 |
-
return (
|
| 142 |
-
<div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4 animate-in fade-in duration-200">
|
| 143 |
-
<div className="bg-[#121212] rounded-2xl border border-gray-800 w-full max-w-4xl shadow-2xl overflow-hidden flex flex-col max-h-[90vh]">
|
| 144 |
-
{/* Header */}
|
| 145 |
-
<div className="bg-[#1a1a1a] border-b border-gray-800 px-6 py-4 flex items-center justify-between sticky top-0 z-10">
|
| 146 |
-
<div className="flex items-center gap-3">
|
| 147 |
-
<div className="p-2 bg-[#bb86fc]/10 rounded-lg text-[#bb86fc]">
|
| 148 |
-
<Tag className="w-5 h-5" />
|
| 149 |
-
</div>
|
| 150 |
-
<h2 className="text-xl font-bold text-white">
|
| 151 |
-
Etiquetadora ({selectedMangaIds.length} mangas)
|
| 152 |
-
</h2>
|
| 153 |
-
</div>
|
| 154 |
-
<button onClick={onClose} className="text-gray-400 hover:text-white transition-colors p-2 hover:bg-white/5 rounded-lg">
|
| 155 |
-
<X className="w-5 h-5" />
|
| 156 |
-
</button>
|
| 157 |
-
</div>
|
| 158 |
-
|
| 159 |
-
<div className="p-6 overflow-y-auto custom-scrollbar flex-1 space-y-6">
|
| 160 |
-
{isLoading ? (
|
| 161 |
-
<div className="flex justify-center p-8">
|
| 162 |
-
<LoadingSpinner size={32} />
|
| 163 |
-
</div>
|
| 164 |
-
) : (
|
| 165 |
-
<>
|
| 166 |
-
{/* Global Toggles */}
|
| 167 |
-
<div className="bg-[#1f1f1f] p-5 rounded-xl border border-gray-700 shadow-lg">
|
| 168 |
-
<h3 className="text-md font-bold text-white mb-4 flex items-center gap-2">
|
| 169 |
-
<Tag className="w-4 h-4 text-[#bb86fc]" /> Opciones Generales
|
| 170 |
-
</h3>
|
| 171 |
-
<div className="flex flex-col sm:flex-row gap-6">
|
| 172 |
-
<div className="flex items-center gap-3">
|
| 173 |
-
<label className="relative inline-flex items-center cursor-pointer">
|
| 174 |
-
<input
|
| 175 |
-
type="checkbox"
|
| 176 |
-
className="sr-only peer"
|
| 177 |
-
checked={globalDecensored}
|
| 178 |
-
onChange={(e) => handleGlobalDecensored(e.target.checked)}
|
| 179 |
-
/>
|
| 180 |
-
<div className="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[#bb86fc]"></div>
|
| 181 |
-
</label>
|
| 182 |
-
<div>
|
| 183 |
-
<span className="text-sm font-semibold text-white">Sin censura (Todos)</span>
|
| 184 |
-
</div>
|
| 185 |
-
</div>
|
| 186 |
-
|
| 187 |
-
<div className="flex items-center gap-3">
|
| 188 |
-
<label className="relative inline-flex items-center cursor-pointer">
|
| 189 |
-
<input
|
| 190 |
-
type="checkbox"
|
| 191 |
-
className="sr-only peer"
|
| 192 |
-
checked={globalBn}
|
| 193 |
-
onChange={(e) => handleGlobalBn(e.target.checked)}
|
| 194 |
-
/>
|
| 195 |
-
<div className="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[#bb86fc]"></div>
|
| 196 |
-
</label>
|
| 197 |
-
<div>
|
| 198 |
-
<span className="text-sm font-semibold text-white">B/N (Todos)</span>
|
| 199 |
-
</div>
|
| 200 |
-
</div>
|
| 201 |
-
|
| 202 |
-
<div className="flex items-center gap-3">
|
| 203 |
-
<label className="relative inline-flex items-center cursor-pointer">
|
| 204 |
-
<input
|
| 205 |
-
type="checkbox"
|
| 206 |
-
className="sr-only peer"
|
| 207 |
-
checked={globalColor}
|
| 208 |
-
onChange={(e) => handleGlobalColor(e.target.checked)}
|
| 209 |
-
/>
|
| 210 |
-
<div className="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[#bb86fc]"></div>
|
| 211 |
-
</label>
|
| 212 |
-
<div>
|
| 213 |
-
<span className="text-sm font-semibold text-white">a color (Todos)</span>
|
| 214 |
-
</div>
|
| 215 |
-
</div>
|
| 216 |
-
</div>
|
| 217 |
-
</div>
|
| 218 |
-
|
| 219 |
-
{/* Individual Manga List */}
|
| 220 |
-
<div className="space-y-3">
|
| 221 |
-
<h3 className="text-sm font-bold text-gray-400 uppercase tracking-wider px-2">
|
| 222 |
-
Mangas Individuales ({mangas.length})
|
| 223 |
-
</h3>
|
| 224 |
-
<div className="bg-[#1a1a1a] rounded-xl border border-gray-800 divide-y divide-gray-800">
|
| 225 |
-
{mangas.map((manga) => (
|
| 226 |
-
<div key={manga.id} className={`p-4 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 transition-colors ${manga.hasChanged ? 'bg-[#bb86fc]/5' : 'hover:bg-[#1f1f1f]'}`}>
|
| 227 |
-
<div className="flex-1 min-w-0 pr-4">
|
| 228 |
-
<h4 className="text-sm font-semibold text-white truncate" title={manga.title}>
|
| 229 |
-
{manga.title}
|
| 230 |
-
</h4>
|
| 231 |
-
{manga.hasChanged && (
|
| 232 |
-
<span className="text-[10px] text-[#bb86fc] uppercase tracking-widest font-bold">Modificado</span>
|
| 233 |
-
)}
|
| 234 |
-
</div>
|
| 235 |
-
|
| 236 |
-
<div className="flex items-center gap-4 sm:gap-6 shrink-0">
|
| 237 |
-
<div className="flex flex-col items-center gap-1">
|
| 238 |
-
<label className="relative inline-flex items-center cursor-pointer">
|
| 239 |
-
<input
|
| 240 |
-
type="checkbox"
|
| 241 |
-
className="sr-only peer"
|
| 242 |
-
checked={manga.is_decensored}
|
| 243 |
-
onChange={(e) => handleIndividualToggle(manga.id, 'is_decensored', e.target.checked)}
|
| 244 |
-
/>
|
| 245 |
-
<div className="w-9 h-5 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#bb86fc]"></div>
|
| 246 |
-
</label>
|
| 247 |
-
<span className="text-[10px] text-gray-400 font-medium">Sin censura</span>
|
| 248 |
-
</div>
|
| 249 |
-
|
| 250 |
-
<div className="flex flex-col items-center gap-1">
|
| 251 |
-
<label className="relative inline-flex items-center cursor-pointer">
|
| 252 |
-
<input
|
| 253 |
-
type="checkbox"
|
| 254 |
-
className="sr-only peer"
|
| 255 |
-
checked={manga.is_bn}
|
| 256 |
-
onChange={(e) => handleIndividualToggle(manga.id, 'is_bn', e.target.checked)}
|
| 257 |
-
/>
|
| 258 |
-
<div className="w-9 h-5 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#bb86fc]"></div>
|
| 259 |
-
</label>
|
| 260 |
-
<span className="text-[10px] text-gray-400 font-medium">B/N</span>
|
| 261 |
-
</div>
|
| 262 |
-
|
| 263 |
-
<div className="flex flex-col items-center gap-1">
|
| 264 |
-
<label className="relative inline-flex items-center cursor-pointer">
|
| 265 |
-
<input
|
| 266 |
-
type="checkbox"
|
| 267 |
-
className="sr-only peer"
|
| 268 |
-
checked={manga.is_color}
|
| 269 |
-
onChange={(e) => handleIndividualToggle(manga.id, 'is_color', e.target.checked)}
|
| 270 |
-
/>
|
| 271 |
-
<div className="w-9 h-5 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#bb86fc]"></div>
|
| 272 |
-
</label>
|
| 273 |
-
<span className="text-[10px] text-gray-400 font-medium">a color</span>
|
| 274 |
-
</div>
|
| 275 |
-
</div>
|
| 276 |
-
</div>
|
| 277 |
-
))}
|
| 278 |
-
</div>
|
| 279 |
-
</div>
|
| 280 |
-
</>
|
| 281 |
-
)}
|
| 282 |
-
</div>
|
| 283 |
-
|
| 284 |
-
<div className="p-6 border-t border-gray-800 flex justify-end gap-3 bg-[#1a1a1a]">
|
| 285 |
-
<button
|
| 286 |
-
onClick={onClose}
|
| 287 |
-
className="px-4 py-2 rounded-lg text-sm font-semibold text-gray-300 hover:text-white transition-colors"
|
| 288 |
-
>
|
| 289 |
-
Cancelar
|
| 290 |
-
</button>
|
| 291 |
-
<button
|
| 292 |
-
onClick={handleSave}
|
| 293 |
-
disabled={isSaving || isLoading || mangas.filter(m => m.hasChanged).length === 0}
|
| 294 |
-
className="bg-[#bb86fc] hover:bg-[#9966dd] text-white px-6 py-2 rounded-lg font-semibold text-sm transition-all shadow-lg shadow-[#bb86fc]/20 flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed"
|
| 295 |
-
>
|
| 296 |
-
{isSaving ? (
|
| 297 |
-
<>
|
| 298 |
-
<LoadingSpinner size={16} />
|
| 299 |
-
Guardando...
|
| 300 |
-
</>
|
| 301 |
-
) : (
|
| 302 |
-
<>
|
| 303 |
-
<Save className="w-4 h-4" />
|
| 304 |
-
Guardar Cambios ({mangas.filter(m => m.hasChanged).length})
|
| 305 |
-
</>
|
| 306 |
-
)}
|
| 307 |
-
</button>
|
| 308 |
-
</div>
|
| 309 |
-
</div>
|
| 310 |
-
</div>
|
| 311 |
-
);
|
| 312 |
-
}
|
|
|
|
| 1 |
+
import { X, Save, Tag } from 'lucide-react';
|
| 2 |
+
import { toast } from 'sonner';
|
| 3 |
+
import { useState, useEffect } from 'react';
|
| 4 |
+
import { getMangaById, updateManga } from '../services/manga';
|
| 5 |
+
import { LoadingSpinner } from './LoadingSpinner';
|
| 6 |
+
|
| 7 |
+
interface MangaToggles {
|
| 8 |
+
id: string;
|
| 9 |
+
title: string;
|
| 10 |
+
is_decensored: boolean;
|
| 11 |
+
is_bn: boolean;
|
| 12 |
+
is_color: boolean;
|
| 13 |
+
hasChanged: boolean;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
interface EtiquetadoraModalProps {
|
| 17 |
+
isOpen: boolean;
|
| 18 |
+
onClose: () => void;
|
| 19 |
+
selectedMangaIds: string[];
|
| 20 |
+
onSaveComplete: () => void;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
export function EtiquetadoraModal({ isOpen, onClose, selectedMangaIds, onSaveComplete }: EtiquetadoraModalProps) {
|
| 24 |
+
const [mangas, setMangas] = useState<MangaToggles[]>([]);
|
| 25 |
+
const [isLoading, setIsLoading] = useState(false);
|
| 26 |
+
const [isSaving, setIsSaving] = useState(false);
|
| 27 |
+
|
| 28 |
+
// Global toggle states
|
| 29 |
+
const [globalDecensored, setGlobalDecensored] = useState(false);
|
| 30 |
+
const [globalBn, setGlobalBn] = useState(false);
|
| 31 |
+
const [globalColor, setGlobalColor] = useState(false);
|
| 32 |
+
|
| 33 |
+
useEffect(() => {
|
| 34 |
+
if (isOpen) {
|
| 35 |
+
loadMangas();
|
| 36 |
+
setGlobalDecensored(false);
|
| 37 |
+
setGlobalBn(false);
|
| 38 |
+
setGlobalColor(false);
|
| 39 |
+
}
|
| 40 |
+
}, [isOpen, selectedMangaIds]);
|
| 41 |
+
|
| 42 |
+
const loadMangas = async () => {
|
| 43 |
+
setIsLoading(true);
|
| 44 |
+
try {
|
| 45 |
+
const loaded = await Promise.all(
|
| 46 |
+
selectedMangaIds.map(async (id) => {
|
| 47 |
+
const manga = await getMangaById(id);
|
| 48 |
+
if (!manga) return null;
|
| 49 |
+
return {
|
| 50 |
+
id: manga.id,
|
| 51 |
+
title: manga.title,
|
| 52 |
+
is_decensored: !!manga.is_decensored,
|
| 53 |
+
is_bn: !!manga.is_bn,
|
| 54 |
+
is_color: !!manga.is_color,
|
| 55 |
+
hasChanged: false,
|
| 56 |
+
} as MangaToggles;
|
| 57 |
+
})
|
| 58 |
+
);
|
| 59 |
+
setMangas(loaded.filter(m => m !== null) as MangaToggles[]);
|
| 60 |
+
} catch (error) {
|
| 61 |
+
console.error('Error loading mangas:', error);
|
| 62 |
+
toast.error('Error al cargar la información de los mangas');
|
| 63 |
+
} finally {
|
| 64 |
+
setIsLoading(false);
|
| 65 |
+
}
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
const handleGlobalDecensored = (checked: boolean) => {
|
| 69 |
+
setGlobalDecensored(checked);
|
| 70 |
+
setMangas(prev => prev.map(m => ({ ...m, is_decensored: checked, hasChanged: true })));
|
| 71 |
+
};
|
| 72 |
+
|
| 73 |
+
const handleGlobalBn = (checked: boolean) => {
|
| 74 |
+
setGlobalBn(checked);
|
| 75 |
+
if (checked) setGlobalColor(false);
|
| 76 |
+
setMangas(prev => prev.map(m => ({
|
| 77 |
+
...m,
|
| 78 |
+
is_bn: checked,
|
| 79 |
+
is_color: checked ? false : m.is_color,
|
| 80 |
+
hasChanged: true
|
| 81 |
+
})));
|
| 82 |
+
};
|
| 83 |
+
|
| 84 |
+
const handleGlobalColor = (checked: boolean) => {
|
| 85 |
+
setGlobalColor(checked);
|
| 86 |
+
if (checked) setGlobalBn(false);
|
| 87 |
+
setMangas(prev => prev.map(m => ({
|
| 88 |
+
...m,
|
| 89 |
+
is_color: checked,
|
| 90 |
+
is_bn: checked ? false : m.is_bn,
|
| 91 |
+
hasChanged: true
|
| 92 |
+
})));
|
| 93 |
+
};
|
| 94 |
+
|
| 95 |
+
const handleIndividualToggle = (id: string, field: 'is_decensored' | 'is_bn' | 'is_color', value: boolean) => {
|
| 96 |
+
setMangas(prev => prev.map(m => {
|
| 97 |
+
if (m.id !== id) return m;
|
| 98 |
+
|
| 99 |
+
const newM = { ...m, [field]: value, hasChanged: true };
|
| 100 |
+
|
| 101 |
+
if (field === 'is_bn' && value) newM.is_color = false;
|
| 102 |
+
if (field === 'is_color' && value) newM.is_bn = false;
|
| 103 |
+
|
| 104 |
+
return newM;
|
| 105 |
+
}));
|
| 106 |
+
};
|
| 107 |
+
|
| 108 |
+
const handleSave = async () => {
|
| 109 |
+
const changedMangas = mangas.filter(m => m.hasChanged);
|
| 110 |
+
|
| 111 |
+
if (changedMangas.length === 0) {
|
| 112 |
+
toast.info('No hay cambios para guardar');
|
| 113 |
+
onClose();
|
| 114 |
+
return;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
setIsSaving(true);
|
| 118 |
+
try {
|
| 119 |
+
const promises = changedMangas.map(manga =>
|
| 120 |
+
updateManga(manga.id, {
|
| 121 |
+
is_decensored: manga.is_decensored,
|
| 122 |
+
is_bn: manga.is_bn,
|
| 123 |
+
is_color: manga.is_color
|
| 124 |
+
})
|
| 125 |
+
);
|
| 126 |
+
|
| 127 |
+
await Promise.all(promises);
|
| 128 |
+
toast.success(`Se actualizaron las etiquetas de ${changedMangas.length} mangas`);
|
| 129 |
+
onSaveComplete();
|
| 130 |
+
onClose();
|
| 131 |
+
} catch (error) {
|
| 132 |
+
console.error('Error updating mangas:', error);
|
| 133 |
+
toast.error('Ocurrió un error al guardar los cambios');
|
| 134 |
+
} finally {
|
| 135 |
+
setIsSaving(false);
|
| 136 |
+
}
|
| 137 |
+
};
|
| 138 |
+
|
| 139 |
+
if (!isOpen) return null;
|
| 140 |
+
|
| 141 |
+
return (
|
| 142 |
+
<div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4 animate-in fade-in duration-200">
|
| 143 |
+
<div className="bg-[#121212] rounded-2xl border border-gray-800 w-full max-w-4xl shadow-2xl overflow-hidden flex flex-col max-h-[90vh]">
|
| 144 |
+
{/* Header */}
|
| 145 |
+
<div className="bg-[#1a1a1a] border-b border-gray-800 px-6 py-4 flex items-center justify-between sticky top-0 z-10">
|
| 146 |
+
<div className="flex items-center gap-3">
|
| 147 |
+
<div className="p-2 bg-[#bb86fc]/10 rounded-lg text-[#bb86fc]">
|
| 148 |
+
<Tag className="w-5 h-5" />
|
| 149 |
+
</div>
|
| 150 |
+
<h2 className="text-xl font-bold text-white">
|
| 151 |
+
Etiquetadora ({selectedMangaIds.length} mangas)
|
| 152 |
+
</h2>
|
| 153 |
+
</div>
|
| 154 |
+
<button onClick={onClose} className="text-gray-400 hover:text-white transition-colors p-2 hover:bg-white/5 rounded-lg">
|
| 155 |
+
<X className="w-5 h-5" />
|
| 156 |
+
</button>
|
| 157 |
+
</div>
|
| 158 |
+
|
| 159 |
+
<div className="p-6 overflow-y-auto custom-scrollbar flex-1 space-y-6">
|
| 160 |
+
{isLoading ? (
|
| 161 |
+
<div className="flex justify-center p-8">
|
| 162 |
+
<LoadingSpinner size={32} />
|
| 163 |
+
</div>
|
| 164 |
+
) : (
|
| 165 |
+
<>
|
| 166 |
+
{/* Global Toggles */}
|
| 167 |
+
<div className="bg-[#1f1f1f] p-5 rounded-xl border border-gray-700 shadow-lg">
|
| 168 |
+
<h3 className="text-md font-bold text-white mb-4 flex items-center gap-2">
|
| 169 |
+
<Tag className="w-4 h-4 text-[#bb86fc]" /> Opciones Generales
|
| 170 |
+
</h3>
|
| 171 |
+
<div className="flex flex-col sm:flex-row gap-6">
|
| 172 |
+
<div className="flex items-center gap-3">
|
| 173 |
+
<label className="relative inline-flex items-center cursor-pointer">
|
| 174 |
+
<input
|
| 175 |
+
type="checkbox"
|
| 176 |
+
className="sr-only peer"
|
| 177 |
+
checked={globalDecensored}
|
| 178 |
+
onChange={(e) => handleGlobalDecensored(e.target.checked)}
|
| 179 |
+
/>
|
| 180 |
+
<div className="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[#bb86fc]"></div>
|
| 181 |
+
</label>
|
| 182 |
+
<div>
|
| 183 |
+
<span className="text-sm font-semibold text-white">Sin censura (Todos)</span>
|
| 184 |
+
</div>
|
| 185 |
+
</div>
|
| 186 |
+
|
| 187 |
+
<div className="flex items-center gap-3">
|
| 188 |
+
<label className="relative inline-flex items-center cursor-pointer">
|
| 189 |
+
<input
|
| 190 |
+
type="checkbox"
|
| 191 |
+
className="sr-only peer"
|
| 192 |
+
checked={globalBn}
|
| 193 |
+
onChange={(e) => handleGlobalBn(e.target.checked)}
|
| 194 |
+
/>
|
| 195 |
+
<div className="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[#bb86fc]"></div>
|
| 196 |
+
</label>
|
| 197 |
+
<div>
|
| 198 |
+
<span className="text-sm font-semibold text-white">B/N (Todos)</span>
|
| 199 |
+
</div>
|
| 200 |
+
</div>
|
| 201 |
+
|
| 202 |
+
<div className="flex items-center gap-3">
|
| 203 |
+
<label className="relative inline-flex items-center cursor-pointer">
|
| 204 |
+
<input
|
| 205 |
+
type="checkbox"
|
| 206 |
+
className="sr-only peer"
|
| 207 |
+
checked={globalColor}
|
| 208 |
+
onChange={(e) => handleGlobalColor(e.target.checked)}
|
| 209 |
+
/>
|
| 210 |
+
<div className="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[#bb86fc]"></div>
|
| 211 |
+
</label>
|
| 212 |
+
<div>
|
| 213 |
+
<span className="text-sm font-semibold text-white">a color (Todos)</span>
|
| 214 |
+
</div>
|
| 215 |
+
</div>
|
| 216 |
+
</div>
|
| 217 |
+
</div>
|
| 218 |
+
|
| 219 |
+
{/* Individual Manga List */}
|
| 220 |
+
<div className="space-y-3">
|
| 221 |
+
<h3 className="text-sm font-bold text-gray-400 uppercase tracking-wider px-2">
|
| 222 |
+
Mangas Individuales ({mangas.length})
|
| 223 |
+
</h3>
|
| 224 |
+
<div className="bg-[#1a1a1a] rounded-xl border border-gray-800 divide-y divide-gray-800">
|
| 225 |
+
{mangas.map((manga) => (
|
| 226 |
+
<div key={manga.id} className={`p-4 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 transition-colors ${manga.hasChanged ? 'bg-[#bb86fc]/5' : 'hover:bg-[#1f1f1f]'}`}>
|
| 227 |
+
<div className="flex-1 min-w-0 pr-4">
|
| 228 |
+
<h4 className="text-sm font-semibold text-white truncate" title={manga.title}>
|
| 229 |
+
{manga.title}
|
| 230 |
+
</h4>
|
| 231 |
+
{manga.hasChanged && (
|
| 232 |
+
<span className="text-[10px] text-[#bb86fc] uppercase tracking-widest font-bold">Modificado</span>
|
| 233 |
+
)}
|
| 234 |
+
</div>
|
| 235 |
+
|
| 236 |
+
<div className="flex items-center gap-4 sm:gap-6 shrink-0">
|
| 237 |
+
<div className="flex flex-col items-center gap-1">
|
| 238 |
+
<label className="relative inline-flex items-center cursor-pointer">
|
| 239 |
+
<input
|
| 240 |
+
type="checkbox"
|
| 241 |
+
className="sr-only peer"
|
| 242 |
+
checked={manga.is_decensored}
|
| 243 |
+
onChange={(e) => handleIndividualToggle(manga.id, 'is_decensored', e.target.checked)}
|
| 244 |
+
/>
|
| 245 |
+
<div className="w-9 h-5 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#bb86fc]"></div>
|
| 246 |
+
</label>
|
| 247 |
+
<span className="text-[10px] text-gray-400 font-medium">Sin censura</span>
|
| 248 |
+
</div>
|
| 249 |
+
|
| 250 |
+
<div className="flex flex-col items-center gap-1">
|
| 251 |
+
<label className="relative inline-flex items-center cursor-pointer">
|
| 252 |
+
<input
|
| 253 |
+
type="checkbox"
|
| 254 |
+
className="sr-only peer"
|
| 255 |
+
checked={manga.is_bn}
|
| 256 |
+
onChange={(e) => handleIndividualToggle(manga.id, 'is_bn', e.target.checked)}
|
| 257 |
+
/>
|
| 258 |
+
<div className="w-9 h-5 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#bb86fc]"></div>
|
| 259 |
+
</label>
|
| 260 |
+
<span className="text-[10px] text-gray-400 font-medium">B/N</span>
|
| 261 |
+
</div>
|
| 262 |
+
|
| 263 |
+
<div className="flex flex-col items-center gap-1">
|
| 264 |
+
<label className="relative inline-flex items-center cursor-pointer">
|
| 265 |
+
<input
|
| 266 |
+
type="checkbox"
|
| 267 |
+
className="sr-only peer"
|
| 268 |
+
checked={manga.is_color}
|
| 269 |
+
onChange={(e) => handleIndividualToggle(manga.id, 'is_color', e.target.checked)}
|
| 270 |
+
/>
|
| 271 |
+
<div className="w-9 h-5 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#bb86fc]"></div>
|
| 272 |
+
</label>
|
| 273 |
+
<span className="text-[10px] text-gray-400 font-medium">a color</span>
|
| 274 |
+
</div>
|
| 275 |
+
</div>
|
| 276 |
+
</div>
|
| 277 |
+
))}
|
| 278 |
+
</div>
|
| 279 |
+
</div>
|
| 280 |
+
</>
|
| 281 |
+
)}
|
| 282 |
+
</div>
|
| 283 |
+
|
| 284 |
+
<div className="p-6 border-t border-gray-800 flex justify-end gap-3 bg-[#1a1a1a]">
|
| 285 |
+
<button
|
| 286 |
+
onClick={onClose}
|
| 287 |
+
className="px-4 py-2 rounded-lg text-sm font-semibold text-gray-300 hover:text-white transition-colors"
|
| 288 |
+
>
|
| 289 |
+
Cancelar
|
| 290 |
+
</button>
|
| 291 |
+
<button
|
| 292 |
+
onClick={handleSave}
|
| 293 |
+
disabled={isSaving || isLoading || mangas.filter(m => m.hasChanged).length === 0}
|
| 294 |
+
className="bg-[#bb86fc] hover:bg-[#9966dd] text-white px-6 py-2 rounded-lg font-semibold text-sm transition-all shadow-lg shadow-[#bb86fc]/20 flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed"
|
| 295 |
+
>
|
| 296 |
+
{isSaving ? (
|
| 297 |
+
<>
|
| 298 |
+
<LoadingSpinner size={16} />
|
| 299 |
+
Guardando...
|
| 300 |
+
</>
|
| 301 |
+
) : (
|
| 302 |
+
<>
|
| 303 |
+
<Save className="w-4 h-4" />
|
| 304 |
+
Guardar Cambios ({mangas.filter(m => m.hasChanged).length})
|
| 305 |
+
</>
|
| 306 |
+
)}
|
| 307 |
+
</button>
|
| 308 |
+
</div>
|
| 309 |
+
</div>
|
| 310 |
+
</div>
|
| 311 |
+
);
|
| 312 |
+
}
|
src/components/LazyImageWrapper.tsx
CHANGED
|
@@ -1,46 +1,46 @@
|
|
| 1 |
-
import { useEffect, useRef, useState, ReactNode } from 'react';
|
| 2 |
-
|
| 3 |
-
interface LazyImageWrapperProps {
|
| 4 |
-
children: (isVisible: boolean) => ReactNode;
|
| 5 |
-
rootMargin?: string;
|
| 6 |
-
minHeight?: string;
|
| 7 |
-
className?: string;
|
| 8 |
-
}
|
| 9 |
-
|
| 10 |
-
export function LazyImageWrapper({
|
| 11 |
-
children,
|
| 12 |
-
rootMargin = '150% 0px 150% 0px',
|
| 13 |
-
minHeight,
|
| 14 |
-
className = ''
|
| 15 |
-
}: LazyImageWrapperProps) {
|
| 16 |
-
const containerRef = useRef<HTMLDivElement>(null);
|
| 17 |
-
const [isVisible, setIsVisible] = useState(false);
|
| 18 |
-
|
| 19 |
-
useEffect(() => {
|
| 20 |
-
if (isVisible) return; // Mantiene el componente renderizado una vez visto
|
| 21 |
-
|
| 22 |
-
const observer = new IntersectionObserver(
|
| 23 |
-
(entries) => {
|
| 24 |
-
const [entry] = entries;
|
| 25 |
-
if (entry.isIntersecting) {
|
| 26 |
-
setIsVisible(true);
|
| 27 |
-
}
|
| 28 |
-
},
|
| 29 |
-
{ rootMargin }
|
| 30 |
-
);
|
| 31 |
-
|
| 32 |
-
if (containerRef.current) {
|
| 33 |
-
observer.observe(containerRef.current);
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
return () => {
|
| 37 |
-
observer.disconnect();
|
| 38 |
-
};
|
| 39 |
-
}, [isVisible, rootMargin]);
|
| 40 |
-
|
| 41 |
-
return (
|
| 42 |
-
<div ref={containerRef} style={minHeight ? { minHeight } : undefined} className={`w-full flex items-center justify-center ${className}`}>
|
| 43 |
-
{isVisible ? children(true) : null}
|
| 44 |
-
</div>
|
| 45 |
-
);
|
| 46 |
-
}
|
|
|
|
| 1 |
+
import { useEffect, useRef, useState, ReactNode } from 'react';
|
| 2 |
+
|
| 3 |
+
interface LazyImageWrapperProps {
|
| 4 |
+
children: (isVisible: boolean) => ReactNode;
|
| 5 |
+
rootMargin?: string;
|
| 6 |
+
minHeight?: string;
|
| 7 |
+
className?: string;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
export function LazyImageWrapper({
|
| 11 |
+
children,
|
| 12 |
+
rootMargin = '150% 0px 150% 0px',
|
| 13 |
+
minHeight,
|
| 14 |
+
className = ''
|
| 15 |
+
}: LazyImageWrapperProps) {
|
| 16 |
+
const containerRef = useRef<HTMLDivElement>(null);
|
| 17 |
+
const [isVisible, setIsVisible] = useState(false);
|
| 18 |
+
|
| 19 |
+
useEffect(() => {
|
| 20 |
+
if (isVisible) return; // Mantiene el componente renderizado una vez visto
|
| 21 |
+
|
| 22 |
+
const observer = new IntersectionObserver(
|
| 23 |
+
(entries) => {
|
| 24 |
+
const [entry] = entries;
|
| 25 |
+
if (entry.isIntersecting) {
|
| 26 |
+
setIsVisible(true);
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
{ rootMargin }
|
| 30 |
+
);
|
| 31 |
+
|
| 32 |
+
if (containerRef.current) {
|
| 33 |
+
observer.observe(containerRef.current);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
return () => {
|
| 37 |
+
observer.disconnect();
|
| 38 |
+
};
|
| 39 |
+
}, [isVisible, rootMargin]);
|
| 40 |
+
|
| 41 |
+
return (
|
| 42 |
+
<div ref={containerRef} style={minHeight ? { minHeight } : undefined} className={`w-full flex items-center justify-center ${className}`}>
|
| 43 |
+
{isVisible ? children(true) : null}
|
| 44 |
+
</div>
|
| 45 |
+
);
|
| 46 |
+
}
|
src/components/MangaCard.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import { useState } from 'react';
|
| 2 |
-
import { BookOpen, Edit2, Trash2, Check } from 'lucide-react';
|
| 3 |
import { Manga } from '../types/manga';
|
| 4 |
import { ImageLoader } from './ImageLoader';
|
| 5 |
import { incrementMangaViews } from '../services/manga';
|
|
@@ -63,7 +63,12 @@ export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSe
|
|
| 63 |
}}
|
| 64 |
className={`relative bg-black rounded-lg shadow-lg overflow-hidden transition-transform duration-300 hover:scale-[1.02] aspect-[2/3] ${isSelected ? 'ring-4 ring-[#bb86fc]' : ''}`}
|
| 65 |
>
|
| 66 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
<>
|
| 68 |
<ImageLoader
|
| 69 |
src={thumbnailUrl}
|
|
@@ -81,26 +86,28 @@ export function MangaCard({ id, title, author, pageCount, thumbnail, manga, onSe
|
|
| 81 |
</div>
|
| 82 |
)}
|
| 83 |
|
| 84 |
-
|
| 85 |
-
<div className="
|
| 86 |
-
{pageCount} paginas
|
| 87 |
-
</div>
|
| 88 |
-
{manga?.is_decensored && (
|
| 89 |
-
<div className="bg-black/70 text-white text-xs px-2 py-1 rounded-md font-semibold opacity-0 group-hover:opacity-100 transition-opacity duration-300 shadow-md">
|
| 90 |
-
Sin censura
|
| 91 |
-
</div>
|
| 92 |
-
)}
|
| 93 |
-
{manga?.is_bn && (
|
| 94 |
-
<div className="bg-black/70 text-white text-xs px-2 py-1 rounded-md font-semibold opacity-0 group-hover:opacity-100 transition-opacity duration-300 shadow-md">
|
| 95 |
-
B/N
|
| 96 |
-
</div>
|
| 97 |
-
)}
|
| 98 |
-
{manga?.is_color && (
|
| 99 |
<div className="bg-black/70 text-white text-xs px-2 py-1 rounded-md font-semibold opacity-0 group-hover:opacity-100 transition-opacity duration-300 shadow-md">
|
| 100 |
-
|
| 101 |
</div>
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
{isCategoryPlusEnabled && (
|
| 106 |
<div className={`absolute top-2 left-2 w-6 h-6 rounded-md border-2 flex items-center justify-center transition-all ${isSelected ? 'bg-[#bb86fc] border-[#bb86fc]' : 'bg-black/50 border-white/50 hover:border-white'}`}>
|
|
|
|
| 1 |
import { useState } from 'react';
|
| 2 |
+
import { BookOpen, Edit2, Trash2, Check, Folder } from 'lucide-react';
|
| 3 |
import { Manga } from '../types/manga';
|
| 4 |
import { ImageLoader } from './ImageLoader';
|
| 5 |
import { incrementMangaViews } from '../services/manga';
|
|
|
|
| 63 |
}}
|
| 64 |
className={`relative bg-black rounded-lg shadow-lg overflow-hidden transition-transform duration-300 hover:scale-[1.02] aspect-[2/3] ${isSelected ? 'ring-4 ring-[#bb86fc]' : ''}`}
|
| 65 |
>
|
| 66 |
+
{manga?.is_folder ? (
|
| 67 |
+
<div className="w-full aspect-[2/3] flex items-center justify-center bg-gradient-to-br from-[#1a1a1a] to-[#2a2a2a] rounded-lg border-2 border-gray-800 group-hover:border-purple-500/50 transition-colors duration-300">
|
| 68 |
+
<Folder className="w-16 h-16 text-purple-400 opacity-80 group-hover:scale-110 transition-transform duration-300" />
|
| 69 |
+
<div className="absolute inset-x-0 bottom-0 h-1/3 bg-gradient-to-t from-black/80 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none"></div>
|
| 70 |
+
</div>
|
| 71 |
+
) : thumbnailUrl ? (
|
| 72 |
<>
|
| 73 |
<ImageLoader
|
| 74 |
src={thumbnailUrl}
|
|
|
|
| 86 |
</div>
|
| 87 |
)}
|
| 88 |
|
| 89 |
+
{!manga?.is_folder && (
|
| 90 |
+
<div className="absolute bottom-2 left-2 flex gap-1 flex-wrap pointer-events-none items-end">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
<div className="bg-black/70 text-white text-xs px-2 py-1 rounded-md font-semibold opacity-0 group-hover:opacity-100 transition-opacity duration-300 shadow-md">
|
| 92 |
+
{pageCount} paginas
|
| 93 |
</div>
|
| 94 |
+
{manga?.is_decensored && (
|
| 95 |
+
<div className="bg-black/70 text-white text-xs px-2 py-1 rounded-md font-semibold opacity-0 group-hover:opacity-100 transition-opacity duration-300 shadow-md">
|
| 96 |
+
Sin censura
|
| 97 |
+
</div>
|
| 98 |
+
)}
|
| 99 |
+
{manga?.is_bn && (
|
| 100 |
+
<div className="bg-black/70 text-white text-xs px-2 py-1 rounded-md font-semibold opacity-0 group-hover:opacity-100 transition-opacity duration-300 shadow-md">
|
| 101 |
+
B/N
|
| 102 |
+
</div>
|
| 103 |
+
)}
|
| 104 |
+
{manga?.is_color && (
|
| 105 |
+
<div className="bg-black/70 text-white text-xs px-2 py-1 rounded-md font-semibold opacity-0 group-hover:opacity-100 transition-opacity duration-300 shadow-md">
|
| 106 |
+
a color
|
| 107 |
+
</div>
|
| 108 |
+
)}
|
| 109 |
+
</div>
|
| 110 |
+
)}
|
| 111 |
|
| 112 |
{isCategoryPlusEnabled && (
|
| 113 |
<div className={`absolute top-2 left-2 w-6 h-6 rounded-md border-2 flex items-center justify-center transition-all ${isSelected ? 'bg-[#bb86fc] border-[#bb86fc]' : 'bg-black/50 border-white/50 hover:border-white'}`}>
|
src/components/MoveToFolderModal.tsx
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState, useMemo } from 'react';
|
| 2 |
+
import { X, FolderInput, Search } from 'lucide-react';
|
| 3 |
+
import { toast } from 'sonner';
|
| 4 |
+
import { moveToFolder } from '../services/manga';
|
| 5 |
+
import { Manga } from '../types/manga';
|
| 6 |
+
|
| 7 |
+
interface MoveToFolderModalProps {
|
| 8 |
+
isOpen: boolean;
|
| 9 |
+
onClose: () => void;
|
| 10 |
+
selectedMangaIds: string[];
|
| 11 |
+
mangas: Manga[];
|
| 12 |
+
onSaveComplete: () => void;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
export function MoveToFolderModal({ isOpen, onClose, selectedMangaIds, mangas, onSaveComplete }: MoveToFolderModalProps) {
|
| 16 |
+
const [searchTerm, setSearchTerm] = useState('');
|
| 17 |
+
const [isSaving, setIsSaving] = useState(false);
|
| 18 |
+
|
| 19 |
+
const folders = useMemo(() => {
|
| 20 |
+
return mangas.filter(m => m.is_folder).sort((a, b) => a.title.localeCompare(b.title));
|
| 21 |
+
}, [mangas]);
|
| 22 |
+
|
| 23 |
+
const filteredFolders = useMemo(() => {
|
| 24 |
+
if (!searchTerm) return folders;
|
| 25 |
+
return folders.filter(f => f.title.toLowerCase().includes(searchTerm.toLowerCase()));
|
| 26 |
+
}, [folders, searchTerm]);
|
| 27 |
+
|
| 28 |
+
const handleMove = async (folderId: string | null) => {
|
| 29 |
+
try {
|
| 30 |
+
setIsSaving(true);
|
| 31 |
+
await moveToFolder(selectedMangaIds, folderId);
|
| 32 |
+
if (folderId) {
|
| 33 |
+
toast.success(`Movido exitosamente a la carpeta.`);
|
| 34 |
+
} else {
|
| 35 |
+
toast.success(`Removido de la carpeta exitosamente.`);
|
| 36 |
+
}
|
| 37 |
+
onSaveComplete();
|
| 38 |
+
onClose();
|
| 39 |
+
} catch (error) {
|
| 40 |
+
console.error('Error moving to folder:', error);
|
| 41 |
+
toast.error('Error al mover a la carpeta');
|
| 42 |
+
} finally {
|
| 43 |
+
setIsSaving(false);
|
| 44 |
+
}
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
if (!isOpen) return null;
|
| 48 |
+
|
| 49 |
+
return (
|
| 50 |
+
<div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-[70] p-4 animate-in fade-in duration-200">
|
| 51 |
+
<div className="bg-[#121212] rounded-2xl border border-gray-800 w-full max-w-md shadow-2xl overflow-hidden flex flex-col max-h-[80vh]">
|
| 52 |
+
<div className="bg-[#1a1a1a] border-b border-gray-800 px-6 py-4 flex items-center justify-between sticky top-0 z-10 flex-shrink-0">
|
| 53 |
+
<div className="flex items-center gap-3">
|
| 54 |
+
<div className="p-2 bg-blue-500/10 rounded-lg text-blue-400">
|
| 55 |
+
<FolderInput className="w-5 h-5" />
|
| 56 |
+
</div>
|
| 57 |
+
<div>
|
| 58 |
+
<h2 className="text-xl font-bold text-white">Mover a Carpeta</h2>
|
| 59 |
+
<p className="text-xs text-gray-400">Selecciona la carpeta de destino</p>
|
| 60 |
+
</div>
|
| 61 |
+
</div>
|
| 62 |
+
<button onClick={onClose} className="text-gray-400 hover:text-white transition-colors p-2 hover:bg-white/5 rounded-lg">
|
| 63 |
+
<X className="w-5 h-5" />
|
| 64 |
+
</button>
|
| 65 |
+
</div>
|
| 66 |
+
|
| 67 |
+
<div className="p-4 border-b border-gray-800 bg-[#121212] flex-shrink-0">
|
| 68 |
+
<div className="relative">
|
| 69 |
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400" />
|
| 70 |
+
<input
|
| 71 |
+
type="text"
|
| 72 |
+
value={searchTerm}
|
| 73 |
+
onChange={(e) => setSearchTerm(e.target.value)}
|
| 74 |
+
placeholder="Buscar carpeta..."
|
| 75 |
+
className="w-full bg-[#1a1a1a] border border-gray-700 rounded-xl pl-10 pr-4 py-3 text-sm text-white focus:outline-none focus:border-blue-500 transition-colors"
|
| 76 |
+
/>
|
| 77 |
+
</div>
|
| 78 |
+
</div>
|
| 79 |
+
|
| 80 |
+
<div className="flex-1 overflow-y-auto p-4 space-y-2 custom-scrollbar">
|
| 81 |
+
<button
|
| 82 |
+
onClick={() => handleMove(null)}
|
| 83 |
+
disabled={isSaving}
|
| 84 |
+
className="w-full flex items-center gap-3 p-3 rounded-xl border border-dashed border-gray-700 hover:border-blue-500 hover:bg-blue-500/5 transition-all text-left group"
|
| 85 |
+
>
|
| 86 |
+
<div className="w-10 h-10 rounded-lg bg-gray-800 flex items-center justify-center group-hover:bg-blue-500/20 transition-colors">
|
| 87 |
+
<span className="text-lg">🏠</span>
|
| 88 |
+
</div>
|
| 89 |
+
<div className="flex-1">
|
| 90 |
+
<h3 className="text-sm font-semibold text-white">Raíz (Pantalla principal)</h3>
|
| 91 |
+
<p className="text-xs text-gray-400 border-gray-700">Sacar de cualquier carpeta</p>
|
| 92 |
+
</div>
|
| 93 |
+
</button>
|
| 94 |
+
|
| 95 |
+
<div className="h-px bg-gray-800 my-4" />
|
| 96 |
+
|
| 97 |
+
{filteredFolders.map((folder) => (
|
| 98 |
+
<button
|
| 99 |
+
key={folder.id}
|
| 100 |
+
onClick={() => handleMove(folder.id)}
|
| 101 |
+
disabled={isSaving}
|
| 102 |
+
className="w-full flex items-center gap-3 p-3 rounded-xl border border-gray-800 bg-[#1a1a1a] hover:border-blue-500 transition-all text-left group"
|
| 103 |
+
>
|
| 104 |
+
<div className="w-10 h-10 rounded-lg bg-gray-800 flex items-center justify-center overflow-hidden">
|
| 105 |
+
<FolderInput className="w-5 h-5 text-gray-400 group-hover:text-blue-400 transition-colors" />
|
| 106 |
+
</div>
|
| 107 |
+
<div className="flex-1">
|
| 108 |
+
<h3 className="text-sm font-semibold text-white group-hover:text-blue-400 transition-colors">{folder.title}</h3>
|
| 109 |
+
<p className="text-xs text-gray-400">Carpeta</p>
|
| 110 |
+
</div>
|
| 111 |
+
</button>
|
| 112 |
+
))}
|
| 113 |
+
|
| 114 |
+
{filteredFolders.length === 0 && (
|
| 115 |
+
<div className="text-center py-8 text-gray-500">
|
| 116 |
+
No hay carpetas disponibles
|
| 117 |
+
</div>
|
| 118 |
+
)}
|
| 119 |
+
</div>
|
| 120 |
+
</div>
|
| 121 |
+
</div>
|
| 122 |
+
);
|
| 123 |
+
}
|
src/components/SettingsModal.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { X, Trash2, Settings, Megaphone, Clock, Eye, Layers, Copy, Edit3, Tag } from 'lucide-react';
|
| 2 |
import { useState, useEffect } from 'react';
|
| 3 |
import { toast } from 'sonner';
|
| 4 |
import { saveAnnouncement } from '../services/announcement';
|
|
@@ -22,6 +22,8 @@ interface SettingsModalProps {
|
|
| 22 |
onEditTitlePlusChange: (enabled: boolean) => void;
|
| 23 |
isEtiquetadoraEnabled: boolean;
|
| 24 |
onEtiquetadoraChange: (enabled: boolean) => void;
|
|
|
|
|
|
|
| 25 |
onOpenTitleManager: () => void;
|
| 26 |
}
|
| 27 |
|
|
@@ -40,6 +42,8 @@ export function SettingsModal({
|
|
| 40 |
onEditTitlePlusChange,
|
| 41 |
isEtiquetadoraEnabled,
|
| 42 |
onEtiquetadoraChange,
|
|
|
|
|
|
|
| 43 |
onOpenTitleManager
|
| 44 |
}: SettingsModalProps) {
|
| 45 |
// Announcement State
|
|
@@ -159,6 +163,30 @@ export function SettingsModal({
|
|
| 159 |
</div>
|
| 160 |
</section>
|
| 161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
{/* Category Minus Toggle */}
|
| 163 |
<section className="space-y-4 pt-4 border-t border-gray-800">
|
| 164 |
<div className="flex items-center justify-between">
|
|
|
|
| 1 |
+
import { X, Trash2, Settings, Megaphone, Clock, Eye, Layers, Copy, Edit3, Tag, FolderPlus } from 'lucide-react';
|
| 2 |
import { useState, useEffect } from 'react';
|
| 3 |
import { toast } from 'sonner';
|
| 4 |
import { saveAnnouncement } from '../services/announcement';
|
|
|
|
| 22 |
onEditTitlePlusChange: (enabled: boolean) => void;
|
| 23 |
isEtiquetadoraEnabled: boolean;
|
| 24 |
onEtiquetadoraChange: (enabled: boolean) => void;
|
| 25 |
+
isFolderPlusEnabled: boolean;
|
| 26 |
+
onFolderPlusChange: (enabled: boolean) => void;
|
| 27 |
onOpenTitleManager: () => void;
|
| 28 |
}
|
| 29 |
|
|
|
|
| 42 |
onEditTitlePlusChange,
|
| 43 |
isEtiquetadoraEnabled,
|
| 44 |
onEtiquetadoraChange,
|
| 45 |
+
isFolderPlusEnabled,
|
| 46 |
+
onFolderPlusChange,
|
| 47 |
onOpenTitleManager
|
| 48 |
}: SettingsModalProps) {
|
| 49 |
// Announcement State
|
|
|
|
| 163 |
</div>
|
| 164 |
</section>
|
| 165 |
|
| 166 |
+
{/* Folder Plus Toggle */}
|
| 167 |
+
<section className="space-y-4 pt-4 border-t border-gray-800">
|
| 168 |
+
<div className="flex items-center justify-between">
|
| 169 |
+
<div className="flex items-center gap-3">
|
| 170 |
+
<div className={`p-2 rounded-lg ${isFolderPlusEnabled ? 'bg-indigo-500/10 text-indigo-400' : 'bg-gray-800 text-gray-400'}`}>
|
| 171 |
+
<FolderPlus className="w-5 h-5" />
|
| 172 |
+
</div>
|
| 173 |
+
<div>
|
| 174 |
+
<h3 className="text-sm font-semibold text-white">Carpetas Plus</h3>
|
| 175 |
+
<p className="text-xs text-gray-400">Habilitar selección para crear carpetas y agrupar mangas</p>
|
| 176 |
+
</div>
|
| 177 |
+
</div>
|
| 178 |
+
<label className="relative inline-flex items-center cursor-pointer">
|
| 179 |
+
<input
|
| 180 |
+
type="checkbox"
|
| 181 |
+
className="sr-only peer"
|
| 182 |
+
checked={isFolderPlusEnabled}
|
| 183 |
+
onChange={(e) => onFolderPlusChange(e.target.checked)}
|
| 184 |
+
/>
|
| 185 |
+
<div className="w-11 h-6 bg-gray-700 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-indigo-300 dark:peer-focus:ring-indigo-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-indigo-500"></div>
|
| 186 |
+
</label>
|
| 187 |
+
</div>
|
| 188 |
+
</section>
|
| 189 |
+
|
| 190 |
{/* Category Minus Toggle */}
|
| 191 |
<section className="space-y-4 pt-4 border-t border-gray-800">
|
| 192 |
<div className="flex items-center justify-between">
|
src/components/TitleManagerModal.tsx
CHANGED
|
@@ -1,176 +1,176 @@
|
|
| 1 |
-
import { useState, useMemo, useEffect } from 'react';
|
| 2 |
-
import { X, Search, Save, Edit3 } from 'lucide-react';
|
| 3 |
-
import { Manga } from '../types/manga';
|
| 4 |
-
import { toast } from 'sonner';
|
| 5 |
-
import { updateMangaTitles } from '../services/manga';
|
| 6 |
-
import { getThumbnailUrl } from '../utils/imageUtils';
|
| 7 |
-
|
| 8 |
-
interface TitleManagerModalProps {
|
| 9 |
-
isOpen: boolean;
|
| 10 |
-
onClose: () => void;
|
| 11 |
-
mangas: Manga[];
|
| 12 |
-
onSaveComplete: () => void;
|
| 13 |
-
}
|
| 14 |
-
|
| 15 |
-
export function TitleManagerModal({ isOpen, onClose, mangas, onSaveComplete }: TitleManagerModalProps) {
|
| 16 |
-
const [searchTerm, setSearchTerm] = useState('');
|
| 17 |
-
const [edits, setEdits] = useState<Record<string, string>>({});
|
| 18 |
-
const [isSaving, setIsSaving] = useState(false);
|
| 19 |
-
|
| 20 |
-
useEffect(() => {
|
| 21 |
-
if (isOpen) {
|
| 22 |
-
setSearchTerm('');
|
| 23 |
-
setEdits({});
|
| 24 |
-
}
|
| 25 |
-
}, [isOpen]);
|
| 26 |
-
|
| 27 |
-
const sortedAndFilteredMangas = useMemo(() => {
|
| 28 |
-
let result = [...mangas];
|
| 29 |
-
if (searchTerm) {
|
| 30 |
-
const lowerQuery = searchTerm.toLowerCase();
|
| 31 |
-
result = result.filter(m => m.title.toLowerCase().includes(lowerQuery));
|
| 32 |
-
}
|
| 33 |
-
return result.sort((a, b) => a.title.localeCompare(b.title));
|
| 34 |
-
}, [mangas, searchTerm]);
|
| 35 |
-
|
| 36 |
-
const handleTitleChange = (id: string, newTitle: string) => {
|
| 37 |
-
setEdits(prev => ({
|
| 38 |
-
...prev,
|
| 39 |
-
[id]: newTitle
|
| 40 |
-
}));
|
| 41 |
-
};
|
| 42 |
-
|
| 43 |
-
const handleSave = async () => {
|
| 44 |
-
const modifications = Object.entries(edits).filter(([id, newTitle]) => {
|
| 45 |
-
const originalManga = mangas.find(m => m.id === id);
|
| 46 |
-
return originalManga && originalManga.title !== newTitle.trim() && newTitle.trim() !== '';
|
| 47 |
-
});
|
| 48 |
-
|
| 49 |
-
if (modifications.length === 0) {
|
| 50 |
-
toast.info('No hay cambios para guardar');
|
| 51 |
-
return;
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
try {
|
| 55 |
-
setIsSaving(true);
|
| 56 |
-
const updates = modifications.map(([id, title]) => ({ id, title: title.trim() }));
|
| 57 |
-
await updateMangaTitles(updates);
|
| 58 |
-
toast.success(`Se actualizaron ${updates.length} nombres correctamente`);
|
| 59 |
-
onSaveComplete();
|
| 60 |
-
onClose();
|
| 61 |
-
} catch (error) {
|
| 62 |
-
console.error('Error saving titles:', error);
|
| 63 |
-
toast.error('Error al guardar los cambios');
|
| 64 |
-
} finally {
|
| 65 |
-
setIsSaving(false);
|
| 66 |
-
}
|
| 67 |
-
};
|
| 68 |
-
|
| 69 |
-
if (!isOpen) return null;
|
| 70 |
-
|
| 71 |
-
return (
|
| 72 |
-
<div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-[60] p-4 animate-in fade-in duration-200">
|
| 73 |
-
<div className="bg-[#121212] rounded-2xl border border-gray-800 w-full max-w-2xl shadow-2xl overflow-hidden flex flex-col max-h-[85vh]">
|
| 74 |
-
<div className="bg-[#1a1a1a] border-b border-gray-800 px-6 py-4 flex items-center justify-between sticky top-0 z-10 flex-shrink-0">
|
| 75 |
-
<div className="flex items-center gap-3">
|
| 76 |
-
<div className="p-2 bg-blue-500/10 rounded-lg text-blue-400">
|
| 77 |
-
<Edit3 className="w-5 h-5" />
|
| 78 |
-
</div>
|
| 79 |
-
<div>
|
| 80 |
-
<h2 className="text-xl font-bold text-white">Gestor de Nombres</h2>
|
| 81 |
-
<p className="text-xs text-gray-400">Edita los títulos de los mangas masivamente</p>
|
| 82 |
-
</div>
|
| 83 |
-
</div>
|
| 84 |
-
<button onClick={onClose} className="text-gray-400 hover:text-white transition-colors p-2 hover:bg-white/5 rounded-lg">
|
| 85 |
-
<X className="w-5 h-5" />
|
| 86 |
-
</button>
|
| 87 |
-
</div>
|
| 88 |
-
|
| 89 |
-
<div className="p-4 border-b border-gray-800 bg-[#121212] flex-shrink-0">
|
| 90 |
-
<div className="relative">
|
| 91 |
-
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400" />
|
| 92 |
-
<input
|
| 93 |
-
type="text"
|
| 94 |
-
value={searchTerm}
|
| 95 |
-
onChange={(e) => setSearchTerm(e.target.value)}
|
| 96 |
-
placeholder="Buscar manga por título..."
|
| 97 |
-
className="w-full bg-[#1a1a1a] border border-gray-700 rounded-xl pl-10 pr-4 py-3 text-sm text-white focus:outline-none focus:border-blue-500 transition-colors"
|
| 98 |
-
/>
|
| 99 |
-
</div>
|
| 100 |
-
</div>
|
| 101 |
-
|
| 102 |
-
<div className="flex-1 overflow-y-auto p-4 space-y-2 custom-scrollbar">
|
| 103 |
-
{sortedAndFilteredMangas.map((manga) => {
|
| 104 |
-
const originalSrc = manga.cover_url || manga.thumbnail_url;
|
| 105 |
-
const optimizedSrc = originalSrc ? getThumbnailUrl(originalSrc) : undefined;
|
| 106 |
-
return (
|
| 107 |
-
<div key={manga.id} className="flex items-center gap-3 bg-[#1a1a1a] p-3 rounded-lg border border-gray-800/50 hover:border-gray-700 transition-colors">
|
| 108 |
-
{optimizedSrc ? (
|
| 109 |
-
<img
|
| 110 |
-
src={optimizedSrc}
|
| 111 |
-
alt=""
|
| 112 |
-
className="w-10 h-10 rounded object-cover"
|
| 113 |
-
/>
|
| 114 |
-
) : (
|
| 115 |
-
<div className="w-10 h-10 rounded bg-gray-800 flex items-center justify-center">
|
| 116 |
-
<span className="text-xs text-gray-500 text-center">Sin img</span>
|
| 117 |
-
</div>
|
| 118 |
-
)}
|
| 119 |
-
<div className="flex-1">
|
| 120 |
-
<input
|
| 121 |
-
type="text"
|
| 122 |
-
value={edits[manga.id] !== undefined ? edits[manga.id] : manga.title}
|
| 123 |
-
onChange={(e) => handleTitleChange(manga.id, e.target.value)}
|
| 124 |
-
className={`w-full bg-transparent border-b pl-2 py-1 text-sm focus:outline-none transition-colors ${
|
| 125 |
-
edits[manga.id] !== undefined && edits[manga.id].trim() !== manga.title
|
| 126 |
-
? 'border-blue-500 text-blue-300'
|
| 127 |
-
: 'border-transparent hover:border-gray-700 text-white focus:border-gray-600'
|
| 128 |
-
}`}
|
| 129 |
-
placeholder="Título del manga"
|
| 130 |
-
/>
|
| 131 |
-
</div>
|
| 132 |
-
</div>
|
| 133 |
-
);
|
| 134 |
-
})}
|
| 135 |
-
{sortedAndFilteredMangas.length === 0 && (
|
| 136 |
-
<div className="text-center py-8 text-gray-500">
|
| 137 |
-
No se encontraron mangas con ese nombre
|
| 138 |
-
</div>
|
| 139 |
-
)}
|
| 140 |
-
</div>
|
| 141 |
-
|
| 142 |
-
<div className="bg-[#1a1a1a] border-t border-gray-800 px-6 py-4 flex justify-between items-center sticky bottom-0 flex-shrink-0">
|
| 143 |
-
<span className="text-sm text-gray-400">
|
| 144 |
-
{Object.keys(edits).filter(id => edits[id].trim() !== mangas.find(m => m.id === id)?.title).length} cambios pendientes
|
| 145 |
-
</span>
|
| 146 |
-
<div className="flex gap-3">
|
| 147 |
-
<button
|
| 148 |
-
onClick={onClose}
|
| 149 |
-
className="px-4 py-2 text-sm font-semibold text-gray-300 hover:text-white transition-colors"
|
| 150 |
-
disabled={isSaving}
|
| 151 |
-
>
|
| 152 |
-
Cancelar
|
| 153 |
-
</button>
|
| 154 |
-
<button
|
| 155 |
-
onClick={handleSave}
|
| 156 |
-
disabled={isSaving}
|
| 157 |
-
className="bg-blue-600 hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed text-white px-6 py-2 rounded-lg text-sm font-bold shadow-lg shadow-blue-500/20 transition-all flex items-center gap-2"
|
| 158 |
-
>
|
| 159 |
-
{isSaving ? (
|
| 160 |
-
<>
|
| 161 |
-
<div className="w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin" />
|
| 162 |
-
Guardando...
|
| 163 |
-
</>
|
| 164 |
-
) : (
|
| 165 |
-
<>
|
| 166 |
-
<Save className="w-4 h-4" />
|
| 167 |
-
Guardar Cambios
|
| 168 |
-
</>
|
| 169 |
-
)}
|
| 170 |
-
</button>
|
| 171 |
-
</div>
|
| 172 |
-
</div>
|
| 173 |
-
</div>
|
| 174 |
-
</div>
|
| 175 |
-
);
|
| 176 |
-
}
|
|
|
|
| 1 |
+
import { useState, useMemo, useEffect } from 'react';
|
| 2 |
+
import { X, Search, Save, Edit3 } from 'lucide-react';
|
| 3 |
+
import { Manga } from '../types/manga';
|
| 4 |
+
import { toast } from 'sonner';
|
| 5 |
+
import { updateMangaTitles } from '../services/manga';
|
| 6 |
+
import { getThumbnailUrl } from '../utils/imageUtils';
|
| 7 |
+
|
| 8 |
+
interface TitleManagerModalProps {
|
| 9 |
+
isOpen: boolean;
|
| 10 |
+
onClose: () => void;
|
| 11 |
+
mangas: Manga[];
|
| 12 |
+
onSaveComplete: () => void;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
export function TitleManagerModal({ isOpen, onClose, mangas, onSaveComplete }: TitleManagerModalProps) {
|
| 16 |
+
const [searchTerm, setSearchTerm] = useState('');
|
| 17 |
+
const [edits, setEdits] = useState<Record<string, string>>({});
|
| 18 |
+
const [isSaving, setIsSaving] = useState(false);
|
| 19 |
+
|
| 20 |
+
useEffect(() => {
|
| 21 |
+
if (isOpen) {
|
| 22 |
+
setSearchTerm('');
|
| 23 |
+
setEdits({});
|
| 24 |
+
}
|
| 25 |
+
}, [isOpen]);
|
| 26 |
+
|
| 27 |
+
const sortedAndFilteredMangas = useMemo(() => {
|
| 28 |
+
let result = [...mangas];
|
| 29 |
+
if (searchTerm) {
|
| 30 |
+
const lowerQuery = searchTerm.toLowerCase();
|
| 31 |
+
result = result.filter(m => m.title.toLowerCase().includes(lowerQuery));
|
| 32 |
+
}
|
| 33 |
+
return result.sort((a, b) => a.title.localeCompare(b.title));
|
| 34 |
+
}, [mangas, searchTerm]);
|
| 35 |
+
|
| 36 |
+
const handleTitleChange = (id: string, newTitle: string) => {
|
| 37 |
+
setEdits(prev => ({
|
| 38 |
+
...prev,
|
| 39 |
+
[id]: newTitle
|
| 40 |
+
}));
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
const handleSave = async () => {
|
| 44 |
+
const modifications = Object.entries(edits).filter(([id, newTitle]) => {
|
| 45 |
+
const originalManga = mangas.find(m => m.id === id);
|
| 46 |
+
return originalManga && originalManga.title !== newTitle.trim() && newTitle.trim() !== '';
|
| 47 |
+
});
|
| 48 |
+
|
| 49 |
+
if (modifications.length === 0) {
|
| 50 |
+
toast.info('No hay cambios para guardar');
|
| 51 |
+
return;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
try {
|
| 55 |
+
setIsSaving(true);
|
| 56 |
+
const updates = modifications.map(([id, title]) => ({ id, title: title.trim() }));
|
| 57 |
+
await updateMangaTitles(updates);
|
| 58 |
+
toast.success(`Se actualizaron ${updates.length} nombres correctamente`);
|
| 59 |
+
onSaveComplete();
|
| 60 |
+
onClose();
|
| 61 |
+
} catch (error) {
|
| 62 |
+
console.error('Error saving titles:', error);
|
| 63 |
+
toast.error('Error al guardar los cambios');
|
| 64 |
+
} finally {
|
| 65 |
+
setIsSaving(false);
|
| 66 |
+
}
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
if (!isOpen) return null;
|
| 70 |
+
|
| 71 |
+
return (
|
| 72 |
+
<div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-[60] p-4 animate-in fade-in duration-200">
|
| 73 |
+
<div className="bg-[#121212] rounded-2xl border border-gray-800 w-full max-w-2xl shadow-2xl overflow-hidden flex flex-col max-h-[85vh]">
|
| 74 |
+
<div className="bg-[#1a1a1a] border-b border-gray-800 px-6 py-4 flex items-center justify-between sticky top-0 z-10 flex-shrink-0">
|
| 75 |
+
<div className="flex items-center gap-3">
|
| 76 |
+
<div className="p-2 bg-blue-500/10 rounded-lg text-blue-400">
|
| 77 |
+
<Edit3 className="w-5 h-5" />
|
| 78 |
+
</div>
|
| 79 |
+
<div>
|
| 80 |
+
<h2 className="text-xl font-bold text-white">Gestor de Nombres</h2>
|
| 81 |
+
<p className="text-xs text-gray-400">Edita los títulos de los mangas masivamente</p>
|
| 82 |
+
</div>
|
| 83 |
+
</div>
|
| 84 |
+
<button onClick={onClose} className="text-gray-400 hover:text-white transition-colors p-2 hover:bg-white/5 rounded-lg">
|
| 85 |
+
<X className="w-5 h-5" />
|
| 86 |
+
</button>
|
| 87 |
+
</div>
|
| 88 |
+
|
| 89 |
+
<div className="p-4 border-b border-gray-800 bg-[#121212] flex-shrink-0">
|
| 90 |
+
<div className="relative">
|
| 91 |
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400" />
|
| 92 |
+
<input
|
| 93 |
+
type="text"
|
| 94 |
+
value={searchTerm}
|
| 95 |
+
onChange={(e) => setSearchTerm(e.target.value)}
|
| 96 |
+
placeholder="Buscar manga por título..."
|
| 97 |
+
className="w-full bg-[#1a1a1a] border border-gray-700 rounded-xl pl-10 pr-4 py-3 text-sm text-white focus:outline-none focus:border-blue-500 transition-colors"
|
| 98 |
+
/>
|
| 99 |
+
</div>
|
| 100 |
+
</div>
|
| 101 |
+
|
| 102 |
+
<div className="flex-1 overflow-y-auto p-4 space-y-2 custom-scrollbar">
|
| 103 |
+
{sortedAndFilteredMangas.map((manga) => {
|
| 104 |
+
const originalSrc = manga.cover_url || manga.thumbnail_url;
|
| 105 |
+
const optimizedSrc = originalSrc ? getThumbnailUrl(originalSrc) : undefined;
|
| 106 |
+
return (
|
| 107 |
+
<div key={manga.id} className="flex items-center gap-3 bg-[#1a1a1a] p-3 rounded-lg border border-gray-800/50 hover:border-gray-700 transition-colors">
|
| 108 |
+
{optimizedSrc ? (
|
| 109 |
+
<img
|
| 110 |
+
src={optimizedSrc}
|
| 111 |
+
alt=""
|
| 112 |
+
className="w-10 h-10 rounded object-cover"
|
| 113 |
+
/>
|
| 114 |
+
) : (
|
| 115 |
+
<div className="w-10 h-10 rounded bg-gray-800 flex items-center justify-center">
|
| 116 |
+
<span className="text-xs text-gray-500 text-center">Sin img</span>
|
| 117 |
+
</div>
|
| 118 |
+
)}
|
| 119 |
+
<div className="flex-1">
|
| 120 |
+
<input
|
| 121 |
+
type="text"
|
| 122 |
+
value={edits[manga.id] !== undefined ? edits[manga.id] : manga.title}
|
| 123 |
+
onChange={(e) => handleTitleChange(manga.id, e.target.value)}
|
| 124 |
+
className={`w-full bg-transparent border-b pl-2 py-1 text-sm focus:outline-none transition-colors ${
|
| 125 |
+
edits[manga.id] !== undefined && edits[manga.id].trim() !== manga.title
|
| 126 |
+
? 'border-blue-500 text-blue-300'
|
| 127 |
+
: 'border-transparent hover:border-gray-700 text-white focus:border-gray-600'
|
| 128 |
+
}`}
|
| 129 |
+
placeholder="Título del manga"
|
| 130 |
+
/>
|
| 131 |
+
</div>
|
| 132 |
+
</div>
|
| 133 |
+
);
|
| 134 |
+
})}
|
| 135 |
+
{sortedAndFilteredMangas.length === 0 && (
|
| 136 |
+
<div className="text-center py-8 text-gray-500">
|
| 137 |
+
No se encontraron mangas con ese nombre
|
| 138 |
+
</div>
|
| 139 |
+
)}
|
| 140 |
+
</div>
|
| 141 |
+
|
| 142 |
+
<div className="bg-[#1a1a1a] border-t border-gray-800 px-6 py-4 flex justify-between items-center sticky bottom-0 flex-shrink-0">
|
| 143 |
+
<span className="text-sm text-gray-400">
|
| 144 |
+
{Object.keys(edits).filter(id => edits[id].trim() !== mangas.find(m => m.id === id)?.title).length} cambios pendientes
|
| 145 |
+
</span>
|
| 146 |
+
<div className="flex gap-3">
|
| 147 |
+
<button
|
| 148 |
+
onClick={onClose}
|
| 149 |
+
className="px-4 py-2 text-sm font-semibold text-gray-300 hover:text-white transition-colors"
|
| 150 |
+
disabled={isSaving}
|
| 151 |
+
>
|
| 152 |
+
Cancelar
|
| 153 |
+
</button>
|
| 154 |
+
<button
|
| 155 |
+
onClick={handleSave}
|
| 156 |
+
disabled={isSaving}
|
| 157 |
+
className="bg-blue-600 hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed text-white px-6 py-2 rounded-lg text-sm font-bold shadow-lg shadow-blue-500/20 transition-all flex items-center gap-2"
|
| 158 |
+
>
|
| 159 |
+
{isSaving ? (
|
| 160 |
+
<>
|
| 161 |
+
<div className="w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin" />
|
| 162 |
+
Guardando...
|
| 163 |
+
</>
|
| 164 |
+
) : (
|
| 165 |
+
<>
|
| 166 |
+
<Save className="w-4 h-4" />
|
| 167 |
+
Guardar Cambios
|
| 168 |
+
</>
|
| 169 |
+
)}
|
| 170 |
+
</button>
|
| 171 |
+
</div>
|
| 172 |
+
</div>
|
| 173 |
+
</div>
|
| 174 |
+
</div>
|
| 175 |
+
);
|
| 176 |
+
}
|
src/services/manga.ts
CHANGED
|
@@ -794,3 +794,64 @@ export async function getAllAuthors(): Promise<string[]> {
|
|
| 794 |
|
| 795 |
return Array.from(authors).sort();
|
| 796 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 794 |
|
| 795 |
return Array.from(authors).sort();
|
| 796 |
}
|
| 797 |
+
|
| 798 |
+
export async function createFolderAndMove(folderName: string, selectedMangaIds: string[]): Promise<Manga> {
|
| 799 |
+
const now = Timestamp.now();
|
| 800 |
+
const folderData = {
|
| 801 |
+
title: folderName,
|
| 802 |
+
author: 'Carpeta',
|
| 803 |
+
description: '',
|
| 804 |
+
status: 'Carpeta',
|
| 805 |
+
categories: [],
|
| 806 |
+
views: 0,
|
| 807 |
+
rating: 0,
|
| 808 |
+
created_at: now,
|
| 809 |
+
updated_at: now,
|
| 810 |
+
is_folder: true,
|
| 811 |
+
};
|
| 812 |
+
|
| 813 |
+
const docRef = await addDoc(collection(db, 'mangas'), folderData);
|
| 814 |
+
const folderId = docRef.id;
|
| 815 |
+
|
| 816 |
+
if (selectedMangaIds.length > 0) {
|
| 817 |
+
await moveToFolder(selectedMangaIds, folderId);
|
| 818 |
+
}
|
| 819 |
+
|
| 820 |
+
const nowISO = new Date().toISOString();
|
| 821 |
+
const newFolder = {
|
| 822 |
+
id: folderId,
|
| 823 |
+
...folderData,
|
| 824 |
+
created_at: nowISO,
|
| 825 |
+
updated_at: nowISO,
|
| 826 |
+
chapters: [],
|
| 827 |
+
categories: [],
|
| 828 |
+
} as unknown as Manga;
|
| 829 |
+
|
| 830 |
+
mangaCache.set(folderId, newFolder);
|
| 831 |
+
removeLocal(STORAGE_KEYS.ALL_MANGAS);
|
| 832 |
+
|
| 833 |
+
return newFolder;
|
| 834 |
+
}
|
| 835 |
+
|
| 836 |
+
export async function moveToFolder(mangaIds: string[], folderId: string | null): Promise<void> {
|
| 837 |
+
const now = Timestamp.now();
|
| 838 |
+
const promises = mangaIds.map(async (mangaId) => {
|
| 839 |
+
const docRef = doc(db, 'mangas', mangaId);
|
| 840 |
+
await updateDoc(docRef, { folder_id: folderId, updated_at: now });
|
| 841 |
+
|
| 842 |
+
const cached = mangaCache.get(mangaId);
|
| 843 |
+
if (cached) {
|
| 844 |
+
if (folderId) {
|
| 845 |
+
cached.folder_id = folderId;
|
| 846 |
+
} else {
|
| 847 |
+
delete cached.folder_id;
|
| 848 |
+
}
|
| 849 |
+
cached.updated_at = now.toDate().toISOString();
|
| 850 |
+
mangaCache.set(mangaId, cached);
|
| 851 |
+
saveLocal(`${STORAGE_KEYS.MANGA_PREFIX}${mangaId}`, cached);
|
| 852 |
+
}
|
| 853 |
+
});
|
| 854 |
+
|
| 855 |
+
await Promise.all(promises);
|
| 856 |
+
removeLocal(STORAGE_KEYS.ALL_MANGAS);
|
| 857 |
+
}
|
src/services/reorderScript.ts
CHANGED
|
@@ -1,126 +1,126 @@
|
|
| 1 |
-
import { db } from '../lib/firebase';
|
| 2 |
-
import { collection, getDocs, doc, updateDoc, query, where } from 'firebase/firestore';
|
| 3 |
-
|
| 4 |
-
export type ReorderProgressCallback = (currentManga: string, current: number, total: number) => void;
|
| 5 |
-
|
| 6 |
-
interface PageData {
|
| 7 |
-
url: string;
|
| 8 |
-
originalUrl: string;
|
| 9 |
-
format: string;
|
| 10 |
-
pageNum: number;
|
| 11 |
-
}
|
| 12 |
-
|
| 13 |
-
export async function reorderAllMangasPages(onProgress?: ReorderProgressCallback): Promise<{ updated: number, errors: number }> {
|
| 14 |
-
let updatedCount = 0;
|
| 15 |
-
let errorCount = 0;
|
| 16 |
-
|
| 17 |
-
try {
|
| 18 |
-
const mangasRef = collection(db, 'mangas');
|
| 19 |
-
const mangasSnap = await getDocs(mangasRef);
|
| 20 |
-
const mangas = mangasSnap.docs;
|
| 21 |
-
|
| 22 |
-
let processed = 0;
|
| 23 |
-
|
| 24 |
-
for (const mangaDoc of mangas) {
|
| 25 |
-
const mangaData = mangaDoc.data();
|
| 26 |
-
const mangaId = mangaDoc.id;
|
| 27 |
-
|
| 28 |
-
processed++;
|
| 29 |
-
if (onProgress) {
|
| 30 |
-
onProgress(mangaData.title || mangaId, processed, mangas.length);
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
try {
|
| 34 |
-
const chaptersQuery = query(collection(db, 'chapters'), where('manga_id', '==', mangaId));
|
| 35 |
-
const chaptersSnap = await getDocs(chaptersQuery);
|
| 36 |
-
|
| 37 |
-
for (const chapterDoc of chaptersSnap.docs) {
|
| 38 |
-
const chapterData = chapterDoc.data();
|
| 39 |
-
const pages: string[] = chapterData.pages || [];
|
| 40 |
-
const originalPages: string[] = chapterData.original_pages || [];
|
| 41 |
-
const pageFormats: string[] = chapterData.page_formats || [];
|
| 42 |
-
|
| 43 |
-
if (pages.length === 0) continue;
|
| 44 |
-
|
| 45 |
-
// Gather page data to sort
|
| 46 |
-
const mappedPages: PageData[] = [];
|
| 47 |
-
|
| 48 |
-
for (let i = 0; i < pages.length; i++) {
|
| 49 |
-
const url = pages[i];
|
| 50 |
-
const originalUrl = originalPages[i] || url;
|
| 51 |
-
const format = pageFormats[i] || 'webp';
|
| 52 |
-
|
| 53 |
-
// Check if it's a Hugging Face URL
|
| 54 |
-
if (url.includes('hf.space')) {
|
| 55 |
-
try {
|
| 56 |
-
// Change out URL to use proxy
|
| 57 |
-
const proxyUrl = url.replace('https://codebydante-brodyfilestreambot.hf.space', '/hf-proxy');
|
| 58 |
-
|
| 59 |
-
// Fetch header
|
| 60 |
-
const response = await fetch(proxyUrl, { method: 'HEAD' });
|
| 61 |
-
|
| 62 |
-
if (response.ok) {
|
| 63 |
-
const contentDisposition = response.headers.get('content-disposition');
|
| 64 |
-
let pageNum = -1;
|
| 65 |
-
|
| 66 |
-
if (contentDisposition) {
|
| 67 |
-
// Extract filename="10.jpg_waifu..." -> "10.jpg_waifu..."
|
| 68 |
-
const filenameMatch = contentDisposition.match(/filename="?([^"]+)"?/);
|
| 69 |
-
if (filenameMatch) {
|
| 70 |
-
const filename = filenameMatch[1];
|
| 71 |
-
const numMatch = filename.match(/^(\d+)/);
|
| 72 |
-
if (numMatch) {
|
| 73 |
-
pageNum = parseInt(numMatch[1], 10);
|
| 74 |
-
}
|
| 75 |
-
}
|
| 76 |
-
}
|
| 77 |
-
|
| 78 |
-
// if we couldn't parse it, fallback to index
|
| 79 |
-
mappedPages.push({
|
| 80 |
-
url,
|
| 81 |
-
originalUrl,
|
| 82 |
-
format,
|
| 83 |
-
pageNum: pageNum !== -1 ? pageNum : i
|
| 84 |
-
});
|
| 85 |
-
} else {
|
| 86 |
-
// Fallback to index if request fails
|
| 87 |
-
mappedPages.push({ url, originalUrl, format, pageNum: i });
|
| 88 |
-
}
|
| 89 |
-
} catch (e) {
|
| 90 |
-
console.error(`Failed to fetch headers for ${url}`, e);
|
| 91 |
-
mappedPages.push({ url, originalUrl, format, pageNum: i });
|
| 92 |
-
}
|
| 93 |
-
} else {
|
| 94 |
-
// Not a HF url, just keep relative order
|
| 95 |
-
mappedPages.push({ url, originalUrl, format, pageNum: i });
|
| 96 |
-
}
|
| 97 |
-
}
|
| 98 |
-
|
| 99 |
-
// Sort mapped pages
|
| 100 |
-
mappedPages.sort((a, b) => a.pageNum - b.pageNum);
|
| 101 |
-
|
| 102 |
-
// Update chapter document with new arrays
|
| 103 |
-
const newPages = mappedPages.map(p => p.url);
|
| 104 |
-
const newOriginalPages = mappedPages.map(p => p.originalUrl);
|
| 105 |
-
const newPageFormats = mappedPages.map(p => p.format);
|
| 106 |
-
|
| 107 |
-
await updateDoc(doc(db, 'chapters', chapterDoc.id), {
|
| 108 |
-
pages: newPages,
|
| 109 |
-
original_pages: newOriginalPages,
|
| 110 |
-
page_formats: newPageFormats,
|
| 111 |
-
});
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
updatedCount++;
|
| 115 |
-
} catch (err) {
|
| 116 |
-
console.error(`Error processing chapter for manga ${mangaId}`, err);
|
| 117 |
-
errorCount++;
|
| 118 |
-
}
|
| 119 |
-
}
|
| 120 |
-
|
| 121 |
-
return { updated: updatedCount, errors: errorCount };
|
| 122 |
-
} catch (error) {
|
| 123 |
-
console.error("Error fetching mangas for reorder: ", error);
|
| 124 |
-
throw error;
|
| 125 |
-
}
|
| 126 |
-
}
|
|
|
|
| 1 |
+
import { db } from '../lib/firebase';
|
| 2 |
+
import { collection, getDocs, doc, updateDoc, query, where } from 'firebase/firestore';
|
| 3 |
+
|
| 4 |
+
export type ReorderProgressCallback = (currentManga: string, current: number, total: number) => void;
|
| 5 |
+
|
| 6 |
+
interface PageData {
|
| 7 |
+
url: string;
|
| 8 |
+
originalUrl: string;
|
| 9 |
+
format: string;
|
| 10 |
+
pageNum: number;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
export async function reorderAllMangasPages(onProgress?: ReorderProgressCallback): Promise<{ updated: number, errors: number }> {
|
| 14 |
+
let updatedCount = 0;
|
| 15 |
+
let errorCount = 0;
|
| 16 |
+
|
| 17 |
+
try {
|
| 18 |
+
const mangasRef = collection(db, 'mangas');
|
| 19 |
+
const mangasSnap = await getDocs(mangasRef);
|
| 20 |
+
const mangas = mangasSnap.docs;
|
| 21 |
+
|
| 22 |
+
let processed = 0;
|
| 23 |
+
|
| 24 |
+
for (const mangaDoc of mangas) {
|
| 25 |
+
const mangaData = mangaDoc.data();
|
| 26 |
+
const mangaId = mangaDoc.id;
|
| 27 |
+
|
| 28 |
+
processed++;
|
| 29 |
+
if (onProgress) {
|
| 30 |
+
onProgress(mangaData.title || mangaId, processed, mangas.length);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
try {
|
| 34 |
+
const chaptersQuery = query(collection(db, 'chapters'), where('manga_id', '==', mangaId));
|
| 35 |
+
const chaptersSnap = await getDocs(chaptersQuery);
|
| 36 |
+
|
| 37 |
+
for (const chapterDoc of chaptersSnap.docs) {
|
| 38 |
+
const chapterData = chapterDoc.data();
|
| 39 |
+
const pages: string[] = chapterData.pages || [];
|
| 40 |
+
const originalPages: string[] = chapterData.original_pages || [];
|
| 41 |
+
const pageFormats: string[] = chapterData.page_formats || [];
|
| 42 |
+
|
| 43 |
+
if (pages.length === 0) continue;
|
| 44 |
+
|
| 45 |
+
// Gather page data to sort
|
| 46 |
+
const mappedPages: PageData[] = [];
|
| 47 |
+
|
| 48 |
+
for (let i = 0; i < pages.length; i++) {
|
| 49 |
+
const url = pages[i];
|
| 50 |
+
const originalUrl = originalPages[i] || url;
|
| 51 |
+
const format = pageFormats[i] || 'webp';
|
| 52 |
+
|
| 53 |
+
// Check if it's a Hugging Face URL
|
| 54 |
+
if (url.includes('hf.space')) {
|
| 55 |
+
try {
|
| 56 |
+
// Change out URL to use proxy
|
| 57 |
+
const proxyUrl = url.replace('https://codebydante-brodyfilestreambot.hf.space', '/hf-proxy');
|
| 58 |
+
|
| 59 |
+
// Fetch header
|
| 60 |
+
const response = await fetch(proxyUrl, { method: 'HEAD' });
|
| 61 |
+
|
| 62 |
+
if (response.ok) {
|
| 63 |
+
const contentDisposition = response.headers.get('content-disposition');
|
| 64 |
+
let pageNum = -1;
|
| 65 |
+
|
| 66 |
+
if (contentDisposition) {
|
| 67 |
+
// Extract filename="10.jpg_waifu..." -> "10.jpg_waifu..."
|
| 68 |
+
const filenameMatch = contentDisposition.match(/filename="?([^"]+)"?/);
|
| 69 |
+
if (filenameMatch) {
|
| 70 |
+
const filename = filenameMatch[1];
|
| 71 |
+
const numMatch = filename.match(/^(\d+)/);
|
| 72 |
+
if (numMatch) {
|
| 73 |
+
pageNum = parseInt(numMatch[1], 10);
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
// if we couldn't parse it, fallback to index
|
| 79 |
+
mappedPages.push({
|
| 80 |
+
url,
|
| 81 |
+
originalUrl,
|
| 82 |
+
format,
|
| 83 |
+
pageNum: pageNum !== -1 ? pageNum : i
|
| 84 |
+
});
|
| 85 |
+
} else {
|
| 86 |
+
// Fallback to index if request fails
|
| 87 |
+
mappedPages.push({ url, originalUrl, format, pageNum: i });
|
| 88 |
+
}
|
| 89 |
+
} catch (e) {
|
| 90 |
+
console.error(`Failed to fetch headers for ${url}`, e);
|
| 91 |
+
mappedPages.push({ url, originalUrl, format, pageNum: i });
|
| 92 |
+
}
|
| 93 |
+
} else {
|
| 94 |
+
// Not a HF url, just keep relative order
|
| 95 |
+
mappedPages.push({ url, originalUrl, format, pageNum: i });
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
// Sort mapped pages
|
| 100 |
+
mappedPages.sort((a, b) => a.pageNum - b.pageNum);
|
| 101 |
+
|
| 102 |
+
// Update chapter document with new arrays
|
| 103 |
+
const newPages = mappedPages.map(p => p.url);
|
| 104 |
+
const newOriginalPages = mappedPages.map(p => p.originalUrl);
|
| 105 |
+
const newPageFormats = mappedPages.map(p => p.format);
|
| 106 |
+
|
| 107 |
+
await updateDoc(doc(db, 'chapters', chapterDoc.id), {
|
| 108 |
+
pages: newPages,
|
| 109 |
+
original_pages: newOriginalPages,
|
| 110 |
+
page_formats: newPageFormats,
|
| 111 |
+
});
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
updatedCount++;
|
| 115 |
+
} catch (err) {
|
| 116 |
+
console.error(`Error processing chapter for manga ${mangaId}`, err);
|
| 117 |
+
errorCount++;
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
return { updated: updatedCount, errors: errorCount };
|
| 122 |
+
} catch (error) {
|
| 123 |
+
console.error("Error fetching mangas for reorder: ", error);
|
| 124 |
+
throw error;
|
| 125 |
+
}
|
| 126 |
+
}
|
src/types/manga.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface Manga {
|
|
| 13 |
is_decensored?: boolean;
|
| 14 |
is_bn?: boolean;
|
| 15 |
is_color?: boolean;
|
|
|
|
|
|
|
| 16 |
categories?: Category[];
|
| 17 |
chapters?: Chapter[];
|
| 18 |
external_links?: Array<{ name: string; url: string }>;
|
|
|
|
| 13 |
is_decensored?: boolean;
|
| 14 |
is_bn?: boolean;
|
| 15 |
is_color?: boolean;
|
| 16 |
+
is_folder?: boolean;
|
| 17 |
+
folder_id?: string;
|
| 18 |
categories?: Category[];
|
| 19 |
chapters?: Chapter[];
|
| 20 |
external_links?: Array<{ name: string; url: string }>;
|
test_url.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
| 1 |
-
import axios from 'axios';
|
| 2 |
-
|
| 3 |
-
async function testUrl() {
|
| 4 |
-
const url = 'https://codebydante-brodyfilestreambot.hf.space/stream/7361?hash=1deaf9';
|
| 5 |
-
try {
|
| 6 |
-
const response = await axios({
|
| 7 |
-
url,
|
| 8 |
-
method: 'GET',
|
| 9 |
-
responseType: 'arraybuffer',
|
| 10 |
-
headers: {
|
| 11 |
-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
|
| 12 |
-
'Referer': 'https://google.com'
|
| 13 |
-
}
|
| 14 |
-
});
|
| 15 |
-
|
| 16 |
-
console.log('Headers:', response.headers);
|
| 17 |
-
console.log('Content-Type:', response.headers['content-type']);
|
| 18 |
-
} catch (err) {
|
| 19 |
-
console.error(err);
|
| 20 |
-
}
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
testUrl();
|
|
|
|
| 1 |
+
import axios from 'axios';
|
| 2 |
+
|
| 3 |
+
async function testUrl() {
|
| 4 |
+
const url = 'https://codebydante-brodyfilestreambot.hf.space/stream/7361?hash=1deaf9';
|
| 5 |
+
try {
|
| 6 |
+
const response = await axios({
|
| 7 |
+
url,
|
| 8 |
+
method: 'GET',
|
| 9 |
+
responseType: 'arraybuffer',
|
| 10 |
+
headers: {
|
| 11 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
|
| 12 |
+
'Referer': 'https://google.com'
|
| 13 |
+
}
|
| 14 |
+
});
|
| 15 |
+
|
| 16 |
+
console.log('Headers:', response.headers);
|
| 17 |
+
console.log('Content-Type:', response.headers['content-type']);
|
| 18 |
+
} catch (err) {
|
| 19 |
+
console.error(err);
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
testUrl();
|