{"ast":null,"code":"import React,{useState}from'react';import{FiSave,FiRefreshCw,FiDownload,FiUpload}from'react-icons/fi';import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";const Settings=()=>{// General settings\nconst[siteName,setSiteName]=useState('SolarBank IoT Dashboard');const[timezone,setTimezone]=useState('Europe/Zurich');const[dateFormat,setDateFormat]=useState('DD/MM/YYYY HH:mm:ss');// Map settings\nconst[mapboxToken,setMapboxToken]=useState('');const[defaultLatitude,setDefaultLatitude]=useState(47.3769);const[defaultLongitude,setDefaultLongitude]=useState(8.5417);const[defaultZoom,setDefaultZoom]=useState(13);// Notification settings\nconst[emailNotifications,setEmailNotifications]=useState(false);const[emailAddress,setEmailAddress]=useState('');const[lowBatteryThreshold,setLowBatteryThreshold]=useState(30);const[criticalBatteryThreshold,setCriticalBatteryThreshold]=useState(15);const[offlineAlertTimeout,setOfflineAlertTimeout]=useState(24);// API settings\nconst[apiRefreshInterval,setApiRefreshInterval]=useState(60);// State for form submission\nconst[saving,setSaving]=useState(false);const[saveSuccess,setSaveSuccess]=useState(false);const handleSaveSettings=e=>{e.preventDefault();setSaving(true);// Simulate API call to save settings\nsetTimeout(()=>{setSaving(false);setSaveSuccess(true);// Reset success message after 3 seconds\nsetTimeout(()=>{setSaveSuccess(false);},3000);},1000);};const handleBackupSettings=()=>{// In a real app, this would generate a JSON file with all settings\nconst settings={general:{siteName,timezone,dateFormat},map:{mapboxToken,defaultLatitude,defaultLongitude,defaultZoom},notifications:{emailNotifications,emailAddress,lowBatteryThreshold,criticalBatteryThreshold,offlineAlertTimeout},api:{apiRefreshInterval}};// Create a blob and download it\nconst blob=new Blob([JSON.stringify(settings,null,2)],{type:'application/json'});const url=URL.createObjectURL(blob);const a=document.createElement('a');a.href=url;a.download='solarbank-settings.json';document.body.appendChild(a);a.click();document.body.removeChild(a);URL.revokeObjectURL(url);};const handleRestoreSettings=e=>{// This would be implemented with a file input and parser\nalert('Restore settings functionality would be implemented here');};return/*#__PURE__*/_jsxs(\"div\",{className:\"space-y-6\",children:[/*#__PURE__*/_jsxs(\"div\",{className:\"flex justify-between items-center\",children:[/*#__PURE__*/_jsx(\"h1\",{className:\"text-2xl font-semibold text-gray-800\",children:\"Settings\"}),/*#__PURE__*/_jsxs(\"div\",{className:\"flex space-x-2\",children:[/*#__PURE__*/_jsxs(\"button\",{className:\"flex items-center gap-2 px-4 py-2 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors\",onClick:handleBackupSettings,children:[/*#__PURE__*/_jsx(FiDownload,{}),/*#__PURE__*/_jsx(\"span\",{children:\"Backup\"})]}),/*#__PURE__*/_jsxs(\"button\",{className:\"flex items-center gap-2 px-4 py-2 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors\",onClick:handleRestoreSettings,children:[/*#__PURE__*/_jsx(FiUpload,{}),/*#__PURE__*/_jsx(\"span\",{children:\"Restore\"})]})]})]}),saveSuccess&&/*#__PURE__*/_jsx(\"div\",{className:\"bg-success-100 border border-success-200 text-success-700 px-4 py-3 rounded relative\",role:\"alert\",children:/*#__PURE__*/_jsx(\"span\",{className:\"block sm:inline\",children:\"Settings saved successfully!\"})}),/*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSaveSettings,children:[/*#__PURE__*/_jsxs(\"div\",{className:\"dashboard-card mb-6\",children:[/*#__PURE__*/_jsx(\"h2\",{className:\"text-lg font-semibold text-gray-800 mb-4\",children:\"General Settings\"}),/*#__PURE__*/_jsxs(\"div\",{className:\"grid grid-cols-1 md:grid-cols-2 gap-4\",children:[/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"siteName\",className:\"block text-sm font-medium text-gray-700 mb-1\",children:\"Site Name\"}),/*#__PURE__*/_jsx(\"input\",{type:\"text\",id:\"siteName\",className:\"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm\",value:siteName,onChange:e=>setSiteName(e.target.value)})]}),/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"timezone\",className:\"block text-sm font-medium text-gray-700 mb-1\",children:\"Timezone\"}),/*#__PURE__*/_jsxs(\"select\",{id:\"timezone\",className:\"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm\",value:timezone,onChange:e=>setTimezone(e.target.value),children:[/*#__PURE__*/_jsx(\"option\",{value:\"Europe/Zurich\",children:\"Europe/Zurich\"}),/*#__PURE__*/_jsx(\"option\",{value:\"Europe/London\",children:\"Europe/London\"}),/*#__PURE__*/_jsx(\"option\",{value:\"America/New_York\",children:\"America/New_York\"}),/*#__PURE__*/_jsx(\"option\",{value:\"America/Los_Angeles\",children:\"America/Los_Angeles\"}),/*#__PURE__*/_jsx(\"option\",{value:\"Asia/Tokyo\",children:\"Asia/Tokyo\"}),/*#__PURE__*/_jsx(\"option\",{value:\"Australia/Sydney\",children:\"Australia/Sydney\"})]})]}),/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"dateFormat\",className:\"block text-sm font-medium text-gray-700 mb-1\",children:\"Date Format\"}),/*#__PURE__*/_jsxs(\"select\",{id:\"dateFormat\",className:\"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm\",value:dateFormat,onChange:e=>setDateFormat(e.target.value),children:[/*#__PURE__*/_jsx(\"option\",{value:\"DD/MM/YYYY HH:mm:ss\",children:\"DD/MM/YYYY HH:mm:ss\"}),/*#__PURE__*/_jsx(\"option\",{value:\"MM/DD/YYYY HH:mm:ss\",children:\"MM/DD/YYYY HH:mm:ss\"}),/*#__PURE__*/_jsx(\"option\",{value:\"YYYY-MM-DD HH:mm:ss\",children:\"YYYY-MM-DD HH:mm:ss\"}),/*#__PURE__*/_jsx(\"option\",{value:\"DD.MM.YYYY HH:mm:ss\",children:\"DD.MM.YYYY HH:mm:ss\"})]})]}),/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"apiRefreshInterval\",className:\"block text-sm font-medium text-gray-700 mb-1\",children:\"Dashboard Refresh Interval (seconds)\"}),/*#__PURE__*/_jsx(\"input\",{type:\"number\",id:\"apiRefreshInterval\",className:\"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm\",value:apiRefreshInterval,onChange:e=>setApiRefreshInterval(parseInt(e.target.value)),min:\"10\",max:\"3600\"})]})]})]}),/*#__PURE__*/_jsxs(\"div\",{className:\"dashboard-card mb-6\",children:[/*#__PURE__*/_jsx(\"h2\",{className:\"text-lg font-semibold text-gray-800 mb-4\",children:\"Map Settings\"}),/*#__PURE__*/_jsxs(\"div\",{className:\"grid grid-cols-1 md:grid-cols-2 gap-4\",children:[/*#__PURE__*/_jsxs(\"div\",{className:\"md:col-span-2\",children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"mapboxToken\",className:\"block text-sm font-medium text-gray-700 mb-1\",children:\"Mapbox Access Token\"}),/*#__PURE__*/_jsx(\"input\",{type:\"text\",id:\"mapboxToken\",className:\"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm\",value:mapboxToken,onChange:e=>setMapboxToken(e.target.value),placeholder:\"Enter your Mapbox access token\"}),/*#__PURE__*/_jsxs(\"p\",{className:\"mt-1 text-xs text-gray-500\",children:[\"Leave empty to use OpenStreetMap. Get a token at \",/*#__PURE__*/_jsx(\"a\",{href:\"https://www.mapbox.com/\",className:\"text-primary-600 hover:text-primary-700\",target:\"_blank\",rel:\"noopener noreferrer\",children:\"mapbox.com\"})]})]}),/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"defaultLatitude\",className:\"block text-sm font-medium text-gray-700 mb-1\",children:\"Default Latitude\"}),/*#__PURE__*/_jsx(\"input\",{type:\"number\",id:\"defaultLatitude\",className:\"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm\",value:defaultLatitude,onChange:e=>setDefaultLatitude(parseFloat(e.target.value)),step:\"0.000001\"})]}),/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"defaultLongitude\",className:\"block text-sm font-medium text-gray-700 mb-1\",children:\"Default Longitude\"}),/*#__PURE__*/_jsx(\"input\",{type:\"number\",id:\"defaultLongitude\",className:\"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm\",value:defaultLongitude,onChange:e=>setDefaultLongitude(parseFloat(e.target.value)),step:\"0.000001\"})]}),/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"defaultZoom\",className:\"block text-sm font-medium text-gray-700 mb-1\",children:\"Default Zoom Level\"}),/*#__PURE__*/_jsx(\"input\",{type:\"number\",id:\"defaultZoom\",className:\"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm\",value:defaultZoom,onChange:e=>setDefaultZoom(parseInt(e.target.value)),min:\"1\",max:\"18\"})]})]})]}),/*#__PURE__*/_jsxs(\"div\",{className:\"dashboard-card mb-6\",children:[/*#__PURE__*/_jsx(\"h2\",{className:\"text-lg font-semibold text-gray-800 mb-4\",children:\"Notification Settings\"}),/*#__PURE__*/_jsxs(\"div\",{className:\"grid grid-cols-1 md:grid-cols-2 gap-4\",children:[/*#__PURE__*/_jsx(\"div\",{className:\"md:col-span-2\",children:/*#__PURE__*/_jsxs(\"div\",{className:\"flex items-center\",children:[/*#__PURE__*/_jsx(\"input\",{type:\"checkbox\",id:\"emailNotifications\",className:\"h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded\",checked:emailNotifications,onChange:e=>setEmailNotifications(e.target.checked)}),/*#__PURE__*/_jsx(\"label\",{htmlFor:\"emailNotifications\",className:\"ml-2 block text-sm text-gray-700\",children:\"Enable Email Notifications\"})]})}),emailNotifications&&/*#__PURE__*/_jsxs(\"div\",{className:\"md:col-span-2\",children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"emailAddress\",className:\"block text-sm font-medium text-gray-700 mb-1\",children:\"Email Address\"}),/*#__PURE__*/_jsx(\"input\",{type:\"email\",id:\"emailAddress\",className:\"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm\",value:emailAddress,onChange:e=>setEmailAddress(e.target.value),placeholder:\"Enter email address for notifications\"})]}),/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"lowBatteryThreshold\",className:\"block text-sm font-medium text-gray-700 mb-1\",children:\"Low Battery Threshold (%)\"}),/*#__PURE__*/_jsx(\"input\",{type:\"number\",id:\"lowBatteryThreshold\",className:\"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm\",value:lowBatteryThreshold,onChange:e=>setLowBatteryThreshold(parseInt(e.target.value)),min:\"0\",max:\"100\"})]}),/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"criticalBatteryThreshold\",className:\"block text-sm font-medium text-gray-700 mb-1\",children:\"Critical Battery Threshold (%)\"}),/*#__PURE__*/_jsx(\"input\",{type:\"number\",id:\"criticalBatteryThreshold\",className:\"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm\",value:criticalBatteryThreshold,onChange:e=>setCriticalBatteryThreshold(parseInt(e.target.value)),min:\"0\",max:\"100\"})]}),/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"offlineAlertTimeout\",className:\"block text-sm font-medium text-gray-700 mb-1\",children:\"Offline Alert Timeout (hours)\"}),/*#__PURE__*/_jsx(\"input\",{type:\"number\",id:\"offlineAlertTimeout\",className:\"block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm\",value:offlineAlertTimeout,onChange:e=>setOfflineAlertTimeout(parseInt(e.target.value)),min:\"1\",max:\"72\"})]})]})]}),/*#__PURE__*/_jsx(\"div\",{className:\"flex justify-end\",children:/*#__PURE__*/_jsxs(\"button\",{type:\"submit\",className:`flex items-center gap-2 px-4 py-2 bg-primary-500 text-white rounded-md hover:bg-primary-600 transition-colors ${saving?'opacity-50 cursor-not-allowed':''}`,disabled:saving,children:[saving?/*#__PURE__*/_jsx(FiRefreshCw,{className:\"animate-spin\"}):/*#__PURE__*/_jsx(FiSave,{}),/*#__PURE__*/_jsx(\"span\",{children:saving?'Saving...':'Save Settings'})]})})]})]});};export default Settings;","map":{"version":3,"names":["React","useState","FiSave","FiRefreshCw","FiDownload","FiUpload","jsx","_jsx","jsxs","_jsxs","Settings","siteName","setSiteName","timezone","setTimezone","dateFormat","setDateFormat","mapboxToken","setMapboxToken","defaultLatitude","setDefaultLatitude","defaultLongitude","setDefaultLongitude","defaultZoom","setDefaultZoom","emailNotifications","setEmailNotifications","emailAddress","setEmailAddress","lowBatteryThreshold","setLowBatteryThreshold","criticalBatteryThreshold","setCriticalBatteryThreshold","offlineAlertTimeout","setOfflineAlertTimeout","apiRefreshInterval","setApiRefreshInterval","saving","setSaving","saveSuccess","setSaveSuccess","handleSaveSettings","e","preventDefault","setTimeout","handleBackupSettings","settings","general","map","notifications","api","blob","Blob","JSON","stringify","type","url","URL","createObjectURL","a","document","createElement","href","download","body","appendChild","click","removeChild","revokeObjectURL","handleRestoreSettings","alert","className","children","onClick","role","onSubmit","htmlFor","id","value","onChange","target","parseInt","min","max","placeholder","rel","parseFloat","step","checked","disabled"],"sources":["/home/m3mo/Desktop/temparea/solarbank/frontend/src/pages/Settings.js"],"sourcesContent":["import React, { useState } from 'react';\nimport { FiSave, FiRefreshCw, FiDownload, FiUpload } from 'react-icons/fi';\n\nconst Settings = () => {\n // General settings\n const [siteName, setSiteName] = useState('SolarBank IoT Dashboard');\n const [timezone, setTimezone] = useState('Europe/Zurich');\n const [dateFormat, setDateFormat] = useState('DD/MM/YYYY HH:mm:ss');\n \n // Map settings\n const [mapboxToken, setMapboxToken] = useState('');\n const [defaultLatitude, setDefaultLatitude] = useState(47.3769);\n const [defaultLongitude, setDefaultLongitude] = useState(8.5417);\n const [defaultZoom, setDefaultZoom] = useState(13);\n \n // Notification settings\n const [emailNotifications, setEmailNotifications] = useState(false);\n const [emailAddress, setEmailAddress] = useState('');\n const [lowBatteryThreshold, setLowBatteryThreshold] = useState(30);\n const [criticalBatteryThreshold, setCriticalBatteryThreshold] = useState(15);\n const [offlineAlertTimeout, setOfflineAlertTimeout] = useState(24);\n \n // API settings\n const [apiRefreshInterval, setApiRefreshInterval] = useState(60);\n \n // State for form submission\n const [saving, setSaving] = useState(false);\n const [saveSuccess, setSaveSuccess] = useState(false);\n \n const handleSaveSettings = (e) => {\n e.preventDefault();\n setSaving(true);\n \n // Simulate API call to save settings\n setTimeout(() => {\n setSaving(false);\n setSaveSuccess(true);\n \n // Reset success message after 3 seconds\n setTimeout(() => {\n setSaveSuccess(false);\n }, 3000);\n }, 1000);\n };\n \n const handleBackupSettings = () => {\n // In a real app, this would generate a JSON file with all settings\n const settings = {\n general: {\n siteName,\n timezone,\n dateFormat\n },\n map: {\n mapboxToken,\n defaultLatitude,\n defaultLongitude,\n defaultZoom\n },\n notifications: {\n emailNotifications,\n emailAddress,\n lowBatteryThreshold,\n criticalBatteryThreshold,\n offlineAlertTimeout\n },\n api: {\n apiRefreshInterval\n }\n };\n \n // Create a blob and download it\n const blob = new Blob([JSON.stringify(settings, null, 2)], { type: 'application/json' });\n const url = URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.href = url;\n a.download = 'solarbank-settings.json';\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n URL.revokeObjectURL(url);\n };\n \n const handleRestoreSettings = (e) => {\n // This would be implemented with a file input and parser\n alert('Restore settings functionality would be implemented here');\n };\n\n return (\n