diff --git a/src/components/CommunityPortal/Reports/Participation/NoShowInsights.jsx b/src/components/CommunityPortal/Reports/Participation/NoShowInsights.jsx index ab635e8ad0..7fce559d4a 100644 --- a/src/components/CommunityPortal/Reports/Participation/NoShowInsights.jsx +++ b/src/components/CommunityPortal/Reports/Participation/NoShowInsights.jsx @@ -1,12 +1,20 @@ -import { useState } from 'react'; +import { useState, useRef } from 'react'; import { useSelector } from 'react-redux'; +import { ArrowUpDown, ArrowUp, ArrowDown, SquareArrowOutUpRight } from 'lucide-react'; +import html2canvas from 'html2canvas'; +import { jsPDF } from 'jspdf'; import mockEvents from './mockData'; import styles from './Participation.module.css'; function NoShowInsights() { const [dateFilter, setDateFilter] = useState('All'); const [activeTab, setActiveTab] = useState('Event type'); + const [sortOrder, setSortOrder] = useState('none'); const darkMode = useSelector(state => state.theme.darkMode); + const insightsRef = useRef(null); + const [isExportOpen, setIsExportOpen] = useState(false); + const [exportError, setExportError] = useState(''); + const [isExporting, setIsExporting] = useState(false); const filterByDate = events => { const today = new Date(); @@ -33,6 +41,15 @@ function NoShowInsights() { }); }; + const handleSortClick = () => { + setSortOrder(prev => { + if (prev === 'none' || prev === 'desc') return 'asc'; + if (prev === 'asc') return 'desc'; + return 'none'; + }); + }; + const SortIcon = sortOrder === 'none' ? ArrowUpDown : sortOrder === 'asc' ? ArrowUp : ArrowDown; + const calculateStats = filteredEvents => { const statsMap = new Map(); @@ -64,8 +81,14 @@ function NoShowInsights() { const renderStats = () => { const filteredEvents = filterByDate(mockEvents); const stats = calculateStats(filteredEvents); + const finalStats = + sortOrder === 'none' + ? stats + : [...stats].sort((a, b) => + sortOrder === 'asc' ? a.percentage - b.percentage : b.percentage - a.percentage, + ); - return stats.map(item => ( + return finalStats.map(item => (