Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | 'use client'; /** * BulkActions - Bulk action controls for selected tickets */ import React, { useState, useEffect } from 'react'; import { TICKET_STATUS_CONFIG, TICKET_PRIORITY_CONFIG } from '@/constants/support'; import { Icon } from '@/components/ui/icons'; export interface BulkActionsProps { /** Number of selected tickets */ selectedCount: number; /** Handler for bulk actions */ onAction: (action: string, value?: string) => void; /** Handler to clear selection */ onClear: () => void; } interface Agent { id: string; name: string; } export default function BulkActions({ selectedCount, onAction, onClear}: BulkActionsProps) { const [agents, setAgents] = useState<Agent[]>([]); const [showAssignDropdown, setShowAssignDropdown] = useState(false); const [showStatusDropdown, setShowStatusDropdown] = useState(false); const [showPriorityDropdown, setShowPriorityDropdown] = useState(false); useEffect(() => { fetch('/api/admin/support/agents') .then((res) => res.json()) .then((data) => setAgents(data.agents || [])) .catch(() => {}); }, []); return ( <div className="bg-blue-50 border border-blue-200 rounded-lg px-4 py-3 flex items-center justify-between"> <div className="flex items-center gap-2"> <span className="text-sm font-medium text-blue-700"> {selectedCount} ticket{selectedCount !== 1 ? 's' : ''} selected </span> <button type="button" onClick={onClear} className="text-sm text-blue-600 hover:text-blue-800" > Clear </button> </div> <div className="flex items-center gap-2"> {/* Assign Dropdown */} <div className="relative"> <button type="button" onClick={() => setShowAssignDropdown(!showAssignDropdown)} className="px-3 py-1.5 text-sm bg-white border border-gray-300 rounded-lg hover:bg-gray-50 flex items-center gap-1" > Assign <Icon name="chevron-down" size={16} /> </button> {showAssignDropdown && ( <div className="absolute right-0 top-full mt-1 bg-white border border-gray-200 rounded-lg shadow-lg z-10 min-w-[160px]"> <button type="button" onClick={() => { onAction('assign', ''); setShowAssignDropdown(false); }} className="w-full px-4 py-2 text-left text-sm text-gray-700 hover:bg-gray-100" > Unassign </button> {agents.map((agent) => ( <button key={agent.id} type="button" onClick={() => { onAction('assign', agent.id); setShowAssignDropdown(false); }} className="w-full px-4 py-2 text-left text-sm text-gray-700 hover:bg-gray-100" > {agent.name} </button> ))} </div> )} </div> {/* Status Dropdown */} <div className="relative"> <button type="button" onClick={() => setShowStatusDropdown(!showStatusDropdown)} className="px-3 py-1.5 text-sm bg-white border border-gray-300 rounded-lg hover:bg-gray-50 flex items-center gap-1" > Status <Icon name="chevron-down" size={16} /> </button> {showStatusDropdown && ( <div className="absolute right-0 top-full mt-1 bg-white border border-gray-200 rounded-lg shadow-lg z-10 min-w-[160px]"> {Object.entries(TICKET_STATUS_CONFIG).map(([key, config]) => ( <button key={key} type="button" onClick={() => { onAction('status', key); setShowStatusDropdown(false); }} className="w-full px-4 py-2 text-left text-sm text-gray-700 hover:bg-gray-100" > {config.label} </button> ))} </div> )} </div> {/* Priority Dropdown */} <div className="relative"> <button type="button" onClick={() => setShowPriorityDropdown(!showPriorityDropdown)} className="px-3 py-1.5 text-sm bg-white border border-gray-300 rounded-lg hover:bg-gray-50 flex items-center gap-1" > Priority <Icon name="chevron-down" size={16} /> </button> {showPriorityDropdown && ( <div className="absolute right-0 top-full mt-1 bg-white border border-gray-200 rounded-lg shadow-lg z-10 min-w-[160px]"> {Object.entries(TICKET_PRIORITY_CONFIG).map(([key, config]) => ( <button key={key} type="button" onClick={() => { onAction('priority', key); setShowPriorityDropdown(false); }} className="w-full px-4 py-2 text-left text-sm text-gray-700 hover:bg-gray-100" > {config.label} </button> ))} </div> )} </div> </div> </div> ); } |