This commit is contained in:
2025-12-04 13:38:58 -05:00
parent 4a1b5bfc24
commit ab663e7d2b
7 changed files with 365 additions and 29 deletions

View File

@@ -33,6 +33,14 @@ export function initDatabase() {
)
`);
// Create settings table for custom AUEC amount
db.exec(`
CREATE TABLE IF NOT EXISTS settings (
key TEXT PRIMARY KEY,
value TEXT NOT NULL
)
`);
console.log('Database initialized at:', dbPath);
}
@@ -80,6 +88,26 @@ export function deleteAlert(id: string): void {
stmt.run(id);
}
export function getCustomAuecAmount(): number | null {
if (!db) throw new Error('Database not initialized');
const stmt = db.prepare('SELECT value FROM settings WHERE key = ?');
const row = stmt.get('customAuecAmount') as any;
return row ? parseFloat(row.value) : null;
}
export function setCustomAuecAmount(amount: number): void {
if (!db) throw new Error('Database not initialized');
const stmt = db.prepare(`
INSERT OR REPLACE INTO settings (key, value)
VALUES (?, ?)
`);
stmt.run('customAuecAmount', amount.toString());
}
export function closeDatabase(): void {
if (db) {
db.close();