import Link from "next/link";

export const carrierTable = [
  {
    accessorKey: "carrier_name",
    header: "CARRIER NAME",
    muiTableHeadCellProps: {
      sx: {
        color: "#3180F3",
        background: "#e0ecfe",
        textDecoration: "underline",
        width: "200px",
        fontSize: "12px",
      },
    },
    Cell: ({ row }: { row: any }) => {
      if (row.original.carrier_name === null) return <>N/A</>;
      if (row?.original?.carrier_name) {
        return (
          <Link
            href={`/carriers/${row?.original?.id}`}
            className="link-rate-table carrier-name"
            style={{
              textAlign: "start",
            }}
          >
            {row?.original?.carrier_name}
          </Link>
        );
      } else {
        return row.original.carrier_name;
      }
    },
  },

  {
    accessorKey: "service_state",
    header: "SERVICE STATE",
    size: 130,
    muiTableHeadCellProps: {
      sx: {
        color: "#3180F3",
        textDecoration: "underline",
        background: "#e0ecfe",
        width: "110px",
        fontSize: "12px",
      },
    },
    Cell: ({ row }: { row: any }) => {
      if (row.original.state_names === null) return <>N/A</>;
      else {
        return <p>{row.original.state_names}</p>;
      }
    },
  },

  {
    accessorKey: "market",
    header: "MARKET",
    size: 100,
    muiTableHeadCellProps: {
      sx: {
        color: "#3180F3",
        textDecoration: "underline",
        background: "#e0ecfe",
        fontSize: "12px",
      },
    },
    Cell: ({ row }: { row: any }) => {
      if (row.original.markets === null) return <>N/A</>;
      else {
        return row.original.markets;
      }
    },
  },
  {
    accessorKey: "terminal_names",
    header: "PORT/TERMINAL",
    size: 120,
    muiTableHeadCellProps: {
      sx: {
        color: "#3180F3",
        textDecoration: "underline",
        background: "#e0ecfe",
        fontSize: "12px",
      },
    },
    Cell: ({ row }: { row: any }) => {
      if (row?.original?.terminal_names === null) return <>N/A</>;
      else {
        return row?.original?.terminal_names;
      }
    },
  },
  {
    accessorKey: "size",
    header: "20/40FT",
    size: 120,
    muiTableHeadCellProps: {
      sx: {
        color: "#3180F3",
        textDecoration: "underline",
        background: "#e0ecfe",
        width: "70px",
        fontSize: "12px",
      },
    },
    Cell: ({ row }: { row: any }) => {
      if (row.original.size === null) return <>N/A</>;
      else {
        return row.original.size;
      }
    },
  },
  {
    accessorKey: "height",
    header: "53FT",
    size: 150,
    muiTableHeadCellProps: {
      sx: {
        color: "#3180F3",
        textDecoration: "underline",
        background: "#e0ecfe",
        width: "70px",
        fontSize: "12px",
      },
    },
    Cell: ({ row }: { row: any }) => {
      if (row?.original?.height) return <>{row?.original?.height}</>;
      else if (row.original.height === null) {
        return row.original.height === null;
      }
    },
  },
  {
    accessorKey: "haz",
    header: "HAZ",
    size: 200,
    muiTableHeadCellProps: {
      sx: {
        color: "#3180F3",
        textDecoration: "underline",
        background: "#e0ecfe",
        width: "70px",
        fontSize: "12px",
      },
    },
    Cell: ({ row }: { row: any }) => {
      if (row?.original.haz === null) return <>N/A</>;
      else {
        return <p className="text-center text-danger">{row?.original.haz}</p>;
      }
    },
  },
  {
    accessorKey: "bonded",
    header: "BONDED",
    size: 200,
    muiTableHeadCellProps: {
      sx: {
        color: "#3180F3",
        textDecoration: "underline",
        background: "#e0ecfe",
        width: "80px",
        fontSize: "12px",
      },
    },
    Cell: ({ row }: { row: any }) => {
      if (row?.original.bonded === null)
        return <p className="text-center">N/A</p>;
      else {
        return (
          <p className="text-center text-success">{row?.original?.bonded}</p>
        );
      }
    },
  },
  {
    accessorKey: "chassis",
    header: "CHASSIS",
    size: 200,
    muiTableHeadCellProps: {
      sx: {
        color: "#3180F3",
        textDecoration: "underline",
        background: "#e0ecfe",
        width: "80px",
        fontSize: "12px",
      },
    },
    Cell: ({ row }: { row: any }) => {
      if (row?.original?.chassis === null)
        return <p className="text-center">N/A</p>;
      else {
        return (
          <p className="text-center text-dark">{row?.original?.chassis}</p>
        );
      }
    },
  },
  {
    accessorKey: "transload",
    header: "TRANSLOAD",
    size: 200,
    muiTableHeadCellProps: {
      sx: {
        color: "#3180F3",
        textDecoration: "underline",
        background: "#e0ecfe",
        width: "100px",
        fontSize: "12px",
      },
    },
    Cell: ({ row }: { row: any }) => {
      if (row?.original?.transload === null)
        return <p className="text-center">N/A</p>;
      else {
        return <p className="text-center">{row?.original?.transload}</p>;
      }
    },
  },
  {
    accessorKey: "parking",
    header: "PARKING",
    size: 200,
    muiTableHeadCellProps: {
      sx: {
        color: "#3180F3",
        textDecoration: "underline",
        background: "#e0ecfe",
        width: "70px",
        fontSize: "12px",
      },
    },
    Cell: ({ row }: { row: any }) => {
      if (row?.original?.parking === null) return <>N/A</>;
      else {
        return (
          <p className="text-center carrier-name">{row?.original?.parking}</p>
        );
      }
    },
  },
];
