|
|
@ -5,10 +5,16 @@ import { |
|
|
|
getCoreRowModel, |
|
|
|
flexRender, |
|
|
|
} from "@tanstack/react-table"; |
|
|
|
import global from "../../../src/theme/global/global.module.scss"; |
|
|
|
import global from "/src/theme/global/global.module.scss"; |
|
|
|
import styles from "./TanStackTable.module.scss"; |
|
|
|
import { useEffect, useState } from "react"; |
|
|
|
import ReviewModal from "../reviewModal/ReviewModal"; |
|
|
|
import ArrowDropUpIcon from "@mui/icons-material/ArrowDropUp"; |
|
|
|
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown"; |
|
|
|
import HeightIcon from "@mui/icons-material/Height"; |
|
|
|
import RemoveRedEyeIcon from "@mui/icons-material/RemoveRedEye"; |
|
|
|
import { IconButton, Tooltip } from "@mui/material"; |
|
|
|
import { grey } from "@mui/material/colors"; |
|
|
|
|
|
|
|
const TanStackTable = ({ data }: any) => { |
|
|
|
const [tableData, setTableData] = useState([]); |
|
|
@ -34,8 +40,15 @@ const TanStackTable = ({ data }: any) => { |
|
|
|
const columns: any = [ |
|
|
|
{ |
|
|
|
header: ( |
|
|
|
<div onClick={() => handleSort("id")}> |
|
|
|
ID {sortOrder === "asc" ? "↑" : sortOrder === "desc" ? "↓" : ""} |
|
|
|
<div className={styles.sort} onClick={() => handleSort("id")}> |
|
|
|
ID{" "} |
|
|
|
{sortOrder === "asc" ? ( |
|
|
|
<ArrowDropUpIcon sx={{ color: grey[300] }} /> |
|
|
|
) : sortOrder === "desc" ? ( |
|
|
|
<ArrowDropDownIcon sx={{ color: grey[300] }} /> |
|
|
|
) : ( |
|
|
|
<HeightIcon sx={{ color: grey[300] }} /> |
|
|
|
)} |
|
|
|
</div> |
|
|
|
), |
|
|
|
accessorKey: "id", |
|
|
@ -47,6 +60,13 @@ const TanStackTable = ({ data }: any) => { |
|
|
|
{ |
|
|
|
header: "Description", |
|
|
|
accessorKey: "description", |
|
|
|
cell: ({ row }: any) => ( |
|
|
|
<> |
|
|
|
<Tooltip title={row.original.description}> |
|
|
|
<p className={styles.clamp_2}>{row.original.description}</p> |
|
|
|
</Tooltip> |
|
|
|
</> |
|
|
|
), |
|
|
|
}, |
|
|
|
{ |
|
|
|
header: "Category", |
|
|
@ -82,9 +102,14 @@ const TanStackTable = ({ data }: any) => { |
|
|
|
cell: ({ row }: any) => ( |
|
|
|
<> |
|
|
|
{/* {row.original.reviews.length} Reviews */} |
|
|
|
<button onClick={() => handleButtonClick(row.original)}> |
|
|
|
View Reviews ({row.original.reviews.length}) |
|
|
|
</button> |
|
|
|
<IconButton |
|
|
|
aria-label="log out" |
|
|
|
size="medium" |
|
|
|
color="primary" |
|
|
|
onClick={() => handleButtonClick(row.original)} |
|
|
|
> |
|
|
|
<RemoveRedEyeIcon fontSize="small" /> |
|
|
|
</IconButton> |
|
|
|
</> |
|
|
|
), |
|
|
|
}, |
|
|
|