import 'package:fis_jsonrpc/services/dictionary.m.dart';
import 'package:vitalapp/managers/interfaces/dictionary.dart';
import 'package:vitalapp/rpc.dart';
import 'package:vitalapp/store/store.dart';

class DictionaryManager implements IDictionaryManager {
  DictionaryManager();

  @override
  Future<List<DictionaryWithUnitDTO>?> getDictionaryNameAndUnitByKeysAsync(
      List<String> keys) async {
    var request = GetDictionaryNameAndUnitByKeysRequest(
      keys: keys,
      token: Store.user.token,
    );
    var result =
        await rpc.dictionary.getDictionaryNameAndUnitByKeysAsync(request);
    return result;
  }

  ///根据key返回单位
  @override
  String getUnitByKey(String key) {
    switch (key) {
      case 'Temperature':
        return "°C";
      case 'sugar':
        return 'mmol/l';
      case 'Pulse_Frequency':
        return 'bpm';
      case 'Spo2':
        return '%';
      case 'Height':
        return 'cm';
      case 'Weight':
        return 'kg';
      case 'Bmi':
        return 'kg/m²';
      case "HEART":
      case "Pulse_Beat":
        return 'bpm';
      case 'Sbp':
      case 'Dbp':
        return 'mmgh';
    }
    return '';
  }
}
