Files
eatvio_app/lib/features/consultations/entities/consultations_entity.dart
2025-02-19 14:56:53 +03:00

83 lines
3.9 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'dart:math';
class ConsultationsEntity {
final String name; // Имя и фамилия пользователя который проходит план
final String planName; // Название плана который проходит
final String clientSlug; // Слаг пользователя который проходит
final String photoUrl; // Ссылка на аватрку пользователя
final DateTime startPlanDate; // Дата начала прохождения плана
final DateTime endPlanDate; // Дата окончания прохождения плана
final int paymentAmount; // Сумма выплаты которую получит консультант
final int currentDayOfPlan; // Текущий день прохождения плана
final int totalDaysOfPlan; // Общее число дней в плане
final List<DayOfPlanEntity> days; // Дни плана
final bool haveUnreadMessages; // Есть ли непрочитанные сообщения в чате от пользователя
ConsultationsEntity({
required this.name,
required this.planName,
required this.clientSlug,
required this.photoUrl,
required this.startPlanDate,
required this.endPlanDate,
required this.paymentAmount,
required this.days,
required this.haveUnreadMessages,
required this.currentDayOfPlan,
required this.totalDaysOfPlan,
});
}
enum LegendOfPlanDay {
Empty, // Дневник не заполнялся и никаких движений в тот день не было.
NotCompleted, // Начат дневник питания, но не закончен.
EndBuyUserDontCheck, // Дневник закончен и прокомментирован консультантом но не просмотрен пользователем.
CompletedButConsultantCommentEmpty, // Дневник заполнен, но не прокомментирован консультантом.
FullCompleted, // Дневник заполнен, прокомментирован консультантом и после этого клиент просмотрел комментарии.
}
class DayOfPlanEntity {
final DateTime dateTime;
final List<LegendOfPlanDay> daysLegends;
DayOfPlanEntity({
required this.dateTime,
required this.daysLegends,
});
}
List<ConsultationsEntity> generateTestData() {
final random = Random();
final List<String> names = ["Иван Петров", "Анна Смирнова", "Дмитрий Соколов", "Елена Козлова", "Алексей Иванов"];
final List<String> plans = ["Похудение", "Набор массы", "Детокс", "Здоровое питание", "Вегетарианство"];
List<ConsultationsEntity> testConsultations = List.generate(20, (index) {
DateTime startDate = DateTime.now().subtract(Duration(days: random.nextInt(30)));
DateTime endDate = startDate.add(Duration(days: 30));
List<DayOfPlanEntity> days = List.generate(30, (i) {
DateTime dayDate = startDate.add(Duration(days: i));
List<LegendOfPlanDay> legends = List.generate(random.nextInt(3) + 1, (j) => LegendOfPlanDay.values[random.nextInt(LegendOfPlanDay.values.length)]);
return DayOfPlanEntity(dateTime: dayDate, daysLegends: legends);
});
return ConsultationsEntity(
name: names[random.nextInt(names.length)],
planName: plans[random.nextInt(plans.length)],
clientSlug: "client_${index + 1}",
startPlanDate: startDate,
endPlanDate: endDate,
paymentAmount: (random.nextInt(10) + 1) * 1000,
days: days,
haveUnreadMessages: random.nextBool(),
photoUrl: '',
currentDayOfPlan: Random().nextInt(6) + 1,
totalDaysOfPlan: Random().nextInt(7) + 14,
);
});
return testConsultations;
}
List<ConsultationsEntity> testData = generateTestData();