import 'dart:convert';

import 'package:fis_jsonrpc/rpc.dart';
import 'package:get/get.dart';
import 'package:vnoteapp/architecture/defines.dart';

import 'state.dart';

class PackageInfoController extends FControllerBase {
  final state = PackageInfoState();
  String servicePackString = '';
  @override
  void onInit() {
    final p = Get.parameters;
    servicePackString = p["servicePack"]!;

    state.servicePack = ServicePackDTO.fromJson(jsonDecode(servicePackString));
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
    _loadData();
  }

  Future<void> _loadData() async {}
  String getServiceItemsName(List<String> serviceItems) {
    List<String> serviceItemNames = [];
    for (var element in state.serviceItems) {
      if (serviceItems.contains(element.code)) {
        serviceItemNames.add(element.name ?? '');
      }
    }
    if (serviceItemNames.isEmpty) {
      return '暂无';
    }
    return serviceItemNames.join('、');
  }
}
