"use client";

import Link from "next/link";
import { ColumnDef } from "@tanstack/react-table";


// Function to fetch user details
// async function fetchUserDetails(uuid: string): Promise<UserType> {
//   const res = await fetch(`/api/user/${uuid}`);
//   const data = await res.json();
//   return data.User;
// }

export const columns: ColumnDef<UserType>[] = [
  {
    accessorKey: "id",
    cell: ({ row }) => {
      return <p>{row.original.id}</p>;
    },
  },
  {
    accessorKey: "full_name",
    header: "Name",
    cell: ({ row }) => {
      return (
        <Link
          href={`/admin/customers/${row.original.uuid}`}
          className="text-primary"
        >
          {row.original.profile?.full_name}
        </Link>
      );
    },
  },
  {
    header: "Phone",
    cell: ({ row }) => {
      if (row.original.profile?.mobile_number !== null)
        return row.original.profile?.mobile_number;
      else return "No Number found";
    },
  },
  { id: "email", accessorKey: "email", header: "Email" },
];
