// SLICE-2 placeholder for the signed-in surfaces (create-storefront, admin) that land in
// SLICE-3. It honestly states what's next and makes PUC-9 sign-out reachable now. No
// fabricated capability (INV-9).
import { logout } from "../api";

interface Props {
  email: string;
  created: boolean;
  onSignedOut: () => void;
}

export default function SignedIn({ email, created, onSignedOut }: Props) {
  async function signOut() {
    await logout();
    onSignedOut();
  }

  return (
    <main>
      <header>
        <strong>ecomm</strong>
        <span>{email}</span>
        <button type="button" onClick={signOut}>
          Sign out
        </button>
      </header>
      <section>
        <h1>{created ? "Welcome to ecomm" : "Welcome back"}</h1>
        <p>You're signed in as {email}.</p>
        <p>Creating your storefront arrives in the next slice. Nothing else is needed yet.</p>
      </section>
    </main>
  );
}
