Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions web/features/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type { Box } from './types';

export default function Home() {
const [allBoxes, setAllBoxes] = useState<Box[]>([]);
const [boxes, setBoxes] = useState<Box[]>([]);
const [search, setSearch] = useState('');
const [loadingBoxes, setLoadingBoxes] = useState(true);
const [pinned, setPinned] = useState<string[]>(() => {
Expand All @@ -30,15 +29,9 @@ export default function Home() {

useEffect(() => {
document.title = 'Kotakin';

loadBoxes();
}, [loadBoxes]);

useEffect(() => {
const boxes = allBoxes.filter((box) => box.id.includes(search) || box.name?.includes(search));
setBoxes(boxes);
}, [allBoxes, search]);

const handlePin = (id: string) => {
setPinned((pin) => (pin.includes(id) ? pin.filter((pid) => pid !== id) : [...pin, id]));
};
Expand All @@ -47,6 +40,7 @@ export default function Home() {
localStorage.setItem('pinned', JSON.stringify(pinned));
}, [pinned]);

const boxes = allBoxes.filter((box) => box.id.includes(search) || box.name?.includes(search));
const pinnedBoxes = boxes.filter((box) => pinned.includes(box.id));
const unpinnedBoxes = boxes.filter((box) => !pinned.includes(box.id));

Expand Down Expand Up @@ -78,10 +72,16 @@ export default function Home() {
</div>
</nav>

{boxes.length === 0 && (
{!loadingBoxes && boxes.length === 0 && (
<div className="text-center py-5">
<i className="bi bi-box display-1" />
<p className="mt-3 text-muted">No boxes available.</p>
<Link to="/store">
<Button variant="primary" className="mt-3">
<i className="bi bi-plus me-1" />
Add Application
</Button>
</Link>
</div>
)}

Expand Down