feat(dashboard): DataTable component (#6297)

This commit is contained in:
Kasper Fabricius Kristensen
2024-02-02 21:56:55 +01:00
committed by GitHub
parent a7be5d7b6d
commit 8cbf6c60fe
62 changed files with 2722 additions and 397 deletions
@@ -1,15 +1,23 @@
import { useSearchParams } from "react-router-dom"
type QueryParams<T extends string> = {
[key in T]: string | undefined
}
export function useQueryParams<T extends string>(
keys: T[]
): Record<T, string | undefined> {
keys: T[],
prefix?: string
): QueryParams<T> {
const [params] = useSearchParams()
// Use a type assertion to initialize the result
const result = {} as Record<T, string | undefined>
const result = {} as QueryParams<T>
keys.forEach((key) => {
result[key] = params.get(key) || undefined
const prefixedKey = prefix ? `${prefix}_${key}` : key
const value = params.get(prefixedKey) || undefined
result[key] = value
})
return result