Add some features

This commit is contained in:
Kazimierz Ciołek
2026-07-07 11:32:06 +02:00
parent b584cbc8ce
commit b38aa268ef
20 changed files with 1367 additions and 319 deletions

View File

@@ -128,6 +128,26 @@ fn migrations() -> Vec<Migration> {
);
",
kind: MigrationKind::Up,
},
Migration {
version: 4,
description: "add_cleaned_flag",
sql: "
ALTER TABLE reservations ADD COLUMN cleaned INTEGER NOT NULL DEFAULT 0;
-- wyjazdy sprzed migracji uznajemy za posprzątane, żeby nie zalać widoku zaległościami
UPDATE reservations SET cleaned = 1 WHERE departure < date('now');
CREATE INDEX idx_reservations_departure ON reservations (departure);
",
kind: MigrationKind::Up,
},
Migration {
version: 5,
description: "add_prepared_flag",
sql: "
ALTER TABLE reservations ADD COLUMN prepared INTEGER NOT NULL DEFAULT 0;
UPDATE reservations SET prepared = 1 WHERE arrival < date('now');
",
kind: MigrationKind::Up,
}]
}
@@ -166,9 +186,16 @@ fn auto_backup(app: &tauri::AppHandle) -> std::io::Result<()> {
Ok(())
}
/// Zapis tekstu do pliku wskazanego przez okno "Zapisz jako" (eksport CSV).
#[tauri::command]
fn save_text_file(path: String, contents: String) -> Result<(), String> {
std::fs::write(&path, contents).map_err(|e| e.to_string())
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![save_text_file])
.setup(|app| {
if let Err(e) = auto_backup(app.handle()) {
eprintln!("Nie udało się wykonać kopii zapasowej: {e}");