showPoinValue method

dynamic showPoinValue()

Implementation

showPoinValue() async {
  final response = await paymentService.showPoinValue();
  response.fold(
    (failure) {
      onError?.call(failure.message);
      pointErrorMsg = "Gagal mendapatkan harga point. Hubungi pusat bantuan";
      canUsePoint = false;
    },
    (result) {
      LoyaltySummary? summary = result.loyaltySummary.firstWhereOrNull(
        (element) =>
            element.exchangePoints.currency.toUpperCase().contains("IDR"),
      );
      if (summary != null) {
        pointValue = summary.exchangePoints.pointValue;
        canUsePoint = true;
      }
    },
  );

  if (canUsePoint) {
    await getDefaultPointEligible();
  }
}