'use client';

import { BaseSessionLiveWrapper } from './BaseSessionLiveWrapper';
import { shareSessionAction, removeShareAction } from '@/actions/share';
import type { TeamWithMembers, Share } from '@/lib/share-utils';

interface SessionLiveWrapperProps {
  sessionId: string;
  sessionTitle: string;
  currentUserId: string;
  shares: Share[];
  isOwner: boolean;
  canEdit: boolean;
  userTeams?: TeamWithMembers[];
  children: React.ReactNode;
}

export function SessionLiveWrapper({
  sessionId,
  sessionTitle,
  currentUserId,
  shares,
  isOwner,
  canEdit,
  userTeams = [],
  children,
}: SessionLiveWrapperProps) {
  return (
    <BaseSessionLiveWrapper
      sessionId={sessionId}
      sessionTitle={sessionTitle}
      currentUserId={currentUserId}
      shares={shares}
      isOwner={isOwner}
      canEdit={canEdit}
      userTeams={userTeams}
      config={{
        apiPath: 'sessions',
        shareModal: {
          title: 'Partager la session',
          sessionSubtitle: 'Session',
          helpText: (
            <>
              <strong>Éditeur</strong> : peut modifier les items et actions
              <br />
              <strong>Lecteur</strong> : peut uniquement consulter
            </>
          ),
        },
        onShareWithEmail: (email, role) => shareSessionAction(sessionId, email, role),
        onRemoveShare: (userId) => removeShareAction(sessionId, userId),
      }}
    >
      {children}
    </BaseSessionLiveWrapper>
  );
}
