This commit is contained in:
2026-05-18 19:20:38 +02:00
parent 1ee4a3bf45
commit ecb161bc07
9 changed files with 317 additions and 105 deletions

View File

@@ -11,7 +11,7 @@ class CustomerRepository {
final String companyId = GetIt.I.get<SessionCubit>().state.company!.id!;
// Crea un nuovo cliente
Future<CustomerModel> saveCustomer(CustomerModel customer) async {
Future<CustomerModel> insertCustomer(CustomerModel customer) async {
try {
final response = await _supabase
.from('customer')
@@ -57,6 +57,23 @@ class CustomerRepository {
}
}
Future<CustomerModel> getCustomerById(String customerId) async {
try {
final response = await _supabase
.from('customer')
.select('''
*,
attachment(*)
''')
.eq('id', customerId)
.single();
return CustomerModel.fromMap(response);
} catch (e) {
throw '$e';
}
}
// Ricerca clienti per nome o telefono (fondamentale per la UX)
Future<List<CustomerModel>> searchCustomers(
String companyId,