Files
edr-platform/apps/edr-freight-web/backoffice/src/user-management/components/content/ArchivedUserColumnDefn.tsx
natib21 e6e44e773b fix ui
2026-07-10 11:25:59 +00:00

86 lines
2.5 KiB
TypeScript

import { useLocalizedName } from "@/shared/common/localizedName";
import { ItemDTO, OrganizationUserDto, User } from "@/shared/dto/user/usersDto";
import { ColumnDef } from "@tanstack/react-table";
import ArchivedUserActionsCell from "./ArchivedUsers/ArchivedUserActions";
import { format } from "date-fns/format";
import { t } from "i18next";
import { Badge } from "@/shared/common/ui/badge";
export const ArchivedUserColumnDefn: ColumnDef<ItemDTO>[] = [
{
accessorKey: "name",
header: () => t("setting.Name"),
cell: ({ row }) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const localizedName = useLocalizedName();
const name = row.original?.name;
return <span>{localizedName(name)}</span>;
},
},
// {
// accessorKey: "username",
// header: "Username",
// cell: ({ row }) => {
// const username = row.original.username;
// return <span>{username}</span>;
// },
// },
// {
// accessorKey: "createdAt",
// header: "Created At",
// cell: ({ row }) => {
// const date = row.original.createdAt;
// return <span>{format(new Date(date), "MMM d, yyyy HH:mm")}</span>;
// },
// },
{
accessorKey: "status",
header: () => t("userRecord.Status"),
cell: ({ row }) => {
const status = row.original?.status;
const getStatusColor = (status: string) => {
switch (status.toLowerCase()) {
case "inactive":
return "bg-red-100 text-red-600 hover:bg-red-100"; // red for inactive
case "active":
return "bg-primary-100 text-primary-600 hover:bg-primary-100"; // green for active
default:
return "bg-gray-100 text-gray-600 hover:bg-gray-100";
}
};
const getStatusText = (status: string) => {
switch (status.toLowerCase()) {
case "inactive":
return "InActive";
case "active":
return "Active";
default:
return "Not Available";
}
};
return (
<div>
<Badge
className={`${getStatusColor(
status
)} rounded-full px-6 py-1 font-medium`}>
{getStatusText(status)}
</Badge>
</div>
);
},
},
{
id: "actions",
header: () => t("userRecord.Actions"),
cell: ({ row }) => <ArchivedUserActionsCell row={row.original} />,
},
];