Wire TopBar search to tasks and files pages
- Add /tasks and /files to SEARCH_ROUTES so the TopBar search input is active on those pages - Tasks page reads search query from URL ?q= param instead of local state; remove duplicate search input from header - Files page reads ?q= param to filter tablos and files by name Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
dfb4e2800f
commit
6e38ac2a63
3 changed files with 15 additions and 26 deletions
|
|
@ -321,7 +321,7 @@ function ProfileDropdown() {
|
|||
);
|
||||
}
|
||||
|
||||
const SEARCH_ROUTES = ["/tablos", "/"];
|
||||
const SEARCH_ROUTES = ["/tablos", "/", "/tasks", "/files"];
|
||||
|
||||
export function TopBar() {
|
||||
const location = useLocation();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import {
|
|||
} from "lucide-react";
|
||||
import { useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import { Link, useSearchParams } from "react-router-dom";
|
||||
import {
|
||||
extractFolderIdFromFileName,
|
||||
getFileNameWithoutFolder,
|
||||
|
|
@ -428,6 +428,8 @@ function FileTable({
|
|||
|
||||
export function FilesPage() {
|
||||
const { t } = useTranslation("navigation");
|
||||
const [searchParams] = useSearchParams();
|
||||
const searchQuery = searchParams.get("q")?.toLowerCase() ?? "";
|
||||
const { data: tablos, isLoading: tablosLoading } = useTablosList();
|
||||
const { data: allFiles, isLoading: filesLoading } = useAllTablosFileNames();
|
||||
const [uploadOpen, setUploadOpen] = useState(false);
|
||||
|
|
@ -440,7 +442,13 @@ export function FilesPage() {
|
|||
|
||||
const tablosWithFiles = (tablos ?? []).filter((tablo) => {
|
||||
const files = filesByTabloId.get(tablo.id) ?? [];
|
||||
return files.some((f) => !f.startsWith("."));
|
||||
const visibleFiles = files.filter((f) => !f.startsWith("."));
|
||||
if (searchQuery) {
|
||||
return visibleFiles.some((f) =>
|
||||
f.toLowerCase().includes(searchQuery) || tablo.name.toLowerCase().includes(searchQuery)
|
||||
);
|
||||
}
|
||||
return visibleFiles.length > 0;
|
||||
});
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import {
|
|||
MapIcon,
|
||||
PaperclipIcon,
|
||||
PlusIcon,
|
||||
SearchIcon,
|
||||
Settings2Icon,
|
||||
UserIcon,
|
||||
} from "lucide-react";
|
||||
|
|
@ -65,7 +64,7 @@ export function TasksPage() {
|
|||
const [statusFilter, setStatusFilter] = useState<TaskStatus>("all");
|
||||
const [assigneeFilter, setAssigneeFilter] = useState<string>("all");
|
||||
const [isTaskModalOpen, setIsTaskModalOpen] = useState(false);
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const searchQuery = searchParams.get("q") ?? "";
|
||||
|
||||
// Get view mode from URL params, default to "kanban"
|
||||
const viewMode =
|
||||
|
|
@ -123,14 +122,7 @@ export function TasksPage() {
|
|||
}
|
||||
|
||||
return filtered;
|
||||
}, [
|
||||
allTasks,
|
||||
selectedTabloId,
|
||||
statusFilter,
|
||||
assigneeFilter,
|
||||
user.id,
|
||||
searchQuery,
|
||||
]);
|
||||
}, [allTasks, selectedTabloId, statusFilter, assigneeFilter, user.id, searchQuery]);
|
||||
|
||||
// Initialize Kanban columns from filtered tasks
|
||||
const columns = useMemo((): KanbanColumn[] => {
|
||||
|
|
@ -289,19 +281,8 @@ export function TasksPage() {
|
|||
})}
|
||||
</div>
|
||||
|
||||
{/* Search + filter row */}
|
||||
<div className="flex flex-col md:flex-row md:items-center md:justify-between gap-3">
|
||||
<div className="flex-1 relative md:max-w-[300px] w-full">
|
||||
<SearchIcon className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Rechercher..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="w-full pl-10 pr-4 py-2 border border-gray-200 dark:border-gray-700 rounded-lg text-sm placeholder-gray-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-purple-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Filter row */}
|
||||
<div className="flex flex-col md:flex-row md:items-center md:justify-end gap-3">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
|
|
|
|||
Loading…
Reference in a new issue