import { useCallback, useState } from 'react'; import ISetupPageProps from './ISetupPageProps'; import { Card, CardHeader, CardTitle, CardDescription, CardContent, Text, Badge, Stack, Separator, Box, Button, } from '@jtl-software/platform-ui-react'; import { Settings } from 'lucide-react'; const howItWorks = [ { step: '1', text: 'The platform loads this page via ', code: 'lifecycle.configurationUrl', suffix: ' in your manifest' }, { step: '2', text: 'The app completes the bridge handshake with the platform (see ', code: 'createAppBridge', suffix: ' in main.tsx)' }, { step: '3', text: 'Call ', code: "appBridge.method.call('setupCompleted')", suffix: ' to finish installation' }, ]; const SetupPage: React.FC = ({ appBridge }) => { const [isLoading, setIsLoading] = useState(false); const [isComplete, setIsComplete] = useState(false); const [error, setError] = useState(null); const handleSetupCompleted = useCallback(async (): Promise => { try { setIsLoading(true); setError(null); // The platform waits for this to mark the install configured. await appBridge.method.call('setupCompleted'); setIsComplete(true); } catch (err) { console.error('An error occurred during setup:', err); setError(String(err)); } finally { setIsLoading(false); } }, [appBridge]); return ( App Setup This page is shown during app installation. Complete the setup to connect your app to the platform. HOW IT WORKS {howItWorks.map(item => ( {item.text} {item.code} {item.suffix} ))} TRY IT