refactor: migrate tickets and users pages to use new dashboard list components
- Refactored TicketsPage to utilize DashboardListPage for improved filtering and data fetching. - Removed unnecessary state management and loading logic in favor of the new list hooks. - Updated user management page to leverage useDashboardPagedList for cleaner pagination and filtering. - Enhanced CRUD page to support new action state management and toolbar customization. - Added reset filters functionality to dashboard list components. - Updated translations for new UI elements and loading states.
This commit is contained in:
@@ -54,6 +54,7 @@ export type DashboardListRenderContext<TItem> = {
|
||||
result: DashboardCrudPageResult<TItem>
|
||||
loading: boolean
|
||||
reload: () => Promise<void>
|
||||
resetFilters: () => void
|
||||
}
|
||||
|
||||
export type DashboardListPageProps<TItem> = {
|
||||
@@ -104,6 +105,7 @@ export function DashboardListPage<TItem>({
|
||||
result: list.result,
|
||||
loading: list.loading,
|
||||
reload: list.loadData,
|
||||
resetFilters: list.resetFilters,
|
||||
}
|
||||
|
||||
function handleFilterKeyDown(event: KeyboardEvent<HTMLInputElement>) {
|
||||
|
||||
@@ -6,4 +6,7 @@ export type {
|
||||
DashboardListPageProps,
|
||||
DashboardListRenderContext,
|
||||
} from "./dashboard-list-page"
|
||||
export type { DashboardPagedListOptions } from "./use-dashboard-paged-list"
|
||||
export type {
|
||||
DashboardPagedListFilter,
|
||||
DashboardPagedListOptions,
|
||||
} from "./use-dashboard-paged-list"
|
||||
|
||||
@@ -39,7 +39,14 @@ export function useDashboardPagedList<TItem>({
|
||||
`${filter.name}:${String(filter.defaultValue)}:${String(filter.allValue)}:${filter.trim ? "1" : "0"}:${filter.valueType ?? ""}`
|
||||
)
|
||||
.join("|")
|
||||
const { draftFilters, appliedFilters, setDraftFilter, applyFilter, applyFilters } =
|
||||
const {
|
||||
draftFilters,
|
||||
appliedFilters,
|
||||
setDraftFilter,
|
||||
applyFilter,
|
||||
applyFilters,
|
||||
resetFilters,
|
||||
} =
|
||||
useDashboardCrudFilters(filters)
|
||||
const [page, setPage] = useState(1)
|
||||
const [limit, setLimit] = useState(pageSize)
|
||||
@@ -100,6 +107,11 @@ export function useDashboardPagedList<TItem>({
|
||||
setPage(1)
|
||||
}
|
||||
|
||||
function resetDraftFilters() {
|
||||
resetFilters()
|
||||
setPage(1)
|
||||
}
|
||||
|
||||
return {
|
||||
draftFilters,
|
||||
setDraftFilter,
|
||||
@@ -115,5 +127,6 @@ export function useDashboardPagedList<TItem>({
|
||||
loadData,
|
||||
handlePageChange,
|
||||
handleLimitChange,
|
||||
resetFilters: resetDraftFilters,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user