Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(proposal table): update table columns & dummy data #60

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 70 additions & 135 deletions frontend/src/components/proposalTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
TableRow,
} from "@/components/ui/table";

import { Payment, columns } from "../lib/tableColumns";
import { columns } from "../lib/tableColumns";
import { IProposal } from "@/database/proposalSchema";

interface DataTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[];
Expand Down Expand Up @@ -121,143 +122,77 @@ function DataTable<TData, TValue>({
);
}

async function getData(): Promise<Payment[]> {
async function getData(): Promise<IProposal[]> {
// Fetch data from your API here.
return [
{
id: "728ed52f",
amount: 100,
status: "pending",
email: "m@example.com",
},
{
id: "728ed52g",
amount: 110,
status: "success",
email: "doug@example.com",
},
{
id: "728ed52h",
amount: 120,
status: "failed",
email: "pug@example.com",
},
{
id: "728ed52i",
amount: 1275470,
status: "failed",
email: "rug@example.com",
},
{
id: "728ed52j",
amount: 1754385,
status: "success",
email: "jeff@example.com",
},
{
id: "728ed52k",
amount: 2345,
status: "pending",
email: "bill@example.com",
},
{
id: "728ed52l",
amount: 2385763,
status: "failed",
email: "mike@example.com",
},
{
id: "728ed52m",
amount: 0.00000000012,
status: "success",
email: "ted@example.com",
},
{
id: "728ed52n",
amount: 748383.58,
status: "failed",
email: "washington@example.com",
},
{
id: "728ed52o",
amount: 887,
status: "pending",
email: "adams@example.com",
},
{
id: "728ed52p",
amount: 1234,
status: "success",
email: "jefferson@example.com",
},
{
id: "728ed52q",
amount: 0.0098,
status: "failed",
email: "maddison@example.com",
},
{
id: "728ed52r",
amount: 101,
status: "pending",
email: "monroe@example.com",
},
{
id: "728ed52s",
amount: 1200000000000,
status: "failed",
email: "adams@example.com",
},
{
id: "728ed52t",
amount: 150,
status: "success",
email: "jacksong@example.com",
},
{
id: "728ed52u",
amount: 180,
status: "failed",
email: "van-buron@example.com",
},
{
id: "728ed52v",
amount: 122345,
status: "failed",
email: "ngl-idk-the-rest@example.com",
},
{
id: "728ed52w",
amount: 85432782345,
status: "failed",
email: "bill-clinton@example.com",
},
{
id: "728ed52x",
amount: 2092345,
status: "failed",
email: "bush@example.com",
},
{
id: "728ed52y",
amount: 12023452,
status: "success",
email: "obunga@example.com",
},
{
id: "728ed52z",
amount: 1202345,
status: "pending",
email: "donnyT@example.com",
},
{
id: "728ed53a",
amount: 1235420,
status: "success",
email: "joeyB@example.com",
},

// ...
name: "Cayucos Sanitary District",
link: "https://agenda.slocounty.ca.gov/iip/sanluisobispo/meeting/Details/1696",
date_approved: new Date("2024-01-16"),
date_closed: new Date("2024-02-04"),
review_status: "not yet under review",
flag_status: "no",
location: "City of Morro Bay",
meeting_date: new Date("2024-02-08"),
public_comment_end_date: new Date("2024-02-24"),
},
{
name: "Buffalo Management Group",
link: "https://agenda.slocounty.ca.gov/iip/sanluisobispo/meeting/Details/1696",
date_approved: new Date("2021-04-14"),
date_closed: new Date("2024-01-07"),
review_status: "under review",
flag_status: "yes",
location: "County of San Luis Obispo",
meeting_date: new Date("2024-02-07"),
public_comment_end_date: new Date("2024-03-27"),
},
{
name: "Chimney Rock Road",
link: "https://agenda.slocounty.ca.gov/iip/sanluisobispo/meeting/Details/1753",
date_approved: new Date("2022-07-18"),
date_closed: new Date("2023-12-26"),
review_status: "reviewed",
flag_status: "no",
location: "City of Paso Robles",
meeting_date: new Date("2024-02-06"),
public_comment_end_date: new Date("2024-04-21"),
},
{
name: "Christie and Cliff Cate",
link: "https://agenda.slocounty.ca.gov/iip/sanluisobispo/meeting/Details/1717",
date_approved: new Date("2023-08-25"),
date_closed: new Date("2024-01-01"),
review_status: "under review",
flag_status: "yes",
location: "City of Paso Robles",
meeting_date: new Date("2024-02-05"),
public_comment_end_date: new Date("2024-04-05"),
},
{
name: "Green Gate Farms",
link: "https://agenda.slocounty.ca.gov/iip/sanluisobispo/meeting/Details/1739",
date_approved: new Date("2018-09-15"),
date_closed: new Date("2024-02-20"),
review_status: "reviewed",
flag_status: "yes",
location: "City of San Luis Obispo",
meeting_date: new Date("2024-02-23"),
public_comment_end_date: new Date("2024-07-21"),
},
/*
{
name: "Green Gate Farms",
link: "https://agenda.slocounty.ca.gov/iip/sanluisobispo/meeting/Details/1739",
date_approved: new Date("2018-09-15").toDateString(),
date_closed: new Date("2024-02-20").toDateString(),
review_status: "reviewed",
flag_status: "yes",
location: "City of San Luis Obispo",
meeting_date: new Date("2024-02-23").toDateString(),
public_comment_end_date: new Date("2024-07-21").toDateString(),
},
*/
];
}

