# All files / src/app/settings page.tsx

0% Statements 0/110
0% Branches 0/1
0% Functions 0/1
0% Lines 0/110

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111

     'use client';

    import { motion } from 'framer-motion';
    import { PersistenceSettings } from '@/components/demo/PersistenceSettings';
    import { SchemaHealthCard } from '@/components/settings/SchemaHealthCard';
    import { BackendAutoConfigCard } from '@/components/settings/BackendAutoConfigCard';
    import { StorageBackendCard } from '@/components/settings/StorageBackendCard';
    import { DatabaseStatsCard } from '@/components/settings/DatabaseStatsCard';
    import { StorageInfoCard } from '@/components/settings/StorageInfoCard';
    import { DatabaseActionsCard } from '@/components/settings/DatabaseActionsCard';
    import { OpenAISettingsCard } from '@/components/settings/OpenAISettingsCard';
    import { useSettingsState } from '@/hooks/useSettingsState';
    import { PageLayout } from '../PageLayout';

    export const dynamic = 'force-dynamic'

    export default function SettingsPage() {
      const {
        stats,
        loading,
        storageBackend,
        setStorageBackend,
        flaskUrl,
        setFlaskUrl,
        flaskConnectionStatus,
        setFlaskConnectionStatus,
        testingConnection,
        envVarSet,
        schemaHealth,
        checkingSchema,
        handleExport,
        handleImport,
        handleClear,
        handleSeed,
        formatBytes,
        handleTestConnection,
        handleSaveStorageConfig,
        handleMigrateToFlask,
        handleMigrateToIndexedDB,
        checkSchemaHealth,
      } = useSettingsState();

      return (
        <PageLayout>
          <motion.div
            initial={{ opacity: 0, y: 20 }}
            animate={{ opacity: 1, y: 0 }}
            transition={{ duration: 0.4 }}
          >
            <div className="mb-8">
              <h2 className="text-3xl font-bold tracking-tight mb-2">Settings</h2>
              <p className="text-muted-foreground">Manage your database and application settings</p>
            </div>

            <div className="grid gap-6 max-w-3xl">
              <OpenAISettingsCard />

              <PersistenceSettings />

              <SchemaHealthCard
                schemaHealth={schemaHealth}
                checkingSchema={checkingSchema}
                onClear={handleClear}
                onCheckSchema={checkSchemaHealth}
              />

              <BackendAutoConfigCard
                envVarSet={envVarSet}
                flaskUrl={flaskUrl}
                flaskConnectionStatus={flaskConnectionStatus}
                testingConnection={testingConnection}
                onTestConnection={handleTestConnection}
              />

              <StorageBackendCard
                storageBackend={storageBackend}
                flaskUrl={flaskUrl}
                flaskConnectionStatus={flaskConnectionStatus}
                testingConnection={testingConnection}
                envVarSet={envVarSet}
                onStorageBackendChange={setStorageBackend}
                onFlaskUrlChange={(url) => {
                  setFlaskUrl(url);
                  setFlaskConnectionStatus('unknown');
                }}
                onTestConnection={handleTestConnection}
                onSaveConfig={handleSaveStorageConfig}
                onMigrateToFlask={handleMigrateToFlask}
                onMigrateToIndexedDB={handleMigrateToIndexedDB}
              />

              <DatabaseStatsCard
                loading={loading}
                stats={stats}
                formatBytes={formatBytes}
              />

              <StorageInfoCard storageType={stats?.storageType} />

              <DatabaseActionsCard
                onExport={handleExport}
                onImport={handleImport}
                onSeed={handleSeed}
                onClear={handleClear}
              />
            </div>
          </motion.div>
        </PageLayout>
      );
    }