// Shared URL state for the record view. // // Table sort/page/search/filters used to live in component state, so a refresh // or a shared link lost the user's view entirely. These parsers put it in the // query string instead, which also lets the dashboard tiles act as filters — // a tile writes `status`, the table reads it. import { parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringLiteral, } from "nuqs"; export const DENSITIES = ["compact", "regular", "relaxed"] as const; export type Density = (typeof DENSITIES)[number]; /** Row heights per density — the 40/48/56px convention. */ export const DENSITY_ROW: Record = { compact: "h-10", regular: "h-12", relaxed: "h-14", }; export const DENSITY_CELL: Record = { compact: "py-1.5", regular: "py-3", relaxed: "py-4", }; export const tableParams = { q: parseAsString.withDefault(""), page: parseAsInteger.withDefault(1), limit: parseAsInteger.withDefault(10), sort: parseAsString.withDefault(""), dir: parseAsStringLiteral(["asc", "desc"] as const).withDefault("desc"), /** Workflow state names, matching `current_state_name`. */ status: parseAsArrayOf(parseAsString).withDefault([]), density: parseAsStringLiteral(DENSITIES).withDefault("regular"), }; /** * Keep the URL short: nuqs omits any value equal to its default, and history * is replaced rather than pushed so filtering doesn't fill the back button. */ export const tableParamsOptions = { history: "replace" as const, clearOnDefault: true, shallow: true, };