feat(ST-05mofrm7): sortDir state + localStorage-persistentie aan PbiList toevoegen (#124)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1dd4e7761b
commit
bc90ef2040
1 changed files with 7 additions and 1 deletions
|
|
@ -203,6 +203,7 @@ export function PbiList({ productId, isDemo }: PbiListProps) {
|
|||
const [filterPriority, setFilterPriority] = useState<number | 'all'>('all')
|
||||
const [filterStatus, setFilterStatus] = useState<PbiStatusApi | 'all'>('all')
|
||||
const [sortMode, setSortMode] = useState<SortMode>('priority')
|
||||
const [sortDir, setSortDir] = useState<'asc' | 'desc'>('asc')
|
||||
const [prefsLoaded, setPrefsLoaded] = useState(false)
|
||||
const [dialogState, setDialogState] = useState<PbiDialogState | null>(null)
|
||||
const [activeDragId, setActiveDragId] = useState<string | null>(null)
|
||||
|
|
@ -225,6 +226,8 @@ export function PbiList({ productId, isDemo }: PbiListProps) {
|
|||
if (savedStatus === 'ready' || savedStatus === 'blocked' || savedStatus === 'done') {
|
||||
setFilterStatus(savedStatus)
|
||||
}
|
||||
const savedDir = localStorage.getItem('scrum4me:pbi_sort_dir')
|
||||
if (savedDir === 'asc' || savedDir === 'desc') setSortDir(savedDir)
|
||||
setPrefsLoaded(true)
|
||||
}, [])
|
||||
|
||||
|
|
@ -232,6 +235,7 @@ export function PbiList({ productId, isDemo }: PbiListProps) {
|
|||
useEffect(() => { if (prefsLoaded) localStorage.setItem('scrum4me:pbi_sort', sortMode) }, [sortMode, prefsLoaded])
|
||||
useEffect(() => { if (prefsLoaded) localStorage.setItem('scrum4me:pbi_filter_priority', String(filterPriority)) }, [filterPriority, prefsLoaded])
|
||||
useEffect(() => { if (prefsLoaded) localStorage.setItem('scrum4me:pbi_filter_status', filterStatus) }, [filterStatus, prefsLoaded])
|
||||
useEffect(() => { if (prefsLoaded) localStorage.setItem('scrum4me:pbi_sort_dir', sortDir) }, [sortDir, prefsLoaded])
|
||||
|
||||
// Sync server data into store — use stable string dep to avoid infinite loop
|
||||
const pbiIdKey = pbis.map(p => p.id).join(',')
|
||||
|
|
@ -259,7 +263,8 @@ export function PbiList({ productId, isDemo }: PbiListProps) {
|
|||
const activeFilterCount =
|
||||
(filterPriority !== 'all' ? 1 : 0) +
|
||||
(filterStatus !== 'all' ? 1 : 0) +
|
||||
(sortMode !== 'priority' ? 1 : 0)
|
||||
(sortMode !== 'priority' ? 1 : 0) +
|
||||
(sortDir !== 'asc' ? 1 : 0)
|
||||
|
||||
const filtered = [...base].sort((a, b) => {
|
||||
if (sortMode === 'code') {
|
||||
|
|
@ -392,6 +397,7 @@ export function PbiList({ productId, isDemo }: PbiListProps) {
|
|||
setFilterPriority('all')
|
||||
setFilterStatus('all')
|
||||
setSortMode('priority')
|
||||
setSortDir('asc')
|
||||
}}
|
||||
>
|
||||
Wis filters
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue