forked from eatvio/eatvio_app
feat(chat): add consultation progress and personal diet status
related to #1115
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import 'package:eatvio_app/features/chat/presentation/widgets/notification_banner.dart';
|
||||
import 'package:eatvio_app/features/consultations/models/consultation_progress.dart';
|
||||
import 'package:eatvio_app/features/plans/enums/chosen_plan_state_enum.dart';
|
||||
|
||||
BannerType? resolveChatBanner({
|
||||
required ConsultationProgress? progress,
|
||||
required bool amIConsultant,
|
||||
required bool hasCard,
|
||||
required ChosenPlanStateEnum? state,
|
||||
}) {
|
||||
if (progress == null ||
|
||||
state == null ||
|
||||
progress.phase != ConsultationPhase.active) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (amIConsultant &&
|
||||
!hasCard &&
|
||||
state == ChosenPlanStateEnum.stateInCoordination) {
|
||||
return BannerType.card;
|
||||
}
|
||||
if (amIConsultant && state == ChosenPlanStateEnum.stateInCoordination) {
|
||||
return BannerType.date;
|
||||
}
|
||||
if (!amIConsultant &&
|
||||
(state == ChosenPlanStateEnum.stateStartDateHasBeenSet ||
|
||||
state == ChosenPlanStateEnum.statePendingPayment)) {
|
||||
return BannerType.payment;
|
||||
}
|
||||
if (state == ChosenPlanStateEnum.stateDone && amIConsultant) {
|
||||
return BannerType.collectCharge;
|
||||
}
|
||||
if (state == ChosenPlanStateEnum.stateLastDayFinished && !amIConsultant) {
|
||||
return BannerType.finishPlan;
|
||||
}
|
||||
if (!amIConsultant) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (state == ChosenPlanStateEnum.statePaid &&
|
||||
progress.dietStatus == PersonalDietStatus.notProposed) {
|
||||
return BannerType.setPersonalDiet;
|
||||
}
|
||||
if ((state == ChosenPlanStateEnum.personalDietSet ||
|
||||
state == ChosenPlanStateEnum.stateStarted ||
|
||||
state == ChosenPlanStateEnum.stateInProgress) &&
|
||||
progress.dietStatus == PersonalDietStatus.proposed) {
|
||||
return BannerType.changePersonalDiet;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user