sistemato deeplinking alla serviceformscreen, aggiunto logout e sistemate altre cose
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import '../models/service_model.dart';
|
||||
|
||||
@@ -187,4 +188,28 @@ class ServicesRepository {
|
||||
]; // Fallback se non c'è ancora storia
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> uploadAttachment({
|
||||
required String serviceId,
|
||||
required String fileName,
|
||||
required Uint8List fileBytes,
|
||||
}) async {
|
||||
try {
|
||||
// 1. Upload fisico nel bucket 'service_documents'
|
||||
final path = '$serviceId/$fileName';
|
||||
await _supabase.storage
|
||||
.from('service_documents')
|
||||
.uploadBinary(path, fileBytes);
|
||||
|
||||
// 2. Registriamo l'esistenza del file nel database
|
||||
await _supabase.from('service_attachment').insert({
|
||||
'service_id': serviceId,
|
||||
'file_path': path,
|
||||
'file_name': fileName,
|
||||
'created_at': DateTime.now().toIso8601String(),
|
||||
});
|
||||
} catch (e) {
|
||||
throw "Errore upload: $e";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user