sembra funzionare tutto

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-26 10:13:58 +02:00
parent de431b6ee6
commit 69f935b755
13 changed files with 740 additions and 208 deletions

View File

@@ -335,4 +335,25 @@ class ServicesRepository {
);
await _customerRepository.saveFileReference(fileToCopy);
}
Future<void> deleteServiceFiles(List<ServiceFileModel> files) async {
if (files.isEmpty) return;
// 1. Prepariamo le liste di ID e di Percorsi
final List<String> idsToDelete = files.map((f) => f.id!).toList();
final List<String> storagePaths = files.map((f) => f.storagePath).toList();
try {
await _supabase.from('service_file').delete().inFilter('id', idsToDelete);
await _supabase.storage.from('documents').remove(storagePaths);
debugPrint("Eliminati con successo ${files.length} file.");
} on PostgrestException catch (e) {
debugPrint("Errore DB: ${e.message}");
throw 'Errore database: ${e.message}';
} catch (e) {
debugPrint("Errore generico: $e");
throw 'Errore durante l\'eliminazione dei file: $e';
}
}
}