Refactor Channel Manager sidebar

This commit is contained in:
gpt-engineer-app[bot]
2025-10-10 22:09:50 +00:00
parent aae25097b1
commit 2ba611cc33
2 changed files with 52 additions and 3 deletions

View File

@@ -63,6 +63,14 @@ const DashboardLayout = ({ children }: { children: React.ReactNode }) => {
{ icon: MessageSquare, label: 'Message', path: '/dashboard/messages', badge: '2' }, { icon: MessageSquare, label: 'Message', path: '/dashboard/messages', badge: '2' },
]; ];
const channelManagerSubmenu = [
{ icon: BarChart3, label: 'Resumen', tab: 'overview' },
{ icon: Zap, label: 'Canales', tab: 'channels' },
{ icon: Home, label: 'Propiedades', tab: 'listings' },
{ icon: BookOpen, label: 'Reservas', tab: 'reservations' },
{ icon: BarChart3, label: 'Analytics', tab: 'analytics' },
];
const adminSubmenu = [ const adminSubmenu = [
{ icon: BarChart3, label: 'Resumen General', tab: 'overview' }, { icon: BarChart3, label: 'Resumen General', tab: 'overview' },
{ icon: Users, label: 'Gestión de Usuarios', tab: 'users' }, { icon: Users, label: 'Gestión de Usuarios', tab: 'users' },
@@ -156,6 +164,7 @@ const DashboardLayout = ({ children }: { children: React.ReactNode }) => {
const Icon = item.icon; const Icon = item.icon;
const isActive = location.pathname === item.path; const isActive = location.pathname === item.path;
const isAdminPanel = item.path === '/dashboard/admin'; const isAdminPanel = item.path === '/dashboard/admin';
const isChannelManager = item.path === '/dashboard/channel-manager';
return ( return (
<div key={item.path}> <div key={item.path}>
@@ -185,6 +194,27 @@ const DashboardLayout = ({ children }: { children: React.ReactNode }) => {
)} )}
</Link> </Link>
{/* Channel Manager submenus */}
{!sidebarCollapsed && isChannelManager && location.pathname.startsWith('/dashboard/channel-manager') && (
<div className="mt-1 ml-10 space-y-1">
{channelManagerSubmenu.map((sub) => {
const SubIcon = sub.icon;
const activeSub = currentTab === sub.tab;
return (
<Link
key={sub.tab}
to={`/dashboard/channel-manager?tab=${sub.tab}`}
className={`flex items-center space-x-2 px-3 py-2 rounded-md text-sm ${activeSub ? 'bg-orange-50 text-orange-800' : 'text-gray-600 hover:text-orange-600 hover:bg-gray-50'}`}
>
<SubIcon className="w-4 h-4" />
<span>{sub.label}</span>
</Link>
);
})}
</div>
)}
{/* Admin submenus */} {/* Admin submenus */}
{!sidebarCollapsed && isAdminPanel && location.pathname.startsWith('/dashboard/admin') && ( {!sidebarCollapsed && isAdminPanel && location.pathname.startsWith('/dashboard/admin') && (
<div className="mt-1 ml-10 space-y-1"> <div className="mt-1 ml-10 space-y-1">

View File

@@ -1,4 +1,5 @@
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
@@ -41,6 +42,8 @@ import { AnalyticsTab } from '@/components/channel-manager/AnalyticsTab';
import { useToast } from '@/hooks/use-toast'; import { useToast } from '@/hooks/use-toast';
const ChannelManager = () => { const ChannelManager = () => {
const location = useLocation();
const navigate = useNavigate();
const { toast } = useToast(); const { toast } = useToast();
const { const {
channels, channels,
@@ -61,7 +64,23 @@ const ChannelManager = () => {
clearError clearError
} = useChannelManager(); } = useChannelManager();
const [activeTab, setActiveTab] = useState('overview'); // Get active tab from URL or default to 'overview'
const queryParams = new URLSearchParams(location.search);
const urlTab = queryParams.get('tab') || 'overview';
const [activeTab, setActiveTab] = useState(urlTab);
// Update active tab when URL changes
useEffect(() => {
const newTab = queryParams.get('tab') || 'overview';
setActiveTab(newTab);
}, [location.search]);
// Update URL when tab changes
const handleTabChange = (newTab: string) => {
setActiveTab(newTab);
navigate(`/dashboard/channel-manager?tab=${newTab}`);
};
const [searchTerm, setSearchTerm] = useState(''); const [searchTerm, setSearchTerm] = useState('');
const [filterType, setFilterType] = useState('all'); const [filterType, setFilterType] = useState('all');
const [showConnectModal, setShowConnectModal] = useState(false); const [showConnectModal, setShowConnectModal] = useState(false);
@@ -693,7 +712,7 @@ const ChannelManager = () => {
</p> </p>
</div> </div>
<Tabs value={activeTab} onValueChange={setActiveTab} className="space-y-6"> <Tabs value={activeTab} onValueChange={handleTabChange} className="space-y-6">
<TabsList className="grid w-full grid-cols-5"> <TabsList className="grid w-full grid-cols-5">
<TabsTrigger value="overview"> <TabsTrigger value="overview">
<TrendingUp className="w-4 h-4 mr-2" /> <TrendingUp className="w-4 h-4 mr-2" />