import React, {useState, useEffect} from 'react'; import {AppPreview} from './components/AppPreview'; import {Controls} from './components/Controls'; import {Warning} from './components/Warning'; interface DomoDevData { manifest: any; width: number; height: number; userId: string; customerId: number; instance: string; } // Type for window global declare global { interface Window { __DOMO_DEV_DATA__?: DomoDevData; } } export function App() { const [devData, setDevData] = useState(null); const [isFullscreen, setIsFullscreen] = useState(false); const [hasThumbnail, setHasThumbnail] = useState(false); useEffect(() => { // Get data from window global injected by Vite plugin const data = window.__DOMO_DEV_DATA__; if (data) { setDevData(data); setIsFullscreen(data.manifest?.fullpage || false); // Check if thumbnail exists fetch('/app/thumbnail.png', {method: 'HEAD'}) .then(res => setHasThumbnail(res.ok)) .catch(() => setHasThumbnail(false)); } }, []); if (!devData) { return (
Loading Domo Dev Server...
); } const {manifest, width, height, userId, customerId, instance} = devData; // Build the iframe URL with query parameters - use /app/ prefix const url = `/app/index.html?userId=${userId}&customer=${customerId}&locale=en-US&platform=desktop`; const displayWidth = isFullscreen ? '100%' : `${width}px`; const displayHeight = isFullscreen ? '100%' : `${height}px`; const displaySize = isFullscreen ? 'FULL-WIDTH x FULL-HEIGHT' : `${width}px x ${height}px`; return (
{!hasThumbnail && ( Warning: A thumbnail is required before creating a card with this design. Place a 300x300 image named{' '} thumbnail.png in the base directory of your design. )}
); }