import React, { useState } from 'react'; import { usePage } from '@inertiajs/react' import { useInertiaForm } from 'use-inertia-form'; import { Settings2, Save, AlertCircle, Key, Database, Globe2 } from 'lucide-react'; import { PluginSettings } from '../components/settings/PluginSettings'; interface Settings { settings: { timezone: string; s3_bucket: string; s3_region: string; s3_access_key_id: string; s3_secret_access_key: string; wandb_api_key: string; } } const TIMEZONES = [ { value: 'America/New_York', label: 'Eastern Time' }, { value: 'America/Chicago', label: 'Central Time' }, { value: 'America/Denver', label: 'Mountain Time' }, { value: 'America/Los_Angeles', label: 'Pacific Time' } ]; export default function SettingsPage({ settings: initialSettings }: { settings: Settings }) { const { rootPath } = usePage().props; const form = useInertiaForm({ settings: { timezone: initialSettings?.settings?.timezone || 'America/New_York', s3_bucket: initialSettings?.settings?.s3_bucket || '', s3_region: initialSettings?.settings?.s3_region || 'us-east-1', s3_access_key_id: initialSettings?.settings?.s3_access_key_id || '', s3_secret_access_key: initialSettings?.settings?.s3_secret_access_key || '', wandb_api_key: initialSettings?.settings?.wandb_api_key || '' } }); const { data: formData, setData: setFormData, patch, processing } = form; const [showSecretKey, setShowSecretKey] = useState(false); const [saved, setSaved] = useState(false); const [error, setError] = useState(null); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); setSaved(false); setError(null); const timeoutId = setTimeout(() => { setError('Request timed out. Please try again.'); }, 3000); patch(`${rootPath}/settings`, { onSuccess: () => { clearTimeout(timeoutId); setSaved(true); }, onError: () => { clearTimeout(timeoutId); setError('Failed to save settings. Please try again.'); } }); }; return (

Settings

{/* General Settings */}

General Settings

All dates and times will be displayed in this timezone

{/* S3 Configuration */}

S3 Configuration

setFormData({ ...formData, settings: { ...formData.settings, s3_bucket: e.target.value } })} className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500" placeholder="my-bucket" />

AWS Credentials

These credentials will be used as default for all S3 operations. You can override them per datasource.

setFormData({ ...formData, settings: { ...formData.settings, s3_access_key_id: e.target.value } })} className="mt-1 block w-full pl-9 rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500" placeholder="AKIA..." />
setFormData({ ...formData, settings: { ...formData.settings, s3_secret_access_key: e.target.value } })} className="mt-1 block w-full pl-9 pr-24 rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500" placeholder="Your secret key" />
setFormData({ ...settings })} />
{saved && (
Settings saved successfully
)} {error && (
{error}
)}
); }