Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

1.0 KB
Raw Blame
'use client';

import { useState } from 'react';
import WorkspaceTemplatePublisherCode from './WorkspaceTemplatePublisherCode';
import WorkspaceTemplatePublisherEmail from './WorkspaceTemplatePublisherEmail';

// Links the workspace to the gallery: the gallery emails a code to the address, and the
// code confirms it.
export default function WorkspaceTemplatePublisherLink({
  workspaceId,
  defaultEmail,
  onLinked,
  onCancel,
}: {
  workspaceId: number;
  defaultEmail: string;
  onLinked: () => void;
  onCancel: () => void;
}) {
  const [email, setEmail] = useState(defaultEmail);
  const [codeSent, setCodeSent] = useState(false);

  return codeSent ? (
    <WorkspaceTemplatePublisherCode
      workspaceId={workspaceId}
      email={email}
      onChangeEmail={() => setCodeSent(false)}
      onLinked={onLinked}
      onCancel={onCancel}
    />
  ) : (
    <WorkspaceTemplatePublisherEmail
      workspaceId={workspaceId}
      email={email}
      onEmailChange={setEmail}
      onSent={() => setCodeSent(true)}
      onCancel={onCancel}
    />
  );
}