/* eslint-disable max-lines */ "use client"; import { UUID } from "crypto"; import { Fragment } from "react"; import { useTranslation } from "react-i18next"; import { ImUserPlus } from "react-icons/im"; import { MdContentPaste, MdShare } from "react-icons/md"; import { BrainUsers } from "@/lib/components/BrainUsers/BrainUsers"; import { UserToInvite } from "@/lib/components/UserToInvite"; import Button from "@/lib/components/ui/Button"; import { Modal } from "@/lib/components/ui/ModalPayment"; import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext"; import { useShareBrain } from "@/lib/hooks/useShareBrain"; import { BrainRoleType } from "../BrainUsers/types"; type ShareBrainModalProps = { brainId: UUID; }; const requiredAccessToShareBrain: BrainRoleType[] = ["Owner", "Editor"]; export const ShareBrain = ({ brainId }: ShareBrainModalProps): JSX.Element => { const { roleAssignations, brainShareLink, handleCopyInvitationLink, updateRoleAssignation, removeRoleAssignation, inviteUsers, addNewRoleAssignationRole, sendingInvitation, setIsShareModalOpen, isShareModalOpen, canAddNewRow, } = useShareBrain(brainId); const { t } = useTranslation(["translation", "brain"]); const { allBrains } = useBrainContext(); const correspondingBrain = allBrains.find((brain) => brain.id === brainId); if ( correspondingBrain === undefined || !requiredAccessToShareBrain.includes(correspondingBrain.role) ) { return ; } return ( void 0} variant={"tertiary"} data-testId="share-brain-button" > } CloseTrigger={} title={t("shareBrain", { name: correspondingBrain.name, ns: "brain" })} isOpen={isShareModalOpen} setOpen={setIsShareModalOpen} > { event.preventDefault(); void inviteUsers(); }} > {brainShareLink} void handleCopyInvitationLink()} > {roleAssignations.map((roleAssignation, index) => ( ))} {t("shareButton")} {t("shareBrainUsers", { ns: "brain" })} ); };
{brainShareLink}
{t("shareBrainUsers", { ns: "brain" })}