forked from eatvio/eatvio_app
feat(consultantFinaces): added consultant finaces screen
This commit is contained in:
@@ -16,6 +16,7 @@ import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.da
|
||||
import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/become_consultant_screen.dart';
|
||||
import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart';
|
||||
import 'package:eatvio_app/features/consultations/presentation/pages/consultations_screen.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/consultant_finances_screen.dart';
|
||||
import 'package:eatvio_app/features/order_info/presentation/info_by_order_screen.dart';
|
||||
import 'package:eatvio_app/features/create_diet/presentation/create_diet_screen.dart';
|
||||
import 'package:eatvio_app/features/create_diet/presentation/diet_preview_screen.dart';
|
||||
@@ -181,10 +182,15 @@ class AppRouter {
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/consultant-finance-screen',
|
||||
name: 'consultantFinanceScreen',
|
||||
path: ConsultationsArchiveScreen.path,
|
||||
name: ConsultationsArchiveScreen.name,
|
||||
builder: (context, state) => const ConsultationsArchiveScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: ConsultantFinancesScreen.path,
|
||||
name: ConsultantFinancesScreen.name,
|
||||
builder: (context, state) => const ConsultantFinancesScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/user-finance-screen',
|
||||
name: 'userFinanceScreen',
|
||||
|
||||
@@ -30,6 +30,7 @@ import 'package:eatvio_app/features/blog_post_create/bloc/blog_post_create_cubit
|
||||
import 'package:eatvio_app/features/blog_post_create/repositories/blog_post_repository.dart';
|
||||
import 'package:eatvio_app/features/blog_post_create/services/blog_post_service.dart';
|
||||
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_cubit.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/consultant_finances/consultant_finances_cubit.dart';
|
||||
import 'package:eatvio_app/features/notifications/presentation/notifications_cubit/notifications_cubit.dart';
|
||||
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart';
|
||||
import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_cubit.dart';
|
||||
@@ -147,6 +148,7 @@ Future<void> init() async {
|
||||
sl.registerFactory<VerifyEmailCubit>(() => VerifyEmailCubit(profileRepository: sl()));
|
||||
sl.registerFactory<MyRecipesCubit>(() => MyRecipesCubit(myRecipesRepository: sl(), aboutRecipeRepository: sl()));
|
||||
sl.registerFactory<ConsultationsArchiveCubit>(() => ConsultationsArchiveCubit(consultationsRepository: sl()));
|
||||
sl.registerFactory<ConsultantFinancesCubit>(() => ConsultantFinancesCubit(consultationsRepository: sl()));
|
||||
|
||||
// Repository
|
||||
sl.registerLazySingleton<ChatRepository>(() => ChatRepository(chatService: sl()));
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:eatvio_app/core/widgets/loader.dart';
|
||||
import 'package:eatvio_app/features/consultations/presentation/cubit/consultations_cubit.dart';
|
||||
import 'package:eatvio_app/features/consultations/presentation/cubit/consultations_state.dart';
|
||||
import 'package:eatvio_app/features/consultations/presentation/widgets/consultation_card_widget.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/consultations_archive_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
@@ -67,7 +68,7 @@ class ConsultationsContent extends StatelessWidget {
|
||||
InkWell(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
onTap: () {
|
||||
GoRouter.of(context).pushNamed('consultantFinanceScreen');
|
||||
GoRouter.of(context).pushNamed(ConsultationsArchiveScreen.name);
|
||||
},
|
||||
child: Ink(
|
||||
width: MediaQuery.of(context).size.width - 32,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:eatvio_app/core/enums/filters_comparison_enum.dart';
|
||||
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
||||
import 'package:eatvio_app/features/consultations/services/consultation_service.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/models/consultant_finance_model.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/models/statistic_model.dart';
|
||||
|
||||
class ConsultationsRepository {
|
||||
@@ -42,4 +43,12 @@ class ConsultationsRepository {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<ConsultantFinanceModel>> getConsultantFinances(String? date, FiltersComparisonEnum? dateComparison) async {
|
||||
try {
|
||||
return await consultationService.getConsultantFinances(date, dateComparison);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/core/enums/filters_comparison_enum.dart';
|
||||
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/models/consultant_finance_model.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/models/statistic_model.dart';
|
||||
|
||||
class ConsultationService {
|
||||
@@ -66,4 +67,23 @@ class ConsultationService {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<ConsultantFinanceModel>> getConsultantFinances(
|
||||
String? date,
|
||||
FiltersComparisonEnum? dateComparison,
|
||||
) async {
|
||||
try {
|
||||
final response = await dio.get(
|
||||
'/api/finances/my_finances',
|
||||
queryParameters: {
|
||||
if (dateComparison != null && date != null) 'filters[end_date]': date,
|
||||
},
|
||||
);
|
||||
final data = response.data as Map<String, dynamic>;
|
||||
final consultations = data['data'] as List<dynamic>;
|
||||
return consultations.map((consultation) => ConsultantFinanceModel.fromJson(consultation as Map<String, dynamic>)).toList();
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:eatvio_app/core/enums/filters_comparison_enum.dart';
|
||||
import 'package:eatvio_app/features/consultations/repositories/consultations_repository.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/consultant_finances/consultant_finances_state.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/period_enum.dart';
|
||||
@@ -13,19 +14,22 @@ class ConsultantFinancesCubit extends Cubit<ConsultantFinancesState> {
|
||||
ConsultantFinancesState(),
|
||||
);
|
||||
|
||||
Future<void> getConsultations() async {
|
||||
Future<void> getConsultantFinances() async {
|
||||
try {
|
||||
emit(state.copyWith(isLoading: true));
|
||||
final consultantFinances = await consultationsRepository.getConsultantFinances(
|
||||
state.periodFilterStatus?.value,
|
||||
state.periodFilterStatus == PeriodFilterStatus.all ? null : FiltersComparisonEnum.greaterThanOrEqual,
|
||||
);
|
||||
emit(state.copyWith(financesModels: consultantFinances, isLoading: false));
|
||||
} catch (e) {
|
||||
emit(state.copyWith(isLoading: false));
|
||||
emit(state.copyWith(financesModels: [], isLoading: false));
|
||||
log(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setConsultationsPeriod(PeriodFilterStatus period) async {
|
||||
Future<void> setFinancesPeriod(PeriodFilterStatus period) async {
|
||||
emit(state.copyWith(periodFilterStatus: period));
|
||||
await getConsultations();
|
||||
await getConsultantFinances();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/models/consultant_finance_model.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/period_enum.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
@@ -6,7 +7,7 @@ part 'consultant_finances_state.freezed.dart';
|
||||
@freezed
|
||||
abstract class ConsultantFinancesState with _$ConsultantFinancesState {
|
||||
factory ConsultantFinancesState({
|
||||
@Default([]) List<String> financesModels,
|
||||
@Default([]) List<ConsultantFinanceModel> financesModels,
|
||||
@Default(false) isLoading,
|
||||
@Default(null) String? error,
|
||||
@Default(null) PeriodFilterStatus? periodFilterStatus,
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'consultant_finance_model.freezed.dart';
|
||||
part 'consultant_finance_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class ConsultantFinanceModel with _$ConsultantFinanceModel {
|
||||
factory ConsultantFinanceModel({
|
||||
@JsonKey(name: 'start_date', fromJson: parseDate) required DateTime startDate,
|
||||
@JsonKey(name: 'bank_id') required String bankId,
|
||||
@JsonKey(name: 'title') required String title,
|
||||
@JsonKey(name: 'clientName') required String clientName,
|
||||
@JsonKey(name: 'duration') required int duration,
|
||||
@JsonKey(name: 'payment_price', fromJson: _parsePayment) required String paymentPrice,
|
||||
}) = _ConsultantFinanceModel;
|
||||
|
||||
factory ConsultantFinanceModel.fromJson(Map<String, dynamic> json) => _$ConsultantFinanceModelFromJson(json);
|
||||
}
|
||||
|
||||
String _parsePayment(json) {
|
||||
return ((json as int) / 100).toStringAsFixed(2);
|
||||
}
|
||||
|
||||
enum PaymentStatus {
|
||||
@JsonValue('COMPLETED')
|
||||
completed,
|
||||
@JsonValue('REJECTED')
|
||||
rejected,
|
||||
@JsonValue('CHECKED')
|
||||
checked,
|
||||
@JsonValue('CREDIT_CHECKING')
|
||||
creditChecking,
|
||||
@JsonValue('COMPLETING')
|
||||
completing;
|
||||
}
|
||||
@@ -1,281 +1,214 @@
|
||||
// import 'package:eatvio_app/core/locator_service.dart';
|
||||
// import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||
// import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
// import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||
// import 'package:eatvio_app/core/utils/localization_utils.dart';
|
||||
// import 'package:eatvio_app/core/widgets/custom_drop_down_button.dart';
|
||||
// import 'package:eatvio_app/core/widgets/loader.dart';
|
||||
// import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/archive/consultations_archive_cubit.dart';
|
||||
// import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/archive/consultations_archive_state.dart';
|
||||
// import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/consultant_finances/consultant_finances_cubit.dart';
|
||||
// import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/consultant_finances/consultant_finances_state.dart';
|
||||
// import 'package:eatvio_app/features/finances_and_consultations_archive/period_enum.dart';
|
||||
// import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/widgets/status_widget.dart';
|
||||
// import 'package:eatvio_app/generated/l10n.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||
import 'package:eatvio_app/core/utils/localization_utils.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_drop_down_button.dart';
|
||||
import 'package:eatvio_app/core/widgets/loader.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/consultant_finances/consultant_finances_cubit.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/consultant_finances/consultant_finances_state.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/period_enum.dart';
|
||||
import 'package:eatvio_app/features/my_finance/presentation/pages/card_settings.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
// class ConsultantFinancesScreen extends StatefulWidget {
|
||||
// const ConsultantFinancesScreen({super.key});
|
||||
class ConsultantFinancesScreen extends StatefulWidget {
|
||||
const ConsultantFinancesScreen({super.key});
|
||||
static const name = 'consultantFinancesScreen';
|
||||
static const path = '/consultant-finances-screen';
|
||||
@override
|
||||
State<ConsultantFinancesScreen> createState() => _ConsultantFinancesScreenState();
|
||||
}
|
||||
|
||||
// @override
|
||||
// State<ConsultantFinancesScreen> createState() => _ConsultantFinancesScreenState();
|
||||
// }
|
||||
|
||||
// class _ConsultantFinancesScreenState extends State<ConsultantFinancesScreen> {
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final s = S.of(context);
|
||||
// return BlocProvider<ConsultantFinancesCubit>(
|
||||
// create: (context) => sl<ConsultantFinancesCubit>(),
|
||||
// child: BlocBuilder<ConsultantFinancesCubit, ConsultantFinancesState>(
|
||||
// builder: (context, state) {
|
||||
// return Scaffold(
|
||||
// backgroundColor: const Color(0xFFF0F2F5),
|
||||
// appBar: AppBar(
|
||||
// shape: const RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadiusDirectional.vertical(
|
||||
// bottom: Radius.circular(12),
|
||||
// ),
|
||||
// ),
|
||||
// title: const Text('Архив консультаций'),
|
||||
// centerTitle: true,
|
||||
// ),
|
||||
// body: state.isLoading
|
||||
// ? const Center(
|
||||
// child: Loader(),
|
||||
// )
|
||||
// : SingleChildScrollView(
|
||||
// padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
// child: Column(
|
||||
// children: [
|
||||
// Material(
|
||||
// color: Colors.white,
|
||||
// borderRadius: BorderRadius.circular(12),
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// const SizedBox(height: 16),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
// child: Text(
|
||||
// 'Всего консультаций: ${state.statisticModel.total}',
|
||||
// style: const TextStyle(
|
||||
// fontSize: 16,
|
||||
// fontWeight: FontWeight.w500,
|
||||
// color: Color(0xFF6D6F71),
|
||||
// height: 1,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 12),
|
||||
// Row(
|
||||
// children: [
|
||||
// const SizedBox(width: 16),
|
||||
// Material(
|
||||
// color: const Color(0xFF0BB450).withAlpha(11),
|
||||
// borderRadius: BorderRadius.circular(8),
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
// child: Text(
|
||||
// 'Завершено: ${state.statisticModel.finished}',
|
||||
// style: const TextStyle(
|
||||
// fontSize: 14,
|
||||
// fontWeight: FontWeight.w400,
|
||||
// color: Color(0xFF0BB450),
|
||||
// height: 1,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(width: 8),
|
||||
// Material(
|
||||
// color: const Color(0xFFD01717).withAlpha(11),
|
||||
// borderRadius: BorderRadius.circular(8),
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
// child: Text(
|
||||
// 'Отменено: ${state.statisticModel.canceled}',
|
||||
// style: const TextStyle(
|
||||
// fontSize: 14,
|
||||
// fontWeight: FontWeight.w400,
|
||||
// color: Color(0xFFD01717),
|
||||
// height: 1,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// const SizedBox(height: 16),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// Material(
|
||||
// color: Colors.white,
|
||||
// borderRadius: BorderRadius.circular(12),
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.only(left: 16, right: 16, top: 16),
|
||||
// child: SingleChildScrollView(
|
||||
// physics: const NeverScrollableScrollPhysics(),
|
||||
// child: Column(
|
||||
// children: [
|
||||
// CustomDropDownButton<PeriodFilterStatus>(
|
||||
// items: PeriodFilterStatus.values
|
||||
// .map(
|
||||
// (value) => DropdownMenuItem(
|
||||
// value: value,
|
||||
// child: Text(
|
||||
// value.name,
|
||||
// style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// .toList(),
|
||||
// onChanged: (value) {
|
||||
// if (value == null) return;
|
||||
// context.read<ConsultationsArchiveCubit>().setConsultationsPeriod(value);
|
||||
// },
|
||||
// value: state.periodFilterStatus ?? PeriodFilterStatus.values.first,
|
||||
// ),
|
||||
// const SizedBox(height: 12),
|
||||
// CustomDropDownButton<ConsultationFilterStatus>(
|
||||
// items: ConsultationFilterStatus.values
|
||||
// .map(
|
||||
// (value) => DropdownMenuItem(
|
||||
// value: value,
|
||||
// child: Text(
|
||||
// value.name,
|
||||
// style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// .toList(),
|
||||
// onChanged: (value) {
|
||||
// if (value == null) return;
|
||||
// context.read<ConsultationsArchiveCubit>().setConsultationsStatus(value);
|
||||
// },
|
||||
// value: state.consultationFilterStatus,
|
||||
// ),
|
||||
// const SizedBox(height: 12),
|
||||
// if (state.consultations.isNotEmpty)
|
||||
// ListView.separated(
|
||||
// shrinkWrap: true,
|
||||
// physics: const NeverScrollableScrollPhysics(),
|
||||
// itemBuilder: (context, index) {
|
||||
// return Material(
|
||||
// color: const Color(0xFFF6F6F6),
|
||||
// borderRadius: BorderRadius.circular(20),
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(12),
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Text(
|
||||
// state.consultations[index].id.toString(),
|
||||
// style: const TextStyle(
|
||||
// color: Color(0xFF323F4B),
|
||||
// height: 1,
|
||||
// fontWeight: FontWeight.w500,
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// state.consultations[index].startDate.format('yyyy.MM.dd'),
|
||||
// style: const TextStyle(
|
||||
// color: Color(0xFF6D6F71),
|
||||
// height: 1,
|
||||
// fontWeight: FontWeight.w500,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// Text(
|
||||
// state.consultations[index].planTitle,
|
||||
// style: TextStyle(
|
||||
// color: appTheme.blueA400,
|
||||
// height: 1,
|
||||
// fontSize: 18,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// Text(
|
||||
// 'Покупатель: ${state.consultations[index].userName}',
|
||||
// style: const TextStyle(
|
||||
// color: Color(0xFF323F4B),
|
||||
// height: 1,
|
||||
// fontSize: 14,
|
||||
// fontWeight: FontWeight.w500,
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// Text(
|
||||
// '${state.consultations[index].duration} ${getDayForm(state.consultations[index].duration, s)}',
|
||||
// style: const TextStyle(
|
||||
// color: Color(0xFF323F4B),
|
||||
// height: 1,
|
||||
// fontSize: 14,
|
||||
// fontWeight: FontWeight.w500,
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// Container(
|
||||
// height: 1,
|
||||
// width: double.infinity,
|
||||
// decoration: const BoxDecoration(
|
||||
// color: Color(0xFFDEDEDF),
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Text(
|
||||
// '${state.consultations[index].consultantPayment.toStringAsFixed(2)} ₽',
|
||||
// style: const TextStyle(
|
||||
// color: Color(0xFF323F4B),
|
||||
// height: 1,
|
||||
// fontSize: 18,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// ),
|
||||
// ),
|
||||
// StatusWidget(
|
||||
// status: state.consultations[index].chosenPlanState,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// separatorBuilder: (context, index) => const SizedBox(height: 12),
|
||||
// itemCount: state.financesModels.length,
|
||||
// )
|
||||
// else
|
||||
// const Padding(
|
||||
// padding: EdgeInsets.symmetric(vertical: 40.0),
|
||||
// child: Text(
|
||||
// 'У вас нет таких консультаций',
|
||||
// style: TextStyles.textMMedium,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
class _ConsultantFinancesScreenState extends State<ConsultantFinancesScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
return BlocProvider<ConsultantFinancesCubit>(
|
||||
create: (context) => sl<ConsultantFinancesCubit>()..getConsultantFinances(),
|
||||
child: BlocBuilder<ConsultantFinancesCubit, ConsultantFinancesState>(
|
||||
builder: (context, state) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF0F2F5),
|
||||
appBar: AppBar(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadiusDirectional.vertical(
|
||||
bottom: Radius.circular(12),
|
||||
),
|
||||
),
|
||||
title: const Text('Архив консультаций'),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: state.isLoading
|
||||
? const Center(
|
||||
child: Loader(),
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
GoRouter.of(context).pushNamed(CardSettingsScreen.name);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: appTheme.blueA400),
|
||||
width: MediaQuery.of(context).size.width - 32,
|
||||
child: const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Text('Управление картами', style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w600)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Material(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, top: 16),
|
||||
child: SingleChildScrollView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
child: Column(
|
||||
children: [
|
||||
CustomDropDownButton<PeriodFilterStatus>(
|
||||
items: PeriodFilterStatus.values
|
||||
.map(
|
||||
(value) => DropdownMenuItem(
|
||||
value: value,
|
||||
child: Text(
|
||||
value.name,
|
||||
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
if (value == null) return;
|
||||
context.read<ConsultantFinancesCubit>().setFinancesPeriod(value);
|
||||
},
|
||||
value: state.periodFilterStatus ?? PeriodFilterStatus.values.first,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
if (state.financesModels.isNotEmpty)
|
||||
ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
return Material(
|
||||
color: const Color(0xFFF6F6F6),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Builder(builder: (context) {
|
||||
final idLen = state.financesModels[index].bankId.length;
|
||||
return Text(
|
||||
'${state.financesModels[index].bankId.substring(0, 4)}...${state.financesModels[index].bankId.substring(idLen - 4, idLen)} ',
|
||||
style: TextStyles.textSMedium.copyWith(color: appTheme.black),
|
||||
);
|
||||
}),
|
||||
Text(
|
||||
state.financesModels[index].startDate.format('yyyy.MM.dd'),
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF6D6F71),
|
||||
height: 1,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
state.financesModels[index].title,
|
||||
style: TextStyle(
|
||||
color: appTheme.blueA400,
|
||||
height: 1,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Покупатель: ${state.financesModels[index].clientName}',
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF323F4B),
|
||||
height: 1,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'${state.financesModels[index].duration} ${getDayForm(state.financesModels[index].duration, s)}',
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF323F4B),
|
||||
height: 1,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
height: 1,
|
||||
width: double.infinity,
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFFDEDEDF),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'${state.financesModels[index].paymentPrice} ₽',
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF323F4B),
|
||||
height: 1,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
// StatusWidget(
|
||||
// status: state.consultations[index].chosenPlanState,
|
||||
// ),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 12),
|
||||
itemCount: state.financesModels.length,
|
||||
)
|
||||
else
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 40.0),
|
||||
child: Text(
|
||||
'У вас нет таких консультаций',
|
||||
style: TextStyles.textMMedium,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class ConsultationsArchiveScreen extends StatefulWidget {
|
||||
const ConsultationsArchiveScreen({super.key});
|
||||
|
||||
static const name = 'consultationsArchiveScreen';
|
||||
static const path = '/consultations-archive-screen';
|
||||
@override
|
||||
State<ConsultationsArchiveScreen> createState() => _ConsultationsArchiveScreenState();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/core/utils/image_constant.dart';
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/consultant_finances_screen.dart';
|
||||
import 'package:eatvio_app/features/my_diets/presentation/my_diets_screen.dart';
|
||||
import 'package:eatvio_app/features/my_plans/presentation/my_plans_screen.dart';
|
||||
import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
||||
@@ -40,7 +41,10 @@ class MenuScreen extends StatelessWidget {
|
||||
leading: 'assets/icons/finance.svg',
|
||||
title: 'Мои финансы',
|
||||
onTap: () {
|
||||
GoRouter.of(context).pushNamed('userFinanceScreen');
|
||||
if (profileModel.roles.contains('consultant')) {
|
||||
GoRouter.of(context).push(ConsultantFinancesScreen.path);
|
||||
return;
|
||||
}
|
||||
},
|
||||
),
|
||||
_divider(context),
|
||||
|
||||
@@ -23,7 +23,7 @@ Future<void> main() async {
|
||||
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
|
||||
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
|
||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||
await di.init();
|
||||
await di.init();
|
||||
await SentryFlutter.init((options) {
|
||||
options.dsn = 'http://ba7f2653067776f3034e6e89850e85a1@sentry.md-desk.ru:9000/2';
|
||||
options.tracesSampleRate = 1.0;
|
||||
|
||||
Reference in New Issue
Block a user