126 lines
4.8 KiB
TypeScript
126 lines
4.8 KiB
TypeScript
"use client";
|
|
|
|
import React, { useState } from 'react';
|
|
import { Search, BookOpen, Tag, Trash2, Star, Archive, X, Folder, FileText, Calendar, Heart, Users, LucideIcon } from 'lucide-react';
|
|
import { PaneLayout } from '@/app/carnet/page';
|
|
|
|
interface NavigationProps {
|
|
layout: PaneLayout;
|
|
onLayoutChange: (layout: PaneLayout) => void;
|
|
nextcloudFolders: string[];
|
|
onFolderSelect: (folder: string) => void;
|
|
}
|
|
|
|
type FolderType = 'Notes' | 'Diary' | 'Health' | 'Contacts';
|
|
|
|
interface FolderConfig {
|
|
icon: LucideIcon;
|
|
order: number;
|
|
}
|
|
|
|
// Define folder order and icons
|
|
const FOLDER_CONFIG: Record<FolderType, FolderConfig> = {
|
|
'Notes': { icon: FileText, order: 1 },
|
|
'Diary': { icon: Calendar, order: 2 },
|
|
'Health': { icon: Heart, order: 3 },
|
|
'Contacts': { icon: Users, order: 4 }
|
|
};
|
|
|
|
export default function Navigation({ layout, onLayoutChange, nextcloudFolders, onFolderSelect }: NavigationProps) {
|
|
const [searchQuery, setSearchQuery] = useState('');
|
|
|
|
// Sort folders according to the specified order
|
|
const sortedFolders = [...nextcloudFolders].sort((a, b) => {
|
|
const orderA = (FOLDER_CONFIG[a as FolderType]?.order) || 999;
|
|
const orderB = (FOLDER_CONFIG[b as FolderType]?.order) || 999;
|
|
return orderA - orderB;
|
|
});
|
|
|
|
return (
|
|
<div className="flex flex-col h-full bg-carnet-sidebar">
|
|
{/* Search */}
|
|
<div className="p-4">
|
|
<div className="relative">
|
|
<input
|
|
type="text"
|
|
value={searchQuery}
|
|
onChange={(e) => setSearchQuery(e.target.value)}
|
|
placeholder="Recherché..."
|
|
className="w-full pl-9 pr-4 py-2 bg-white border border-carnet-border rounded-md text-sm text-carnet-text-primary placeholder-carnet-text-muted focus:outline-none focus:ring-1 focus:ring-primary"
|
|
/>
|
|
<Search className="absolute left-3 top-2.5 h-4 w-4 text-carnet-text-muted" />
|
|
{searchQuery && (
|
|
<button
|
|
onClick={() => setSearchQuery('')}
|
|
className="absolute right-3 top-2.5 text-carnet-text-muted hover:text-carnet-text-primary"
|
|
>
|
|
<X className="h-4 w-4" />
|
|
</button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
|
|
{/* Navigation Items */}
|
|
<div className="flex-1 overflow-y-auto">
|
|
<div className="px-3">
|
|
<div className="space-y-0.5">
|
|
<div
|
|
className="flex items-center px-3 py-2 rounded-md hover:bg-carnet-hover cursor-pointer text-carnet-text-primary"
|
|
onClick={() => onLayoutChange?.(PaneLayout.ItemSelection)}
|
|
>
|
|
<BookOpen className="w-4 h-4 mr-3" />
|
|
<span className="text-sm">Page</span>
|
|
<span className="ml-auto text-xs text-carnet-text-muted">54</span>
|
|
</div>
|
|
|
|
<div
|
|
className="flex items-center px-3 py-2 rounded-md hover:bg-carnet-hover cursor-pointer text-carnet-text-primary"
|
|
onClick={() => onLayoutChange?.(PaneLayout.TagSelection)}
|
|
>
|
|
<Star className="w-4 h-4 mr-3" />
|
|
<span className="text-sm">Important</span>
|
|
</div>
|
|
|
|
<div
|
|
className="flex items-center px-3 py-2 rounded-md hover:bg-carnet-hover cursor-pointer text-carnet-text-primary"
|
|
>
|
|
<Archive className="w-4 h-4 mr-3" />
|
|
<span className="text-sm">Archivé</span>
|
|
<span className="ml-auto text-xs text-carnet-text-muted">18</span>
|
|
</div>
|
|
|
|
<div
|
|
className="flex items-center px-3 py-2 rounded-md hover:bg-carnet-hover cursor-pointer text-carnet-text-primary"
|
|
onClick={() => onLayoutChange?.(PaneLayout.TableView)}
|
|
>
|
|
<Trash2 className="w-4 h-4 mr-3" />
|
|
<span className="text-sm">Corbeille</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Nextcloud Folders Section */}
|
|
{sortedFolders.length > 0 && (
|
|
<div className="mt-6 px-3">
|
|
<h3 className="px-3 mb-2 text-xs font-medium text-carnet-text-muted uppercase">Vues</h3>
|
|
<div className="space-y-0.5">
|
|
{sortedFolders.map((folder) => {
|
|
const Icon = FOLDER_CONFIG[folder as FolderType]?.icon || Folder;
|
|
return (
|
|
<div
|
|
key={folder}
|
|
className="flex items-center px-3 py-2 rounded-md hover:bg-carnet-hover cursor-pointer"
|
|
onClick={() => onFolderSelect(folder)}
|
|
>
|
|
<Icon className="w-4 h-4 mr-3 text-carnet-text-muted" />
|
|
<span className="text-sm text-carnet-text-primary">{folder}</span>
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|