import { appPath } from "@agent-native/core/client/api-path"; import { useActionMutation, useActionQuery, } from "@agent-native/core/client/hooks"; import { useT } from "@agent-native/core/client/i18n"; import { IconCheck, IconLink, IconMail } from "@tabler/icons-react"; import { useEffect, useMemo, useState, type ReactNode } from "react"; import { toast } from "sonner"; import { CopyField, GeneralAccessSelect, MakePublicCard, ShareCardHeader, SharePeopleTab, copyToClipboard, useResourceVisibilityMutation, type SharesQuery, type SharesResponse, type Visibility, } from "@/components/sharing/share-ui"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { Switch } from "@/components/ui/switch"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; export interface ShareMeetingPopoverProps { meetingId: string; meetingTitle?: string; shareTranscript: boolean; transcriptReady: boolean; children: ReactNode; } export function ShareMeetingPopover({ meetingId, meetingTitle, shareTranscript, transcriptReady, children, }: ShareMeetingPopoverProps) { return ( {children} ); } function ShareMeetingContent({ meetingId, meetingTitle, shareTranscript, transcriptReady, }: { meetingId: string; meetingTitle?: string; shareTranscript: boolean; transcriptReady: boolean; }) { const t = useT(); const shareUrl = useMemo( () => `${window.location.origin}${appPath(`/share/meeting/${meetingId}`)}`, [meetingId], ); const sharesQuery = useActionQuery("list-resource-shares", { resourceType: "meeting", resourceId: meetingId, }); const data = sharesQuery.data; const canManage = data?.role === "owner" || data?.role === "admin"; const titleText = meetingTitle ? t("clipsFinalRaw.shareNamedMeeting", { title: meetingTitle }) : t("clipsFinalRaw.shareMeeting"); return ( <> {t("clipsFinalRaw.link")} {t("clipsFinalRaw.invite")} toast.error( err instanceof Error ? err.message : action === "invite" ? t("clipsFinalRaw.inviteFailed") : t("clipsFinalRaw.removePersonFailed"), ) } /> > ); } function LinkTab({ meetingId, shareUrl, sharesQuery, canManage, shareTranscript, transcriptReady, }: { meetingId: string; shareUrl: string; sharesQuery: SharesQuery; canManage: boolean; shareTranscript: boolean; transcriptReady: boolean; }) { const t = useT(); const updateMeeting = useActionMutation< unknown, { id: string; shareTranscript: boolean } >("update-meeting"); const [includeTranscript, setIncludeTranscript] = useState(shareTranscript); const { setResourceVisibility, isPending } = useResourceVisibilityMutation( "meeting", meetingId, sharesQuery, ); const data = sharesQuery.data; const visibility: Visibility = (data?.visibility as Visibility | null) ?? "private"; const isPublic = visibility === "public"; useEffect(() => { setIncludeTranscript(shareTranscript); }, [shareTranscript]); const handleTranscriptSharingChange = (next: boolean) => { const previous = includeTranscript; setIncludeTranscript(next); updateMeeting.mutate( { id: meetingId, shareTranscript: next }, { onError: (error: unknown) => { setIncludeTranscript(previous); toast.error( error instanceof Error ? error.message : t("shareMeeting.updateTranscriptSharingFailed"), ); }, }, ); }; return ( setResourceVisibility(next)} /> {t("shareMeeting.sharedContent")} {t("shareMeeting.summaryIncluded")} {t("shareMeeting.includeTranscript")} {transcriptReady ? t("shareMeeting.includeTranscriptDescription") : t("shareMeeting.transcriptUnavailable")} {!isPublic && canManage ? ( setResourceVisibility("public", { onSuccess: () => copyToClipboard(shareUrl), }) } /> ) : null} ); }
{transcriptReady ? t("shareMeeting.includeTranscriptDescription") : t("shareMeeting.transcriptUnavailable")}