refactor pesantissimo dei Customer Files

This commit is contained in:
2026-04-23 11:20:34 +02:00
parent ba54267b77
commit 41f6d0dd43
25 changed files with 518 additions and 157 deletions

View File

@@ -159,7 +159,10 @@ class ServicesRepository {
final String mimeType = file.extension.toLowerCase() == 'pdf'
? 'application/pdf'
: 'image/${file.extension}';
final fileToSave = file.copyWith(serviceId: newId, url: storagePath);
final fileToSave = file.copyWith(
serviceId: newId,
storagePath: storagePath,
);
// Creiamo una funzione asincrona per caricare file e scrivere nel DB
Future<void> uploadAndLink() async {
@@ -235,6 +238,15 @@ class ServicesRepository {
}
}
/// Ascolta in tempo reale i file caricati per una pratica
Stream<List<Map<String, dynamic>>> getServiceFilesStream(String serviceId) {
return _supabase
.from('service_file')
.stream(primaryKey: ['id'])
.eq('service_id', serviceId)
.order('created_at', ascending: false);
}
Future<void> copyFileToCustomer({
required ServiceFileModel file,
required String customerId,
@@ -242,7 +254,7 @@ class ServicesRepository {
CustomerFileModel fileToCopy = CustomerFileModel(
customerId: customerId,
name: file.name,
url: file.url,
storagePath: file.storagePath,
extension: file.extension,
fileSize: file.fileSize,
);