Expand Down
6 changes: 5 additions & 1 deletion frontend/src/database/proposalSchema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mongoose, { Schema, Types } from "mongoose";
import mongoose, { Schema } from "mongoose";

//typescript Interface
export type IProposal = {
Expand All @@ -9,6 +9,8 @@ export type IProposal = {
review_status: string;
flag_status: string;
location: string;
meeting_date: Date;
public_comment_end_date: Date;
};

//mongoose schema
Expand All @@ -20,6 +22,8 @@ export const proposalSchema = new Schema<IProposal>({
review_status: { type: String, required: true },
flag_status: { type: String, required: true },
location: { type: String, required: true },
meeting_date: { type: Date, required: false, default: new Date() },
public_comment_end_date: { type: Date, required: false, default: new Date() },
});

// defining the collection and model and creating one if doesn't exist
Expand Down
102 changes: 89 additions & 13 deletions frontend/src/lib/tableColumns.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,98 @@
"use client";

import { ColumnDef } from "@tanstack/react-table";
import { ArrowUpDown, MoreHorizontal } from "lucide-react";
import { ArrowUpDown } from "lucide-react";
import { Button } from "@/components/ui/button";
import { IProposal } from "@/database/proposalSchema";

// This type is used to define the shape of our data.
// You can use a Zod schema here if you want.
export type Payment = {
id: string;
amount: number;
status: "pending" | "processing" | "success" | "failed";
email: string;
};

export const columns: ColumnDef<Payment>[] = [
export const columns: ColumnDef<IProposal>[] = [
{
accessorKey: "name",
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
Name
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
},
{
accessorKey: "link",
header: "Link",
},
{
accessorKey: "date_approved",
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
Date Approved
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
},
{
accessorKey: "status",
header: "Status",
accessorKey: "date_closed",
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
Date Closed
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
},
{
accessorKey: "review_status",
header: "Review Status",
},
{
accessorKey: "flag_status",
header: "Flag Status",
},
{
accessorKey: "location",
header: "Location",
},
{
accessorKey: "meeting_date",
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
Date Public Meeting Held
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
},
{
accessorKey: "public_comment_end_date",
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
Date Public Comment Ends
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
},
/*
{
accessorKey: "email",
header: ({ column }) => {
Expand Down Expand Up @@ -46,4 +121,5 @@ export const columns: ColumnDef<Payment>[] = [
);
},
},
*/
];
Loading