Spaces:
Sleeping
Sleeping
Table and upload button ui with dummy data
Browse files- app/(home)/dashboard/page.tsx +25 -1
- app/lib/data/index.ts +75 -0
app/(home)/dashboard/page.tsx
CHANGED
@@ -1,8 +1,32 @@
|
|
1 |
'use client';
|
|
|
|
|
2 |
import React from "react";
|
|
|
|
|
|
|
3 |
const Dashboard = () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
return (
|
5 |
-
<div
|
|
|
|
|
|
|
|
|
|
|
6 |
);
|
7 |
}
|
8 |
|
|
|
1 |
'use client';
|
2 |
+
import { Button, Table, Upload, message } from "antd";
|
3 |
+
import { UploadOutlined } from '@ant-design/icons';
|
4 |
import React from "react";
|
5 |
+
import { data } from '../../lib/data';
|
6 |
+
import { UploadChangeParam, UploadFile } from "antd/es/upload";
|
7 |
+
|
8 |
const Dashboard = () => {
|
9 |
+
const transactions = data['transactions'];
|
10 |
+
|
11 |
+
const columns = Object.keys(transactions[0]).map((key: string) => ({ title: key, dataIndex: key, key: key }));
|
12 |
+
function handleUpload(info: UploadChangeParam<UploadFile<any>>) {
|
13 |
+
if (info.file.status !== 'uploading') {
|
14 |
+
console.log(info.file, info.fileList);
|
15 |
+
}
|
16 |
+
if (info.file.status === 'done') {
|
17 |
+
message.success(`${info.file.name} file uploaded successfully`);
|
18 |
+
} else if (info.file.status === 'error') {
|
19 |
+
message.error(`${info.file.name} file upload failed.`);
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
return (
|
24 |
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
|
25 |
+
<Upload onChange={handleUpload}>
|
26 |
+
<Button icon={<UploadOutlined />}>Click to Upload</Button>
|
27 |
+
</Upload>
|
28 |
+
<Table dataSource={transactions} columns={columns} />
|
29 |
+
</div>
|
30 |
);
|
31 |
}
|
32 |
|
app/lib/data/index.ts
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
export const data = {
|
3 |
+
"transactions": [
|
4 |
+
{
|
5 |
+
"transaction_date": "2021-01-01",
|
6 |
+
"category": "Food",
|
7 |
+
"name_description": "McDonalds",
|
8 |
+
"amount": 10.00,
|
9 |
+
"type": "Debit"
|
10 |
+
},
|
11 |
+
{
|
12 |
+
"transaction_date": "2021-01-02",
|
13 |
+
"category": "Transport",
|
14 |
+
"name_description": "Uber",
|
15 |
+
"amount": 15.50,
|
16 |
+
"type": "Debit"
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"transaction_date": "2021-01-03",
|
20 |
+
"category": "Entertainment",
|
21 |
+
"name_description": "Netflix",
|
22 |
+
"amount": 12.99,
|
23 |
+
"type": "Debit"
|
24 |
+
},
|
25 |
+
{
|
26 |
+
"transaction_date": "2021-01-04",
|
27 |
+
"category": "Groceries",
|
28 |
+
"name_description": "Walmart",
|
29 |
+
"amount": 45.23,
|
30 |
+
"type": "Debit"
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"transaction_date": "2021-01-05",
|
34 |
+
"category": "Utilities",
|
35 |
+
"name_description": "Electricity Bill",
|
36 |
+
"amount": 75.00,
|
37 |
+
"type": "Debit"
|
38 |
+
},
|
39 |
+
{
|
40 |
+
"transaction_date": "2021-01-06",
|
41 |
+
"category": "Income",
|
42 |
+
"name_description": "Salary",
|
43 |
+
"amount": 2000.00,
|
44 |
+
"type": "Credit"
|
45 |
+
},
|
46 |
+
{
|
47 |
+
"transaction_date": "2021-01-07",
|
48 |
+
"category": "Health",
|
49 |
+
"name_description": "Pharmacy",
|
50 |
+
"amount": 20.00,
|
51 |
+
"type": "Debit"
|
52 |
+
},
|
53 |
+
{
|
54 |
+
"transaction_date": "2021-01-08",
|
55 |
+
"category": "Entertainment",
|
56 |
+
"name_description": "Movie Theater",
|
57 |
+
"amount": 25.00,
|
58 |
+
"type": "Debit"
|
59 |
+
},
|
60 |
+
{
|
61 |
+
"transaction_date": "2021-01-09",
|
62 |
+
"category": "Transport",
|
63 |
+
"name_description": "Gas Station",
|
64 |
+
"amount": 30.00,
|
65 |
+
"type": "Debit"
|
66 |
+
},
|
67 |
+
{
|
68 |
+
"transaction_date": "2021-01-10",
|
69 |
+
"category": "Food",
|
70 |
+
"name_description": "Starbucks",
|
71 |
+
"amount": 5.75,
|
72 |
+
"type": "Debit"
|
73 |
+
}
|
74 |
+
]
|
75 |
+
}
|