updateChanges method

Future<void> updateChanges(
  1. String documentId
)

Implementation

Future<void> updateChanges(String documentId) async {
  try {
    final updatedData = {
      'organizationName': nameController.text.trim(),
      'status': state.selectedType,
      'contactPerson': contactPersonController.text.trim(),
      'designation': state.selectedDesignation,
      'mobileNo': int.parse(mobileController.text.toString()),

      'email': emailController.text.trim(),
      'addressLine': addressController.text.trim(),
      'state': state.selectedState,
      'city': state.selectedCity,
    };

    await db.updateDocument(
      databaseId: AppConstants.appwriteDatabaseId,
      collectionId: AppConstants.userCollectionId,
      documentId: documentId,
      data: updatedData,
    );

    emit(state.copyWith(organizationDetails: state.organizationDetails));

    if (context.mounted) {}
  } catch (e) {
    print("Update error: $e");
    ScaffoldMessenger.of(
      context,
    ).showSnackBar(SnackBar(content: Text("Update failed: $e")));
  }
}