"use client" import { useState } from "react" import { Loader2 } from "lucide-react" import { extractGoogleDocId, getGoogleEmbedUrl } from "@/lib/url-helpers" interface GoogleDocViewerProps { url: string | null | undefined customId: string | null | undefined type: "google_doc" | "google_sheet" | "google_slide" } export function GoogleDocViewer({ url, customId, type }: GoogleDocViewerProps) { const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const docId = customId ?? (url ? extractGoogleDocId(url) : null) if (!docId) { return (
Unable to load document - no document ID found
) } const embedUrl = getGoogleEmbedUrl(docId, type) const typeLabels = { google_doc: "Google Doc", google_sheet: "Google Sheet", google_slide: "Google Slides", } return (
{loading && (
Loading {typeLabels[type]}...
)} {error && (
{error}
)}