Skip to content

Commit

Permalink
feat: add coffee overview
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelblijleven committed Oct 1, 2023
1 parent 342d0c5 commit 13dad12
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
20 changes: 16 additions & 4 deletions src/app/coffee/components/data-table/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,26 @@ export const columns: ColumnDef<Coffee>[] = [
{
accessorKey: "name",
cell: ({row}) => (
<Link
className={"hover:underline"}
href={`/coffee/${row.getValue("publicId")}`}>{row.getValue("name")}
</Link>
IE <Link
className={"w-[200px] inline-block whitespace-nowrap truncate overflow-ellipsis hover:underline"}
href={`/coffee/${row.getValue("publicId")}`}>{row.getValue("name")}
</Link>
),
header: "Name",
},
{
accessorKey: "roastDate",
header: "Roast date",
cell: ({row}) => (
<div className={"w-[90px]"}>{row.getValue("roastDate")}</div>
)
},
{
accessorKey: "buyDate",
header: "Buy date",
cell: ({row, cell}) => (
<div className={"w-[90px]"}>{row.getValue("buyDate")}</div>
)
},
{
accessorKey: "weight",
Expand All @@ -55,10 +61,16 @@ export const columns: ColumnDef<Coffee>[] = [
row.roaster.name
),
header: "Roaster",
cell: ({row}) => (
<div className={"w-[200px] whitespace-nowrap truncate overflow-ellipsis"}>{row.getValue("Roaster")}</div>
)
},
{
accessorFn: (row) => row.varieties.map(variety => variety.name).join(", "),
header: "Varieties",
cell: ({row}) => (
<div className={"w-[100px] whitespace-nowrap truncate overflow-ellipsis"}>{row.getValue("Varieties")}</div>
)
},
{
accessorFn: (row) => row.isArchived ? "Yes" : "No",
Expand Down
5 changes: 1 addition & 4 deletions src/app/coffee/components/data-table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ interface DataTableProps<TData, TValue> {
data: TData[],
}

export function DataTable<TData, TValue>({
columns,
data,
}: DataTableProps<TData, TValue>) {
export function DataTable<TData, TValue>({columns, data}: DataTableProps<TData, TValue>) {
const table = useReactTable({
data,
columns,
Expand Down
2 changes: 1 addition & 1 deletion src/app/coffee/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {User} from "@clerk/nextjs/api";
import {currentUser} from "@clerk/nextjs";
import {db} from "@/db";
import {beans} from "@/db/schema";
import {eq} from "drizzle-orm";
import {and, eq} from "drizzle-orm";
import {DataTable} from "@/app/coffee/components/data-table";
import Link from "next/link";
import {cn} from "@/lib/utils";
Expand Down

0 comments on commit 13dad12

Please sign in to comment.