2023-07-24 15:17:21 +03:00
|
|
|
import Link from "next/link";
|
2023-09-20 17:24:56 +03:00
|
|
|
import { useTranslation } from "react-i18next";
|
2023-07-24 15:17:21 +03:00
|
|
|
import { FaBrain } from "react-icons/fa";
|
|
|
|
|
2023-09-20 17:24:56 +03:00
|
|
|
import { Chip } from "@/lib/components/ui/Chip";
|
2023-07-24 15:17:21 +03:00
|
|
|
import { MinimalBrainForUser } from "@/lib/context/BrainProvider/types";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
|
|
|
import { useBrainListItem } from "./hooks/useBrainListItem";
|
|
|
|
|
2023-09-20 17:24:56 +03:00
|
|
|
type BrainsListItemProps = {
|
2023-07-24 15:17:21 +03:00
|
|
|
brain: MinimalBrainForUser;
|
2023-09-20 17:24:56 +03:00
|
|
|
};
|
2023-07-24 15:17:21 +03:00
|
|
|
export const BrainListItem = ({ brain }: BrainsListItemProps): JSX.Element => {
|
|
|
|
const { selected } = useBrainListItem(brain);
|
2023-09-20 17:24:56 +03:00
|
|
|
const { t } = useTranslation("brain");
|
2023-07-24 15:17:21 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={cn(
|
|
|
|
"w-full min-w-48 border-b border-black/10 dark:border-white/25 last:border-none relative group flex overflow-x-hidden hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
|
|
selected
|
|
|
|
? "bg-gray-100 dark:bg-gray-800 text-primary dark:text-white"
|
|
|
|
: ""
|
|
|
|
)}
|
|
|
|
data-testid="brains
|
|
|
|
-list-item"
|
|
|
|
>
|
|
|
|
<Link
|
|
|
|
className="flex flex-col flex-1 min-w-0 p-4"
|
|
|
|
href={`/brains-management/${brain.id}`}
|
|
|
|
key={brain.id}
|
|
|
|
>
|
2023-09-21 10:35:53 +03:00
|
|
|
<div className="flex flex-row flex-1 w-max">
|
2023-09-20 17:24:56 +03:00
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
<FaBrain className="text-xl" />
|
|
|
|
<p>{brain.name}</p>
|
|
|
|
</div>
|
|
|
|
{brain.status === "public" && (
|
|
|
|
<Chip className="ml-3">{t("public_brain_label")}</Chip>
|
|
|
|
)}
|
2023-07-24 15:17:21 +03:00
|
|
|
</div>
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
<div
|
|
|
|
aria-hidden
|
2023-09-20 17:24:56 +03:00
|
|
|
className="not-sr-only absolute left-1/2 top-0 bottom-0 right-0 bg-gradient-to-r dark:to-black pointer-events-none"
|
2023-07-24 15:17:21 +03:00
|
|
|
></div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|