From c377c67f40492aee7f07381a25bc92c3582b676e Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 20 Jan 2026 17:02:02 +0300 Subject: [PATCH] rota module added. --- .../providers/api/user_provider.dart | 8 +- lib/views/pages/user/profile_page.dart | 111 +++++++++--------- 2 files changed, 60 insertions(+), 59 deletions(-) diff --git a/lib/controllers/providers/api/user_provider.dart b/lib/controllers/providers/api/user_provider.dart index 64cec305..a989cbde 100644 --- a/lib/controllers/providers/api/user_provider.dart +++ b/lib/controllers/providers/api/user_provider.dart @@ -446,17 +446,17 @@ class UserProvider extends ChangeNotifier { } } - Future> getUserRota() async { + Future getUserRota() async { Response response; try { response = await ApiManager.instance.get(URLs.getUserRota); if (response.statusCode >= 200 && response.statusCode < 300) { List dataList = json.decode(response.body); - return List.generate(dataList.length, (index) => UserRotaModel.fromJson(dataList[index])); + return UserRotaModel.fromJson(dataList.first); } - return []; + return null; } catch (error) { - return []; + return null ; } } diff --git a/lib/views/pages/user/profile_page.dart b/lib/views/pages/user/profile_page.dart index 213df9b7..e228923e 100644 --- a/lib/views/pages/user/profile_page.dart +++ b/lib/views/pages/user/profile_page.dart @@ -219,12 +219,11 @@ class _ProfilePageState extends State { ], ).toShadowContainer(context), if (context.settingProvider.isUserFlowMedical) - FutureBuilder>( + FutureBuilder( future: _userProvider.getUserRota(), builder: (cxt, snapshot) { bool isLoading = snapshot.connectionState == ConnectionState.waiting; - - if ((!isLoading && (snapshot.hasError || (snapshot.data?.isEmpty ?? true)))) { + if ((!isLoading && (snapshot.hasError || !snapshot.hasData))) { return const SizedBox(); } @@ -238,56 +237,6 @@ class _ProfilePageState extends State { style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10), ), 8.height, - if (!isLoading) - ListView.separated( - padding: EdgeInsets.zero, - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (cxt, index) => Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - // Text( - // 'Site: ${_user.clientName ?? "-"}', - // style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), - // ), - Text( - 'Shift Name: ${snapshot.data![index].shiftName ?? "-"}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), - ), - Text( - 'Break: ${snapshot.data![index].breakTime ?? "-"}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), - ), - if (snapshot.data![index].leaveTypeCode?.isNotEmpty ?? false) - SizedBox( - width: double.infinity, - child: Column(children: [ - 8.height, - Text( - snapshot.data![index].leaveTypeCode ?? "", - style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120, fontWeight: FontWeight.w600), - ), - Text( - snapshot.data![index].leaveDescription ?? "", - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), - ), - ]), - ) - else ...[ - Text( - 'Shift Start Time: ${snapshot.data![index].shTActualStartTime?.toTime ?? "-"}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), - ), - Text( - 'Shift Start Time: ${snapshot.data![index].shTActualEndTime?.toTime ?? "-"}', - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), - ), - ], - ], - ), - separatorBuilder: (cxt, index) => const Divider().defaultStyle(context), - itemCount: snapshot.data!.length), if (isLoading) ...[ Text( 'Shift Start Time Time', @@ -297,8 +246,60 @@ class _ProfilePageState extends State { Text( 'Shift Actual Actual Start Time', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), - ).toShimmer(context: context, isShow: isLoading), - ] + ).toShimmer(context: context, isShow: isLoading) + ] else + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + // Text( + // 'Site: ${_user.clientName ?? "-"}', + // style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + // ), + Text( + 'Shift Name: ${snapshot.data!.shiftName ?? "-"}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + Text( + 'Break: ${snapshot.data!.breakTime ?? "-"}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + if (snapshot.data!.leaveTypeCode?.isNotEmpty ?? false) + SizedBox( + width: double.infinity, + child: Column(children: [ + 8.height, + Text( + snapshot.data!.leaveTypeCode ?? "", + style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120, fontWeight: FontWeight.w600), + ), + Text( + snapshot.data!.leaveDescription ?? "", + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + ]), + ) + else ...[ + Text( + 'Shift Start Time: ${snapshot.data!.shiftActualStartDatetime?.chatMsgTime ?? "-"}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + Text( + 'Shift Start Time: ${snapshot.data!.shiftActualEndDateTime?.chatMsgTime ?? "-"}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + const Divider().defaultStyle(context), + Text( + 'Swipe In: ${snapshot.data!.shTActualStartTime?.toTime ?? "-"}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + Text( + 'Swipe Out: ${snapshot.data!.shTActualEndTime?.toTime ?? "-"}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120), + ), + ], + ], + ), ], ).toShadowContainer(context), );