Skip to content

Commit d935bfe

Browse files
committed
add dataframe table
1 parent 2bbaaf3 commit d935bfe

File tree

5 files changed

+40
-12
lines changed

5 files changed

+40
-12
lines changed

frontend/package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"axios": "^1.9.0",
2828
"class-variance-authority": "^0.7.1",
2929
"clsx": "^2.1.1",
30+
"filesize": "^10.1.6",
3031
"lucide-react": "^0.487.0",
3132
"next-themes": "^0.4.6",
3233
"react": "^18.3.1",

frontend/src/components/DataFrameTable/dataframetable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const DataFrameTable = ({ data }: DataFrameTableProps) => {
8484

8585
return (
8686
<div>
87-
<div className="rounded-md border w-200">
87+
<div className="rounded-md border grow w-full">
8888
<Table>
8989
<TableHeader>
9090
{table.getHeaderGroups().map((headerGroup) => (

frontend/src/components/ui/fileinput.tsx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as React from "react";
22

3-
import { Button } from "./button";
43
import { useUploadFile } from "@/hooks/petition/useUploadFile";
5-
import { CloudUpload } from "lucide-react";
4+
import { filesize } from "filesize";
5+
import { CloudUpload, File, X } from "lucide-react";
6+
import { Button } from "./button";
67

78
function FileInput({ ...props }: React.ComponentProps<"input">) {
89
const [file, setFile] = React.useState<File | null>(null);
@@ -13,6 +14,7 @@ function FileInput({ ...props }: React.ComponentProps<"input">) {
1314
const { id, accept } = props;
1415

1516
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
17+
console.log(event.target.files);
1618
if (event.target.files && event.target.files[0]) {
1719
setFile(event.target.files[0]);
1820
}
@@ -54,17 +56,33 @@ function FileInput({ ...props }: React.ComponentProps<"input">) {
5456
</div>
5557

5658
{file && (
57-
<Button
58-
className="mb-2 items-center justify-center w-full"
59-
onClick={handleUpload}
60-
disabled={mutation.isPending || !file}
61-
>
62-
Upload file
63-
</Button>
59+
<div>
60+
<div className="border-gray-500 border-2 p-5 mb-2 =rounded-lg flex flex-row items-center">
61+
<File />
62+
<p className="ml-4 mb-0 flex flex-col">
63+
{file.name}
64+
<sub>{filesize(file.size)}</sub>
65+
</p>
66+
<Button
67+
variant="destructive"
68+
className="flex-end ml-auto"
69+
onClick={() => setFile(null)}
70+
>
71+
<X />
72+
</Button>
73+
</div>
74+
<Button
75+
className="mb-2 items-center justify-center w-full"
76+
onClick={handleUpload}
77+
disabled={mutation.isPending || !file}
78+
>
79+
Upload file
80+
</Button>
81+
</div>
6482
)}
6583

6684
{uploadClicked && (
67-
<div className="text-center">
85+
<div className="text-center text-white">
6886
{mutation.isPending ? (
6987
<div className="rounded bg-yellow-400/50 p-2">Uploading...</div>
7088
) : (

frontend/src/routes/petition.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Ensure these sections have the printed name and address of the voter.
7474

7575
<div className="border-gray-600 border-t-2 my-5">
7676
<h3>Results</h3>
77-
<Tabs defaultValue="datatable" className="w-[400px]">
77+
<Tabs defaultValue="datatable">
7878
<TabsList>
7979
<TabsTrigger value="datatable">📊 Data Table</TabsTrigger>
8080
<TabsTrigger value="statistics">📈 Statistics</TabsTrigger>

0 commit comments

Comments
 (0)