Enhance Training Framework Programs List with Filtering and Styling Improvements
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 37s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m20s
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 37s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m20s
- Introduced a new filter block for training framework programs, allowing users to refine their selections based on focus areas, training types, and target groups. - Updated the TrainingFrameworkProgramsListPage to integrate the filter block and manage filter states effectively. - Enhanced CSS styles for the filter block and program list, improving layout and spacing for better user experience. - Removed unused filter-related logic from the TrainingPlanningFrameworkImportModal, streamlining the component's functionality.
This commit is contained in:
1 parent
9c3494a7ea
commit
9d122d4808
4 files changed
+376
-260
No files matched your search
@@ -1,10 +1,16 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import api from '../utils/api'
|
||||
import NavStateLink from '../components/NavStateLink'
|
||||
import FrameworkProgramsFilterBlock from '../components/planning/FrameworkProgramsFilterBlock'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import { getTenantClubDependencyKey } from '../utils/activeClub'
|
||||
import { buildFrameworkProgramsListReturnContext } from '../utils/navReturnContext'
|
||||
import { frameworkSessionDurationLabel } from '../utils/frameworkProgramListHelpers'
|
||||
import {
|
||||
EMPTY_FRAMEWORK_IMPORT_FILTERS,
|
||||
filterFrameworkPrograms,
|
||||
frameworkSessionDurationLabel,
|
||||
hasActiveFrameworkImportFilters,
|
||||
} from '../utils/frameworkProgramListHelpers'
|
||||
|
||||
function dashIfEmpty(val) {
|
||||
const s = (val ?? '').toString().trim()
|
||||
@@ -87,16 +93,38 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
const [rows, setRows] = useState([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState('')
|
||||
const [catalogFocusAreas, setCatalogFocusAreas] = useState([])
|
||||
const [catalogTrainingTypes, setCatalogTrainingTypes] = useState([])
|
||||
const [catalogTargetGroups, setCatalogTargetGroups] = useState([])
|
||||
const [filters, setFilters] = useState(() => ({ ...EMPTY_FRAMEWORK_IMPORT_FILTERS }))
|
||||
const [filterPanelOpen, setFilterPanelOpen] = useState(true)
|
||||
|
||||
const filteredRows = useMemo(
|
||||
() => filterFrameworkPrograms(rows, filters),
|
||||
[rows, filters]
|
||||
)
|
||||
const filterActive = hasActiveFrameworkImportFilters(filters)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true)
|
||||
setError('')
|
||||
try {
|
||||
const list = await api.listTrainingFrameworkPrograms()
|
||||
const [list, fa, tt, tg] = await Promise.all([
|
||||
api.listTrainingFrameworkPrograms(),
|
||||
api.listFocusAreas({ status: 'active' }),
|
||||
api.listTrainingTypes({ status: 'active' }),
|
||||
api.listTargetGroups({ status: 'active' }),
|
||||
])
|
||||
setRows(Array.isArray(list) ? list : [])
|
||||
setCatalogFocusAreas(Array.isArray(fa) ? fa : [])
|
||||
setCatalogTrainingTypes(Array.isArray(tt) ? tt : [])
|
||||
setCatalogTargetGroups(Array.isArray(tg) ? tg : [])
|
||||
} catch (e) {
|
||||
setError(e.message || 'Laden fehlgeschlagen')
|
||||
setRows([])
|
||||
setCatalogFocusAreas([])
|
||||
setCatalogTrainingTypes([])
|
||||
setCatalogTargetGroups([])
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
@@ -181,8 +209,31 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
</NavStateLink>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<FrameworkProgramsFilterBlock
|
||||
programs={rows}
|
||||
filters={filters}
|
||||
onFiltersChange={setFilters}
|
||||
panelOpen={filterPanelOpen}
|
||||
onPanelOpenChange={setFilterPanelOpen}
|
||||
catalogFocusAreas={catalogFocusAreas}
|
||||
catalogTrainingTypes={catalogTrainingTypes}
|
||||
catalogTargetGroups={catalogTargetGroups}
|
||||
durationRadioName="fw-list-duration-mode"
|
||||
className="fw-prog-filter-block--list"
|
||||
/>
|
||||
|
||||
{filteredRows.length === 0 ? (
|
||||
<div className="card" style={{ marginTop: '1rem' }}>
|
||||
<p style={{ color: 'var(--text2)', margin: 0 }}>
|
||||
{filterActive
|
||||
? 'Kein Rahmenprogramm passt zu den gewählten Filtern. Passe die Kriterien an oder setze den Filter zurück.'
|
||||
: 'Keine Einträge.'}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<ul className="framework-programs-list">
|
||||
{rows.map((r) => (
|
||||
{filteredRows.map((r) => (
|
||||
<li key={r.id} className="card">
|
||||
<div
|
||||
style={{
|
||||
@@ -239,6 +290,8 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user