Add pricing entry flow and platform admin foundations
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
import '../../../core/api/pocketbase_client.dart';
|
||||
import '../../../models/connection.dart';
|
||||
import '../../../models/tenant.dart';
|
||||
|
||||
class ClinicConnectionsRepository {
|
||||
ClinicConnectionsRepository._();
|
||||
@@ -10,10 +11,10 @@ class ClinicConnectionsRepository {
|
||||
|
||||
Future<List<Connection>> listConnections(String clinicTenantId) async {
|
||||
final result = await _pb.collection('connections').getList(
|
||||
filter: 'clinic_tenant_id = "$clinicTenantId"',
|
||||
expand: 'lab_tenant_id,clinic_tenant_id',
|
||||
perPage: 100,
|
||||
);
|
||||
filter: 'clinic_tenant_id = "$clinicTenantId"',
|
||||
expand: 'lab_tenant_id,clinic_tenant_id',
|
||||
perPage: 100,
|
||||
);
|
||||
return (result.items.map((r) => Connection.fromJson(r.toJson())).toList()
|
||||
..sort((a, b) => (b.dateCreated ?? '').compareTo(a.dateCreated ?? '')));
|
||||
}
|
||||
@@ -30,11 +31,26 @@ class ClinicConnectionsRepository {
|
||||
return Connection.fromJson(record.toJson());
|
||||
}
|
||||
|
||||
Future<List<Map<String, dynamic>>> searchLabs(String query) async {
|
||||
Future<List<Tenant>> searchLabs({
|
||||
String query = '',
|
||||
String? city,
|
||||
}) async {
|
||||
final normalizedQuery = query.trim().replaceAll('"', '\\"');
|
||||
final normalizedCity = (city ?? '').trim().replaceAll('"', '\\"');
|
||||
|
||||
final filterParts = ['kind = "lab"'];
|
||||
if (normalizedQuery.isNotEmpty) {
|
||||
filterParts.add(
|
||||
'(company_name ~ "$normalizedQuery" || city ~ "$normalizedQuery" || district ~ "$normalizedQuery")',
|
||||
);
|
||||
} else if (normalizedCity.isNotEmpty) {
|
||||
filterParts.add('city = "$normalizedCity"');
|
||||
}
|
||||
|
||||
final result = await _pb.collection('tenants').getList(
|
||||
filter: 'kind = "lab" && company_name ~ "$query"',
|
||||
perPage: 20,
|
||||
);
|
||||
return result.items.map((r) => r.toJson()).toList();
|
||||
filter: filterParts.join(' && '),
|
||||
perPage: 100,
|
||||
);
|
||||
return result.items.map((r) => Tenant.fromJson(r.toJson())).toList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user