adding missing feature table columns

This commit is contained in:
Khalim Conn-Kowlessar 2023-07-25 20:38:01 +01:00
parent 13c2fb5ac1
commit e762584a66

View file

@ -0,0 +1,50 @@
"use client";
import { Feature, GeneralFeature, Rating } from "@/app/db/schema/property";
import { Badge } from "@/app/shadcn_components/ui/badge";
import { ColumnDef } from "@tanstack/react-table";
function RatingBadge({ rating }: { rating: Rating }) {
const colourMap = {
"Very good": "bg-green-500 hover:bg-green-600",
Good: "bg-green-300 hover:bg-green-400",
Poor: "bg-yellow-300 hover:bg-yellow-400",
"Very poor": "bg-red-500 hover:bg-red-600",
"N/A": "bg-gray-500 hover:bg-gray-600",
};
const ratingConfig = colourMap[rating];
return <Badge className={ratingConfig}>{rating}</Badge>;
}
export const retrofitColumns: ColumnDef<Feature>[] = [
{
accessorKey: "feature",
header: "Feature",
},
{
accessorKey: "description",
header: "Description",
},
{
accessorKey: "rating",
header: "Rating",
cell: ({ row }) => {
return (
<div className="">
<RatingBadge rating={row.getValue("rating")} />
</div>
);
},
},
];
export const generalColumns: ColumnDef<GeneralFeature>[] = [
{
accessorKey: "feature",
header: "Feature",
},
{
accessorKey: "description",
header: "Description",
},
];