-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.tsx
More file actions
64 lines (59 loc) · 1.47 KB
/
Copy pathpage.tsx
File metadata and controls
64 lines (59 loc) · 1.47 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
import { Link } from 'nextjs13-progress';
import { db } from '@/lib/db';
import { DataTable } from '@/components/table/data-table';
import { buttonVariants } from '@/components/ui/button';
import { CaseColumn } from '@/types/CaseColumns';
import { columns } from './columns';
async function getData(): Promise<CaseColumn[]> {
const rawCases = await db.case.findMany({
select: {
created_at: true,
status: true,
case_id: true,
created_by: {
select: {
initials: true,
},
},
order: {
select: {
companyId: true,
enduser_name: true,
external_id: true,
order_id: true,
},
},
},
});
const parsedCases = rawCases.map(
({ created_at, created_by, order, status, case_id }) => {
return {
created_at,
status,
case_id,
initials: created_by.initials,
companyId: order.companyId,
enduser_name: order.enduser_name,
external_id: order.external_id,
order_id: order.order_id,
};
}
);
return parsedCases;
}
export default async function Page() {
const data = await getData();
return (
<div className="sm:py-10 px-1">
<DataTable
columns={columns}
data={data}
filterColumnId="order_id"
filterPlaceholder="Filter cases..."
/>
<Link href="/cases/new" className={buttonVariants()}>
Create new case
</Link>
</div>
);
}