feat(diary): consultant comments

This commit is contained in:
Username1548
2025-04-24 04:20:24 +07:00
parent 267cc38a0b
commit 3754d047fb
102 changed files with 6021 additions and 494 deletions

View File

@@ -128,21 +128,24 @@ class AboutPlanCubit extends Cubit<AboutPlanState> {
);
}
Future<ChosenPlanModel?> chosePlan() async {
Future<(ChosenPlanModel?, String?)> chosePlan() async {
try {
final slug = state.planModel?.slug;
final optionIndex = state.chosenOptionIndex;
if (slug != null) {
final optionName = _getOptionNameFromIndex(optionIndex);
final body = {'options_type': optionName};
return await planRepository.chosePlan(slug, body);
return (await planRepository.chosePlan(slug, body), null);
}
} on DioException catch (e, st) {
log(e.toString(), stackTrace: st);
if (e.response?.statusCode == 400) {
return (null, 'hasPlan');
}
log(e.toString(), stackTrace: st);
} catch (e, st) {
log(e.toString(), stackTrace: st);
}
return null;
return (null, '');
}
String _getOptionNameFromIndex(int index) => switch (index) {

View File

@@ -220,7 +220,11 @@ class _AboutPlanScreenState extends State<AboutPlanScreen> {
),
backgroundColor: appTheme.greenA700,
onPressed: () async {
final chosenPlan = await context.read<AboutPlanCubit>().chosePlan();
final (chosenPlan, error) = await context.read<AboutPlanCubit>().chosePlan();
if (error == 'hasPlan') {
showErrorDialog(context, title: s.end_previous_plan, description: s.you_can_not_start_plan_until_end_of_prev_one);
return;
}
if (chosenPlan == null) {
if (!context.mounted) return;
showErrorDialog(context, title: 'Не удалось заказать план');