refactor(ui): Improve usage log filter responsiveness and mobile UX

Refactor the usage log filter toolbar into a shared reusable component for common, drawing, and task logs. Optimize desktop filters with a responsive grid, move secondary filters into a mobile drawer, standardize filter typography, remove redundant filter icons, and add the missing i18n translations for the new drawer description.
This commit is contained in:
t0ng7u
2026-05-25 05:35:44 +08:00
parent b302be30e3
commit 583da45296
79 changed files with 1879 additions and 1262 deletions
+40 -33
View File
@@ -62,7 +62,7 @@ function getAnnouncementKey(item: Record<string, unknown>): string {
* Provides unread counts and read status management
*/
export function useNotifications() {
const [dialogOpen, setDialogOpen] = useState(false)
const [popoverOpen, setPopoverOpen] = useState(false)
const [activeTab, setActiveTab] = useState<'notice' | 'announcements'>(
'notice'
)
@@ -92,8 +92,6 @@ export function useNotifications() {
markNoticeRead,
markAnnouncementsRead,
isAnnouncementRead,
isNoticeClosed,
setClosedUntilDate,
} = useNotificationStore()
// Extract notice content
@@ -120,22 +118,8 @@ export function useNotifications() {
}
}, [noticeContent, lastReadNotice, announcements, isAnnouncementRead])
// Handle dialog open
const handleOpenDialog = (tab?: 'notice' | 'announcements') => {
// Mark Notice as read when opening dialog
if (noticeContent) {
markNoticeRead(noticeContent)
}
setActiveTab(tab || 'notice')
setDialogOpen(true)
}
// Handle tab change - mark announcements as read when switching to that tab
const handleTabChange = (tab: 'notice' | 'announcements') => {
setActiveTab(tab)
if (tab === 'announcements' && announcements.length > 0) {
const markAnnouncementsAsRead = () => {
if (announcements.length > 0) {
const allKeys = announcements.map((item: Record<string, unknown>) =>
getAnnouncementKey(item)
)
@@ -143,11 +127,38 @@ export function useNotifications() {
}
}
// Handle "Close Today" action
const handleCloseToday = () => {
const today = new Date().toDateString()
setClosedUntilDate(today)
setDialogOpen(false)
// Handle popover open
const handleOpenPopover = (tab?: 'notice' | 'announcements') => {
const nextTab = tab || activeTab
// Mark currently visible content as read when opening the notification center
if (noticeContent) {
markNoticeRead(noticeContent)
}
if (nextTab === 'announcements') {
markAnnouncementsAsRead()
}
setActiveTab(nextTab)
setPopoverOpen(true)
}
const handlePopoverOpenChange = (open: boolean) => {
if (open) {
handleOpenPopover(activeTab)
return
}
setPopoverOpen(false)
}
// Handle tab change - mark announcements as read when switching to that tab
const handleTabChange = (tab: 'notice' | 'announcements') => {
setActiveTab(tab)
if (tab === 'announcements') {
markAnnouncementsAsRead()
}
}
return {
@@ -161,19 +172,15 @@ export function useNotifications() {
unreadNoticeCount: unreadCounts.notice,
unreadAnnouncementsCount: unreadCounts.announcements,
// Dialog state
dialogOpen,
setDialogOpen,
// Popover state
popoverOpen,
setPopoverOpen: handlePopoverOpenChange,
activeTab,
setActiveTab: handleTabChange,
// Actions
openDialog: handleOpenDialog,
closeDialog: () => setDialogOpen(false),
closeToday: handleCloseToday,
openPopover: handleOpenPopover,
closePopover: () => setPopoverOpen(false),
refetchNotice,
// Status
isNoticeClosed: isNoticeClosed(),
}
}