WT 1.1.18+4 A/B Test sales page
This commit is contained in:
@@ -14,9 +14,9 @@ import 'package:aitrainer_app/model/faq.dart';
|
||||
import 'package:aitrainer_app/model/model_change.dart';
|
||||
import 'package:aitrainer_app/model/product.dart' as wt_product;
|
||||
import 'package:aitrainer_app/model/product.dart';
|
||||
import 'package:aitrainer_app/model/product_test.dart';
|
||||
import 'package:aitrainer_app/model/property.dart';
|
||||
import 'package:aitrainer_app/model/purchase.dart';
|
||||
import 'package:aitrainer_app/model/split_test.dart';
|
||||
import 'package:aitrainer_app/model/sport.dart';
|
||||
import 'package:aitrainer_app/model/training_plan.dart';
|
||||
import 'package:aitrainer_app/model/tutorial.dart';
|
||||
@@ -136,7 +136,8 @@ class Cache with Logging {
|
||||
List<Sport>? _sports;
|
||||
List<wt_product.Product>? _products;
|
||||
List<Purchase> _purchases = [];
|
||||
List<ProductTest>? _productTests;
|
||||
List<SplitTest> _splitTests = [];
|
||||
|
||||
List<ExercisePlanTemplate> _exercisePlanTemplates = [];
|
||||
|
||||
ExercisePlan? activeExercisePlan;
|
||||
@@ -242,7 +243,7 @@ class Cache with Logging {
|
||||
Map<String, dynamic> map;
|
||||
try {
|
||||
map = JsonDecoder().convert(savedTrainingPlanJson);
|
||||
print("Training plan: $savedTrainingPlanJson");
|
||||
//print("Training plan: $savedTrainingPlanJson");
|
||||
this.myTrainingPlan = CustomerTrainingPlan.fromJsonWithDetails(map);
|
||||
} on Exception catch (e) {
|
||||
print(e.toString());
|
||||
@@ -662,11 +663,6 @@ class Cache with Logging {
|
||||
List<Purchase> get purchases => _purchases;
|
||||
setPurchases(List<Purchase> value) => _purchases = value;
|
||||
|
||||
// ignore: unnecessary_getters_setters
|
||||
List<ProductTest>? get productTests => _productTests;
|
||||
// ignore: unnecessary_getters_setters
|
||||
set productTests(List<ProductTest>? value) => _productTests = value;
|
||||
|
||||
Future<void> initCustomer(int customerId) async {
|
||||
log(" *** initCustomer");
|
||||
await PackageApi().getCustomerPackage(customerId);
|
||||
@@ -738,4 +734,7 @@ class Cache with Logging {
|
||||
|
||||
List<CustomerTrainingPlan>? getCustomerTrainingPlans() => this._customerTrainingPlans;
|
||||
setCustomerTrainingPlans(value) => this._customerTrainingPlans = value;
|
||||
|
||||
List<SplitTest> getSplitTests() => this._splitTests;
|
||||
setSplitTests(value) => this._splitTests = value;
|
||||
}
|
||||
|
||||
@@ -57,10 +57,6 @@ class CustomerTrainingPlan {
|
||||
jsonDetails =
|
||||
jsonDetails.replaceAllMapped(RegExp(r'([0-9]{4}\-[0-9]{2}\-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2})'), (Match m) => "\"${m[0]}\"");
|
||||
|
||||
// jsonDetails = jsonDetails.replaceAll(r'\"null\"', 'null');
|
||||
// jsonDetails = jsonDetails.replaceAll(r'\"false\"', 'false');
|
||||
// jsonDetails = jsonDetails.replaceAll(r'\"true\"', 'true');
|
||||
|
||||
print("detail: $jsonDetails");
|
||||
|
||||
Iterable iterable = jsonDecode(jsonDetails);
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/model/exercise.dart';
|
||||
import 'package:aitrainer_app/model/exercise_plan_detail.dart';
|
||||
@@ -9,6 +7,9 @@ class CustomerTrainingPlanDetails {
|
||||
/// customerTrainingPlanDetails
|
||||
int? customerTrainingPlanDetailsId;
|
||||
|
||||
/// trainingPlanDetailsId
|
||||
int? trainingPlanDetailsId;
|
||||
|
||||
/// exerciseTypeId
|
||||
int? exerciseTypeId;
|
||||
|
||||
@@ -32,6 +33,8 @@ class CustomerTrainingPlanDetails {
|
||||
|
||||
List<Exercise> exercises = [];
|
||||
|
||||
bool isTest = false;
|
||||
|
||||
CustomerTrainingPlanDetails();
|
||||
|
||||
CustomerTrainingPlanDetails.fromJson(Map json) {
|
||||
@@ -49,6 +52,7 @@ class CustomerTrainingPlanDetails {
|
||||
this.customerTrainingPlanDetailsId = json['customerTrainingPlanDetailsId'] == "null" || json['customerTrainingPlanDetailsId'] == null
|
||||
? 0
|
||||
: json['customerTrainingPlanDetailsId'];
|
||||
this.trainingPlanDetailsId = json['trainingPlanDetailsId'];
|
||||
this.exerciseTypeId = json['exerciseTypeId'];
|
||||
this.set = json['set'];
|
||||
this.repeats = json['repeats'] == "null" ? -1 : json['repeats'];
|
||||
@@ -79,6 +83,7 @@ class CustomerTrainingPlanDetails {
|
||||
} else {
|
||||
this.state = ExercisePlanDetailState.start;
|
||||
}
|
||||
this.isTest = json['isTest'] == "true" ? true : false;
|
||||
|
||||
this.exerciseType = Cache().getExerciseTypeById(exerciseTypeId!);
|
||||
}
|
||||
@@ -98,7 +103,8 @@ class CustomerTrainingPlanDetails {
|
||||
|
||||
Map<String, dynamic> toJsonWithExercises() {
|
||||
final Map<String, dynamic> jsonMap = {
|
||||
//"customerTrainingPlanDetailsId": this.customerTrainingPlanDetailsId,
|
||||
"customerTrainingPlanDetailsId": this.customerTrainingPlanDetailsId,
|
||||
"trainingPlanDetailsId": this.trainingPlanDetailsId,
|
||||
"exerciseTypeId": this.exerciseTypeId,
|
||||
"set": this.set,
|
||||
"repeats": this.repeats,
|
||||
@@ -107,6 +113,7 @@ class CustomerTrainingPlanDetails {
|
||||
"parallel": this.parallel,
|
||||
'exercises': exercises.isEmpty ? [].toString() : exercises.map((exercise) => exercise.toJson()).toList().toString(),
|
||||
'state': this.state.toStr(),
|
||||
"isTest": this.isTest,
|
||||
};
|
||||
if (this.day != null && this.day!.isNotEmpty) {
|
||||
jsonMap["day"] = this.day;
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class ProductTest {
|
||||
late int? productTestId;
|
||||
late int customerId;
|
||||
late int productId;
|
||||
|
||||
late DateTime dateView;
|
||||
late bool purchaseClick;
|
||||
|
||||
ProductTest();
|
||||
|
||||
ProductTest.fromJson(Map json) {
|
||||
this.productTestId = json['productTestId'];
|
||||
this.customerId = json['customerId'];
|
||||
this.productId = json['productId'];
|
||||
this.dateView = DateTime.parse(json['dateView']);
|
||||
this.purchaseClick = json['purchaseClick'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
if (productTestId != null) {
|
||||
return {
|
||||
"productTestId": productTestId,
|
||||
"customerId": customerId,
|
||||
"productId": productId,
|
||||
"dateView": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateView),
|
||||
"purchaseClick": purchaseClick
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
"customerId": customerId,
|
||||
"productId": productId,
|
||||
"dateView": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateView),
|
||||
"purchaseClick": purchaseClick
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
class SplitTest {
|
||||
late int testId;
|
||||
late String name;
|
||||
late String remoteConfigKey;
|
||||
late String remoteConfigValue;
|
||||
late String testValue;
|
||||
String? source;
|
||||
late bool active;
|
||||
DateTime? validTo;
|
||||
|
||||
SplitTest.fromJson(Map json) {
|
||||
this.testId = json['testId'];
|
||||
this.name = json['name'];
|
||||
this.remoteConfigKey = json['remoteConfigKey'];
|
||||
this.remoteConfigValue = json['remoteConfigValue'];
|
||||
this.testValue = json['testValue'];
|
||||
this.source = json['source'];
|
||||
this.active = json['active'];
|
||||
this.validTo = json['validTo'] == null ? null : DateTime.parse(json['validTo']);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
Map<String, dynamic> json = {
|
||||
'productId': this.testId,
|
||||
'name': this.name,
|
||||
'remoteConfigKey': this.remoteConfigKey,
|
||||
'remoteConfigValue': this.remoteConfigValue,
|
||||
'testValue': this.testValue,
|
||||
'source': this.source,
|
||||
'active': this.active,
|
||||
'validTo': validTo,
|
||||
};
|
||||
return json.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user