diff --git a/text-tile/TextTileEditor.tsx b/text-tile/TextTileEditor.tsx index f89def4..b7fdf0d 100644 --- a/text-tile/TextTileEditor.tsx +++ b/text-tile/TextTileEditor.tsx @@ -20,6 +20,59 @@ export const TextTileEditor: React.FC<{ const [content, setContent] = useState(''); const [fontSize, setFontSize] = useState(); const [align, setAlign] = useState('left'); + const [isSaving, setIsSaving] = useState(false); + + useEffect(() => { + console.log('Setting default values'); + + if (config.visualisation?.config) { + setContent(config.visualisation?.config?.content || 'Sample text'); + setFontSize(config.visualisation?.config?.fontSize || 16); + setAlign(config.visualisation?.config?.align || 'left'); + } + }, []); + + const handleSave = async () => { + setIsSaving(true); + + try { + const response = await fetch('/api/text-tile/save', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + id: config.id, + content, + fontSize, + align + }) + }); + + if (response.ok) { + console.log('Saved successfully'); + onClose(); + } else { + console.error('Save failed'); + } + } catch (error) { + console.error('Network error:', error); + } finally { + setIsSaving(false); + } + }; + + const renderTextArea = () => { + return ( +
+ +