fix attachments with no parentId

This commit is contained in:
2026-06-08 13:17:33 +02:00
parent 6582da60d4
commit fc850795c9
2 changed files with 28 additions and 65 deletions

View File

@@ -111,69 +111,6 @@ class OperationsRepository {
}
}
// --- RECUPERO PAGINATO CON FILTRI E JOIN ---
/* Future<List<OperationModel>> fetchOperations({
required String companyId,
String? storeId,
String? staffId,
String? providerId,
required int offset,
int limit = 50,
String? searchTerm,
DateTimeRange? dateRange,
}) async {
try {
var query = _supabase
.from(Tables.operations)
.select('''
*,
${Tables.customers}(*),
${Tables.stores}(name),
${Tables.providers}(name),
${Tables.models}(name_with_brand),
${Tables.staffMembers}(name),
${Tables.attachments}(*)
''')
.eq('company_id', companyId);
// Filtro Range Date
if (dateRange != null) {
query = query
.gte('created_at', dateRange.start.toIso8601String())
.lte('created_at', dateRange.end.toIso8601String());
}
if (storeId != null) {
query = query.or('store_id.eq.$storeId,store_id.is.null');
}
if (staffId != null) {
query = query.or('staff_id.eq.$staffId,staff_id.is.null');
}
if (providerId != null) {
query = query.or('provider_id.eq.$providerId,provider_id.is.null');
}
if (searchTerm != null && searchTerm.isNotEmpty) {
// Filtra sui campi della tabella principale O su quelli della tabella joinata
query = query.or(
'reference.ilike.%$searchTerm%,note.ilike.%$searchTerm%,customer.name.ilike.%$searchTerm%',
);
}
final response = await query
.order('created_at', ascending: false)
.range(offset, offset + limit - 1);
return (response as List)
.map((map) => OperationModel.fromMap(map))
.toList();
} catch (e) {
throw Exception('$e');
}
} */
Stream<List<Map<String, dynamic>>> watchStoreOperations({
required String storeId,
required int limit,