import { useTranslation } from "react-i18next"; import { MdAdd } from "react-icons/md"; import Button from "@/lib/components/ui/Button"; import { Modal } from "@/lib/components/ui/Modal"; import { PublicBrain } from "@/lib/context/BrainProvider/types"; import { usePublicBrainItem } from "./hooks/usePublicBrainItem"; import { formatDate } from "./utils/formatDate"; type PublicBrainItemProps = { brain: PublicBrain; }; export const PublicBrainItem = ({ brain, }: PublicBrainItemProps): JSX.Element => { const { handleSubscribeToBrain, isUserSubscribedToBrain, subscriptionRequestPending, isSubscriptionModalOpened, setIsSubscriptionModalOpened, } = usePublicBrainItem({ brainId: brain.id, }); const { t } = useTranslation("brain"); const subscribeButton = ( ); const isBrainDescriptionEmpty = brain.description === ""; const brainDescription = isBrainDescriptionEmpty ? t("empty_brain_description") : brain.description; return ( } Trigger={

{brain.name}

{brainDescription}

{subscribeButton}
} >

{brain.name}

{brainDescription}

{t("public_brain_last_update_label")}: {formatDate(brain.last_update)}

{subscribeButton}
); };