Spaces:
Build error
Build error
Create src/routes/index.tsx
#11
by launch-calcium - opened
- src/routes/index.tsx +42 -0
src/routes/index.tsx
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState } from 'react';
|
| 2 |
+
import { useSites } from '../lib/grabber/useSites';
|
| 3 |
+
import { SearchBar } from '../components/grabber/SearchBar';
|
| 4 |
+
import { PostGrid } from '../components/grabber/PostGrid';
|
| 5 |
+
import { AddSiteDialog } from '../components/grabber/AddSiteDialog';
|
| 6 |
+
import { SiteSelect } from '../components/grabber/SiteSelect';
|
| 7 |
+
|
| 8 |
+
export default function GrabberPage() {
|
| 9 |
+
const { sites, addSite } = useSites();
|
| 10 |
+
const [selectedIds, setSelectedIds] = useState<string[]>([]);
|
| 11 |
+
const [results, setResults] = useState<any[]>([]);
|
| 12 |
+
const [siteId, setSiteId] = useState('e621');
|
| 13 |
+
const [isAddDialogOpen, setIsAddDialogOpen] = useState(false);
|
| 14 |
+
|
| 15 |
+
return (
|
| 16 |
+
<div className="max-w-6xl mx-auto p-4">
|
| 17 |
+
<header className="flex justify-between items-center mb-8 border-b pb-4">
|
| 18 |
+
<h1 className="text-2xl font-bold">Grabber</h1>
|
| 19 |
+
<div className="flex gap-2">
|
| 20 |
+
<SiteSelect sites={sites} onChange={(id) => setSiteId(id)} />
|
| 21 |
+
<button onClick={() => setIsAddDialogOpen(true)} className="px-3 py-1 bg-secondary rounded text-sm">+ Add site</button>
|
| 22 |
+
</div>
|
| 23 |
+
</header>
|
| 24 |
+
|
| 25 |
+
<SearchBar onResults={setResults} />
|
| 26 |
+
|
| 27 |
+
{results.length > 0 && (
|
| 28 |
+
<div className="mt-8">
|
| 29 |
+
<div className="flex justify-between items-center mb-4">
|
| 30 |
+
<span>Selected: {selectedIds.length}</span>
|
| 31 |
+
<button disabled={selectedIds.length === 0} className="px-4 py-2 bg-primary text-white rounded disabled:opacity-50">
|
| 32 |
+
Download ZIP
|
| 33 |
+
</button>
|
| 34 |
+
</div>
|
| 35 |
+
<PostGrid posts={results} onSelect={setSelectedIds} />
|
| 36 |
+
</div>
|
| 37 |
+
)}
|
| 38 |
+
|
| 39 |
+
<AddSiteDialog open={isAddDialogOpen} setOpen={setIsAddDialogOpen} onAdd={addSite} />
|
| 40 |
+
</div>
|
| 41 |
+
);
|
| 42 |
+
}
|