open tasks menu when clicking view
This commit is contained in:
parent
509b6c6132
commit
7201a914be
2 changed files with 18 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { Bell, CheckCircle, XCircle, Clock, Loader2, ChevronDown, ChevronUp, X } from 'lucide-react'
|
import { Bell, CheckCircle, XCircle, Clock, Loader2, ChevronDown, ChevronUp, X } from 'lucide-react'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
||||||
|
|
@ -8,9 +8,16 @@ import { Badge } from '@/components/ui/badge'
|
||||||
import { useTask, Task } from '@/contexts/task-context'
|
import { useTask, Task } from '@/contexts/task-context'
|
||||||
|
|
||||||
export function TaskNotificationMenu() {
|
export function TaskNotificationMenu() {
|
||||||
const { tasks, isFetching, isMenuOpen, cancelTask } = useTask()
|
const { tasks, isFetching, isMenuOpen, isRecentTasksExpanded, cancelTask } = useTask()
|
||||||
const [isExpanded, setIsExpanded] = useState(false)
|
const [isExpanded, setIsExpanded] = useState(false)
|
||||||
|
|
||||||
|
// Sync local state with context state
|
||||||
|
useEffect(() => {
|
||||||
|
if (isRecentTasksExpanded) {
|
||||||
|
setIsExpanded(true)
|
||||||
|
}
|
||||||
|
}, [isRecentTasksExpanded])
|
||||||
|
|
||||||
// Don't render if menu is closed
|
// Don't render if menu is closed
|
||||||
if (!isMenuOpen) return null
|
if (!isMenuOpen) return null
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,8 @@ interface TaskContextType {
|
||||||
isFetching: boolean;
|
isFetching: boolean;
|
||||||
isMenuOpen: boolean;
|
isMenuOpen: boolean;
|
||||||
toggleMenu: () => void;
|
toggleMenu: () => void;
|
||||||
|
isRecentTasksExpanded: boolean;
|
||||||
|
setRecentTasksExpanded: (expanded: boolean) => void;
|
||||||
// React Query states
|
// React Query states
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
error: Error | null;
|
error: Error | null;
|
||||||
|
|
@ -53,6 +55,7 @@ const TaskContext = createContext<TaskContextType | undefined>(undefined);
|
||||||
export function TaskProvider({ children }: { children: React.ReactNode }) {
|
export function TaskProvider({ children }: { children: React.ReactNode }) {
|
||||||
const [files, setFiles] = useState<TaskFile[]>([]);
|
const [files, setFiles] = useState<TaskFile[]>([]);
|
||||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||||
|
const [isRecentTasksExpanded, setIsRecentTasksExpanded] = useState(false);
|
||||||
const previousTasksRef = useRef<Task[]>([]);
|
const previousTasksRef = useRef<Task[]>([]);
|
||||||
const { isAuthenticated, isNoAuthMode } = useAuth();
|
const { isAuthenticated, isNoAuthMode } = useAuth();
|
||||||
|
|
||||||
|
|
@ -220,7 +223,10 @@ export function TaskProvider({ children }: { children: React.ReactNode }) {
|
||||||
description,
|
description,
|
||||||
action: {
|
action: {
|
||||||
label: "View",
|
label: "View",
|
||||||
onClick: () => setIsMenuOpen(true),
|
onClick: () => {
|
||||||
|
setIsMenuOpen(true);
|
||||||
|
setIsRecentTasksExpanded(true);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
@ -302,6 +308,8 @@ export function TaskProvider({ children }: { children: React.ReactNode }) {
|
||||||
isFetching,
|
isFetching,
|
||||||
isMenuOpen,
|
isMenuOpen,
|
||||||
toggleMenu,
|
toggleMenu,
|
||||||
|
isRecentTasksExpanded,
|
||||||
|
setRecentTasksExpanded: setIsRecentTasksExpanded,
|
||||||
isLoading,
|
isLoading,
|
||||||
error,
|
error,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue