// * Packages
import { CheckIcon, MailIcon, PlusIcon, XIcon } from "lucide-react";
import { route } from "ziggy-js";
import { Row } from "@tanstack/react-table";
// * Components shadcn
import { usePage } from "@inertiajs/react";
import { Badge } from "@/components/ui/badge";
// * Other
import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout";
import DataTable from "@/back/Components/Table/DataTable";
import DataTableSearch from "@/back/Components/Table/DataTableSearch";
import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton";
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
import Views from "@/back/lib/actions";
import { GetFormatedDate, GetTranslation } from "@/lib/utils";
import { AuthProp, Resource, UserModel } from "@/back/types/global";
import str from "@/hooks/use-string";
import useTrans from "@/hooks/use-translations";
const getColumns = () => {
return [
{
accessorKey: "first_name",
header: ({ column }: { column: { id: string } }) => (
),
},
{
accessorKey: "last_name",
header: ({ column }: { column: { id: string } }) => (
),
},
{
accessorKey: "email",
header: ({ column }: { column: { id: string } }) => (
),
cell: ({ row }: { row: Row }) => (
{row.getValue("email")}
),
},
{
accessorKey: "role",
header: ({ column }: { column: { id: string } }) => (
),
cell: ({ row }: { row: Row }) => {
const rowRole = row.getValue("role") as UserModel["role"];
return (
{str(String(rowRole?.label ?? '')).ucFirst().value()}
);
},
},
{
accessorKey: "published",
header: ({ column }: { column: { id: string } }) => (
),
cell: ({ row }: { row: Row }) => (
{row.getValue("published") ? (
) : (
)}
{str(
GetTranslation(
row.getValue("published")
? "uwil-backend::back.yes"
: "uwil-backend::back.no",
),
)
.ucFirst()
.value()}
),
},
{
accessorKey: "updated_at",
header: ({ column }: { column: { id: string } }) => (
),
cell: ({ row }: { row: Row }) => (
{GetFormatedDate(row.getValue("updated_at"))}
),
},
];
};
export default function Index({
userModels,
searchFields,
}: {
userModels: Resource;
searchFields: string;
}) {
const { auth } = usePage().props as unknown as {
auth: AuthProp;
};
const { create } = auth.policies.users;
const modelName = usePage().props.modelName as string;
const actionModels = [
Views.VISUALIZATION,
Views.EDITION,
Views.DUPLICATION,
Views.DELETION,
];
const columns = getColumns();
const transCrudAddEntry = useTrans("uwil-backend::back.crud_add_entry");
const afterNode = () => {
return (
create && (
}
tooltipContent={{transCrudAddEntry}
}
/>
)
);
};
return (
);
}