Kontaktok listázási hibájának javítása, csv export

This commit is contained in:
2026-07-08 22:13:30 +02:00
parent 7cd682fe59
commit 1ab656585b
9 changed files with 262 additions and 19 deletions
+11 -4
View File
@@ -46,8 +46,8 @@ class ContactService extends GetxService {
/// A megjelenítendő lista: a Supabase-ből lehúzott kapcsolatok ELÉ
/// fűzve a még fel nem töltött (pending) helyi sorok. A pending sorokat
/// az `isPending` jelöli — a UI kis felhő-ikonnal mutatja őket.
Future<List<ContactWithState>> listMerged() async {
final pending = (await _db.listPendingContacts())
Future<List<ContactWithState>> listMerged(String projectId) async {
final pending = (await _db.listPendingContacts(projectId: projectId))
.map((m) => ContactWithState(
contact: Contact.fromMap(m),
isPending: true,
@@ -60,6 +60,7 @@ class ContactService extends GetxService {
final rows = await _client
.from('terepi_seged_contacts')
.select()
.eq('project_id', projectId)
.order('name', ascending: true);
remote = rows
.map((r) =>
@@ -101,6 +102,7 @@ class ContactService extends GetxService {
// Offline (vagy online-hiba) új rekord → outbox.
await _db.insertPendingContact({
'local_uuid': _uuid.v4(),
'project_id': c.projectId,
'name': c.name.trim(),
'address': c.address.trim(),
'phone': c.phone.trim(),
@@ -152,6 +154,7 @@ class ContactService extends GetxService {
// local_uuid mint kliens-kulcs → az ismételt próba idempotens.
await _client.from('terepi_seged_contacts').upsert({
'client_uuid': m['local_uuid'],
'project_id': m['project_id'],
'name': m['name'],
'address': m['address'],
'phone': m['phone'],
@@ -169,13 +172,15 @@ class ContactService extends GetxService {
return uploaded;
}
Future<int> pendingCount() => _db.countPendingContacts();
Future<int> pendingCount(String projectId) =>
_db.countPendingContacts(projectId: projectId);
// ═════════════════════════════════════════════════════════════════
// CSV import (változatlan a korábbihoz képest)
// ═════════════════════════════════════════════════════════════════
static Future<List<Contact>> parseCsv(File file) async {
static Future<List<Contact>> parseCsv(File file,
{required String projectId}) async {
final bytes = await file.readAsBytes();
String text;
try {
@@ -256,6 +261,7 @@ class ContactService extends GetxService {
final name = cell(r, iName);
if (name.isEmpty) continue;
contacts.add(Contact(
projectId: projectId,
name: name,
address: cell(r, iAddr),
phone: cell(r, iPhone),
@@ -285,6 +291,7 @@ class ContactService extends GetxService {
for (final c in contacts) {
await _db.insertPendingContact({
'local_uuid': _uuid.v4(),
'project_id': c.projectId,
'name': c.name.trim(),
'address': c.address.trim(),
'phone': c.phone.trim(),