Files
lunarfront-app/packages/admin/src/hooks/use-pagination.ts
Ryan Moon 9400828f62 Rename Forte to LunarFront, generalize for any small business
Rebrand from Forte (music-store-specific) to LunarFront (any small business):
- Package namespace @forte/* → @lunarfront/*
- Database forte/forte_test → lunarfront/lunarfront_test
- Docker containers, volumes, connection strings
- UI branding, localStorage keys, test emails
- All documentation and planning docs

Generalize music-specific terminology:
- instrumentDescription → itemDescription
- instrumentCount → itemCount
- instrumentType → itemCategory (on service templates)
- New migration 0027_generalize_terminology for column renames
- Seed data updated with generic examples
- RBAC descriptions updated
2026-03-30 08:51:54 -05:00

44 lines
1.1 KiB
TypeScript

import { useNavigate, useSearch } from '@tanstack/react-router'
import type { PaginationInput } from '@lunarfront/shared/schemas'
interface PaginationSearch {
page?: number
limit?: number
q?: string
sort?: string
order?: 'asc' | 'desc'
}
export function usePagination() {
const search = useSearch({ strict: false }) as PaginationSearch
const navigate = useNavigate()
const params: PaginationInput = {
page: search.page ?? 1,
limit: search.limit ?? 25,
q: search.q,
sort: search.sort,
order: search.order ?? 'asc',
}
function setParams(updates: Partial<PaginationSearch>) {
navigate({
search: ((prev: PaginationSearch) => ({
...prev,
...updates,
// Reset to page 1 when search or sort changes
page: updates.q !== undefined || updates.sort !== undefined ? 1 : (updates.page ?? prev.page),
})) as any,
replace: true,
})
}
return {
...params,
setPage: (page: number) => setParams({ page }),
setSearch: (q: string) => setParams({ q: q || undefined }),
setSort: (sort: string, order: 'asc' | 'desc') => setParams({ sort, order }),
params,
}
}