-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathloading.tsx
More file actions
70 lines (66 loc) · 2.03 KB
/
loading.tsx
File metadata and controls
70 lines (66 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'use client';
import SectionWrapper from '@/components/SectionWrapper/SectionWrapper';
import { OrganizationsTableColumns } from '@/components/pages/organizations/DataTableColumns';
import { Button, DataTable, SelectWithOptions } from '@/ui-library';
import { useQueryStates } from 'nuqs';
export default function Loading() {
const [{ results, search }, setQuery] = useQueryStates({
results: {
defaultValue: 10,
parse: (value: string | undefined) => (value !== undefined ? Number(value) : 10),
},
search: {
defaultValue: '',
parse: (value: string | undefined) => (value !== undefined ? String(value) : ''),
},
});
const setSearch = (str: string) => {
setQuery({ search: str });
};
const setResults = (val: string) => {
setQuery({ results: Number(val) });
};
return (
<>
<SectionWrapper>
<h3 className="scroll-m-20 text-2xl font-semibold tracking-tight">Organizations</h3>
<Button className="px-0" variant="link">
View all organizations
</Button>
<DataTable
loading
columns={OrganizationsTableColumns}
data={[]}
searchableColumns={['name']}
onSearch={searchStr => setSearch(searchStr)}
initialSearch={String(search)}
renderFilters={table => (
<SelectWithOptions
options={[
{
label: '10 results per page',
value: 10,
},
{
label: '20 results per page',
value: 20,
},
{
label: '50 results per page',
value: 50,
},
]}
width={100}
value={String(results)}
placeholder="Results per page"
onValueChange={newVal => {
table.setPageSize(Number(newVal));
setResults(newVal);
}}
/>
)}
/>
</SectionWrapper>
</>
);
}