diff --git a/admin-panel/src/components/ReportGeneration.jsx b/admin-panel/src/components/ReportGeneration.jsx index 092cf6d..fc868a5 100644 --- a/admin-panel/src/components/ReportGeneration.jsx +++ b/admin-panel/src/components/ReportGeneration.jsx @@ -148,7 +148,10 @@ function ReportGeneration() { category_id: selectedCategory.id } - if (selectedSubCategories.length > 0) { + // Tüm alt kategoriler seçiliyse subcategory_ids gönderme — backend zaten tümünü tarar + const allSelected = selectedSubCategories.length > 0 && + selectedSubCategories.length === subCategories.length + if (selectedSubCategories.length > 0 && !allSelected) { requestBody.subcategory_ids = selectedSubCategories.map(cat => cat.id) } @@ -426,27 +429,28 @@ function ReportGeneration() { onClick={() => { if (generating) return const allIds = new Set(selectedSubCategories.map(c => c.id)) - const allSelected = filteredSubCategories.every(c => allIds.has(c.id)) + const allSelected = subCategories.every(c => allIds.has(c.id)) if (allSelected) { - const filterIds = new Set(filteredSubCategories.map(c => c.id)) - setSelectedSubCategories(prev => prev.filter(c => !filterIds.has(c.id))) + setSelectedSubCategories([]) } else { - const newOnes = filteredSubCategories.filter(c => !allIds.has(c.id)) + const newOnes = subCategories.filter(c => !allIds.has(c.id)) setSelectedSubCategories(prev => [...prev, ...newOnes]) } }} className={`flex items-center px-5 py-2.5 border-b border-slate-100 cursor-pointer hover:bg-slate-50 transition-colors ${generating ? 'opacity-50 cursor-not-allowed' : ''}`} >
0 && filteredSubCategories.every(c => selectedSubCategories.some(s => s.id === c.id)) + subCategories.length > 0 && subCategories.every(c => selectedSubCategories.some(s => s.id === c.id)) ? 'bg-orange-500 border-orange-500' : 'border-slate-300' }`}> - {filteredSubCategories.length > 0 && filteredSubCategories.every(c => selectedSubCategories.some(s => s.id === c.id)) && ( + {subCategories.length > 0 && subCategories.every(c => selectedSubCategories.some(s => s.id === c.id)) && ( )}
- Tümünü seç + + Tümünü seç ({selectedSubCategories.length}/{subCategories.length}) + {filteredSubCategories.length > 0 ? (