Skip to content

Commit

Permalink
Enhance organizations dashboard with new components and styling impro…
Browse files Browse the repository at this point in the history
…vements (#18)

* add data-table
  • Loading branch information
thatguyinabeanie authored Nov 12, 2024
1 parent b585af2 commit c4c7a22
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 65 deletions.
12 changes: 3 additions & 9 deletions apps/nextjs/src/app/organizations/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Metadata } from "next";

import type { Tournament } from "~/lib/api";
import OrganizationsTable from "~/components/organizations/organizations-table";
import PartneredOrganizations from "~/components/organizations/partnered-organizations";
import { getOrganizations } from "../server-actions/organizations/actions";

Expand All @@ -19,15 +20,8 @@ export default async function OrganizationsPage() {
<div className="mt-4">
<PartneredOrganizations />
</div>

<div>
<h2>TODO: Organizations Table</h2>
{orgs.map((org) => (
<div key={org.id}>
<h3>{org.name}</h3>
<p>{org.description}</p>
</div>
))}
<div className="mt-4">
<OrganizationsTable orgs={orgs} />
</div>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
"use client";

import type {
ColumnDef,
ColumnFiltersState,
SortingState,
VisibilityState,
} from "@tanstack/react-table";
import React from "react";
import {
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuTrigger,
} from "@radix-ui/react-dropdown-menu";
import * as React from "react";
import {
flexRender,
getCoreRowModel,
Expand All @@ -24,6 +19,10 @@ import { ChevronDown } from "lucide-react";

import {
Button,
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuTrigger,
Input,
Table,
TableBody,
Expand All @@ -33,10 +32,12 @@ import {
TableRow,
} from "@battle-stadium/ui";

import { columns } from "./columns";
import { data } from "./data";
interface DataTableProps<T> {
data: T[];
columns: ColumnDef<T>[];
}

export function DataTableDemo() {
export default function DataTable<T>({ data, columns }: DataTableProps<T>) {
const [sorting, setSorting] = React.useState<SortingState>([]);
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
[],
Expand Down Expand Up @@ -69,7 +70,7 @@ export function DataTableDemo() {
<div className="flex items-center py-4">
<Input
placeholder="Filter emails..."
value={table.getColumn("email")?.getFilterValue()?.toString() ?? ""}
value={table.getColumn("email")?.getFilterValue() as string}
onChange={(event) =>
table.getColumn("email")?.setFilterValue(event.target.value)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";

import type { ColumnDef } from "@tanstack/react-table";
import * as React from "react";
import { ArrowUpDown, MoreHorizontal } from "lucide-react";

import type { Organization } from "@battle-stadium/db/schema";
import {
Button,
Checkbox,
Expand All @@ -15,9 +15,17 @@ import {
DropdownMenuTrigger,
} from "@battle-stadium/ui";

import type { Payment } from "./types";
import DataTable from "~/components/data-table";

export const columns: ColumnDef<Payment>[] = [
interface OrganizationTableProps {
orgs: Organization[];
}

export default function OrganizationsTable({ orgs }: OrganizationTableProps) {
return <DataTable<Organization> data={orgs} columns={columns} />;
}

export const columns: ColumnDef<Organization>[] = [
{
id: "select",
header: ({ table }) => (
Expand Down Expand Up @@ -81,7 +89,7 @@ export const columns: ColumnDef<Payment>[] = [
id: "actions",
enableHiding: false,
cell: ({ row }) => {
const payment = row.original;
const organization = row.original;

return (
<DropdownMenu>
Expand All @@ -94,7 +102,9 @@ export const columns: ColumnDef<Payment>[] = [
<DropdownMenuContent align="end">
<DropdownMenuLabel>Actions</DropdownMenuLabel>
<DropdownMenuItem
onClick={() => navigator.clipboard.writeText(payment.id)}
onClick={() =>
navigator.clipboard.writeText(`${organization.id}`)
}
>
Copy payment ID
</DropdownMenuItem>
Expand Down

This file was deleted.

This file was deleted.

Empty file added packages/ui/src/hooks/.keep
Empty file.
Empty file added packages/ui/src/lib/.keep
Empty file.

1 comment on commit c4c7a22

@vercel
Copy link

@vercel vercel bot commented on c4c7a22 Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.