import React from "react";
import { createRoot } from "react-dom/client";
import { CoveEmbeddedDashboard } from "@getcove/react-sdk";
// Replace with your backend call to POST /v1/auth/embed/mint-embed-token (see step 2).
// Must be called every time the user opens the dashboard — embed tokens are short-lived.
async function fetchEmbedToken(): Promise<string> {
// Your backend should exchange the partner_token + external_user_email for an embed_token
// and return it here. Do not call mint-embed-token from the browser.
throw new Error("Not implemented");
}
// On button click: fetch a fresh token, then mount into the target div
async function onScreeningTabClick() {
const embedToken = await fetchEmbedToken();
const target = document.querySelector(".cove-dashboard-embed-target");
if (target) {
const root = createRoot(target as HTMLElement);
root.render(
<CoveEmbeddedDashboard
embedToken={embedToken}
width="100%"
height={700}
onMessage={(data) => console.log("Dashboard message:", data)}
/>
);
}
}