Skip to content

Commit 7e45f61

Browse files
fix: update snackbar messages and enable rebate display for previous years
1 parent b35bbb2 commit 7e45f61

File tree

6 files changed

+59
-33
lines changed

6 files changed

+59
-33
lines changed

lib/data/constants/constants.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class AppConstants {
99
static const String USER_NOT_AUTHORIZED_TO_FETCH_USER =
1010
'You are not authorized to fetch this User';
1111
static const String USER_NOT_FOUND = 'No User Found';
12+
static const String USER_NOT_REGISTERED =
13+
'You are not registered. Kindly contact MDGSpace.';
1214

1315
/// MENU CONSTANTS
1416
static const String MENU_NOT_FOUND = 'No Menu Found';
@@ -46,7 +48,7 @@ class AppConstants {
4648
static const TEMPORARY_USER_API_STATUS = "Temporary";
4749

4850
/// api error messages
49-
static const MENU_NOT_UPLOADED = 'Menu not uploaded yet';
51+
static const MENU_NOT_UPLOADED = 'Menu not uploaded yet.\nKindly contact your mess secretary.';
5052

5153
// Storage Keys
5254
static const FCM_TOKEN = 'fcm_token';

lib/data/constants/env_config.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class EnvironmentConfig {
22
static const String BASE_URL = String.fromEnvironment(
33
'BASE_URL',
4-
defaultValue: 'https://appetizer.onrender.com',
4+
defaultValue: 'https://mess.iitr.ac.in',
55
);
66

77
static const String OAUTH_CLIENT_ID = String.fromEnvironment(
@@ -11,7 +11,7 @@ class EnvironmentConfig {
1111

1212
static const String OAUTH_REDIRECT_URI = String.fromEnvironment(
1313
'OAUTH_REDIRECT_URI',
14-
defaultValue: 'https://appetizer.onrender.com/api/user/oauth/redirect/',
14+
defaultValue: 'https://mess.iitr.ac.in/api/user/oauth/redirect/',
1515
);
1616

1717
static const String SENTRY_DSN = String.fromEnvironment('SENTRY_DSN');

lib/presentation/components/no_data_found_container.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class NoDataFoundContainer extends StatelessWidget {
2727
),
2828
Text(
2929
title,
30+
textAlign: TextAlign.center,
3031
style: TextStyle(
3132
color: const Color(0xFF111111),
3233
fontSize: 18.toAutoScaledFont,

lib/presentation/leaves_and_rebate/components/monthly_rebates.dart

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import 'package:appetizer/domain/models/transaction/paginated_yearly_rebate.dart
44
import 'package:appetizer/presentation/leaves_and_rebate/components/custom_divider.dart';
55
import 'package:appetizer/presentation/components/shadow_container.dart';
66
import 'package:flutter/material.dart';
7+
import 'package:flutter_bloc/flutter_bloc.dart';
8+
import 'package:appetizer/domain/repositories/transaction_repositroy.dart';
79
import 'package:month_picker_dialog/month_picker_dialog.dart';
810

911
class MonthlyRebates extends StatefulWidget {
@@ -39,6 +41,26 @@ class _MonthlyRebatesState extends State<MonthlyRebates> {
3941
// super.initState();
4042
// }
4143

44+
@override
45+
void initState() {
46+
super.initState();
47+
year = DateTime.now().year;
48+
_currMonthIndex = widget.currMonthIndex;
49+
paginatedYearlyRebate = widget.paginatedYearlyRebate;
50+
}
51+
52+
void _rebuildMonthlyMap() {
53+
_totalRebate = 0;
54+
_monthlyRebateMap.clear();
55+
if (paginatedYearlyRebate != null) {
56+
for (YearlyRebate yr in paginatedYearlyRebate!.results) {
57+
_monthlyRebateMap[_monthList[yr.monthId]] = yr.rebate;
58+
_totalRebate += yr.rebate;
59+
}
60+
}
61+
_monthlyRebateMap["All"] = _totalRebate;
62+
}
63+
4264
final _monthList = [
4365
'All',
4466
'January',
@@ -56,16 +78,10 @@ class _MonthlyRebatesState extends State<MonthlyRebates> {
5678
];
5779
@override
5880
Widget build(BuildContext context) {
59-
_totalRebate = 0;
6081
_currMonthIndex ??= widget.currMonthIndex;
6182
_currMonthName = _monthList[_currMonthIndex!];
6283
paginatedYearlyRebate ??= widget.paginatedYearlyRebate;
63-
for (YearlyRebate yr in paginatedYearlyRebate!.results) {
64-
_monthlyRebateMap[_monthList[yr.monthId]] = yr.rebate;
65-
_totalRebate += yr.rebate;
66-
}
67-
_monthlyRebateMap["All"] = _totalRebate;
68-
year = DateTime.now().year;
84+
_rebuildMonthlyMap();
6985
return ShadowContainer(
7086
width: 312.toAutoScaledWidth,
7187
offset: 2,
@@ -112,10 +128,17 @@ class _MonthlyRebatesState extends State<MonthlyRebates> {
112128
initialDate: DateTime(year, _currMonthIndex!),
113129
lastDate: DateTime.now(),
114130
);
115-
// TODO: rebates for prev year are blocked
116-
if (newDateTime != null &&
117-
newDateTime.year == year &&
118-
newDateTime.month != _currMonthIndex) {
131+
if (newDateTime == null) return;
132+
if (newDateTime.year != year) {
133+
final repo = context.read<TransactionRepository>();
134+
final data = await repo.getYearlyRebates(newDateTime.year);
135+
setState(() {
136+
year = newDateTime.year;
137+
paginatedYearlyRebate = data;
138+
_currMonthIndex = newDateTime.month;
139+
_rebuildMonthlyMap();
140+
});
141+
} else if (newDateTime.month != _currMonthIndex) {
119142
setState(() {
120143
_currMonthIndex = newDateTime.month;
121144
});

lib/presentation/login/bloc/login_bloc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
110110
try {
111111
isOldUser = await userRepository.userIsOldUser(event.enrollmentNo);
112112
} catch (e) {
113-
emit(const LoginInitial(error: AppConstants.GENERIC_FAILURE));
113+
emit(const LoginInitial(error: AppConstants.USER_NOT_REGISTERED));
114114
}
115115
if (isOldUser) {
116116
emit(EnterPassword(enrollmentNo: event.enrollmentNo));

pubspec.lock

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -713,26 +713,26 @@ packages:
713713
dependency: transitive
714714
description:
715715
name: leak_tracker
716-
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
716+
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
717717
url: "https://pub.dev"
718718
source: hosted
719-
version: "11.0.2"
719+
version: "10.0.9"
720720
leak_tracker_flutter_testing:
721721
dependency: transitive
722722
description:
723723
name: leak_tracker_flutter_testing
724-
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
724+
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
725725
url: "https://pub.dev"
726726
source: hosted
727-
version: "3.0.10"
727+
version: "3.0.9"
728728
leak_tracker_testing:
729729
dependency: transitive
730730
description:
731731
name: leak_tracker_testing
732-
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
732+
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
733733
url: "https://pub.dev"
734734
source: hosted
735-
version: "3.0.2"
735+
version: "3.0.1"
736736
lints:
737737
dependency: transitive
738738
description:
@@ -1017,10 +1017,10 @@ packages:
10171017
dependency: transitive
10181018
description:
10191019
name: shared_preferences_android
1020-
sha256: "0b0f98d535319cb5cdd4f65783c2a54ee6d417a2f093dbb18be3e36e4c3d181f"
1020+
sha256: bd14436108211b0d4ee5038689a56d4ae3620fd72fd6036e113bf1345bc74d9e
10211021
url: "https://pub.dev"
10221022
source: hosted
1023-
version: "2.4.14"
1023+
version: "2.4.13"
10241024
shared_preferences_foundation:
10251025
dependency: transitive
10261026
description:
@@ -1158,10 +1158,10 @@ packages:
11581158
dependency: transitive
11591159
description:
11601160
name: test_api
1161-
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
1161+
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
11621162
url: "https://pub.dev"
11631163
source: hosted
1164-
version: "0.7.6"
1164+
version: "0.7.4"
11651165
timing:
11661166
dependency: transitive
11671167
description:
@@ -1206,10 +1206,10 @@ packages:
12061206
dependency: transitive
12071207
description:
12081208
name: url_launcher_android
1209-
sha256: c0fb544b9ac7efa10254efaf00a951615c362d1ea1877472f8f6c0fa00fcf15b
1209+
sha256: "81777b08c498a292d93ff2feead633174c386291e35612f8da438d6e92c4447e"
12101210
url: "https://pub.dev"
12111211
source: hosted
1212-
version: "6.3.23"
1212+
version: "6.3.20"
12131213
url_launcher_ios:
12141214
dependency: transitive
12151215
description:
@@ -1294,18 +1294,18 @@ packages:
12941294
dependency: transitive
12951295
description:
12961296
name: vector_math
1297-
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
1297+
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
12981298
url: "https://pub.dev"
12991299
source: hosted
1300-
version: "2.2.0"
1300+
version: "2.1.4"
13011301
vm_service:
13021302
dependency: transitive
13031303
description:
13041304
name: vm_service
1305-
sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60"
1305+
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
13061306
url: "https://pub.dev"
13071307
source: hosted
1308-
version: "15.0.2"
1308+
version: "15.0.0"
13091309
watcher:
13101310
dependency: transitive
13111311
description:
@@ -1371,5 +1371,5 @@ packages:
13711371
source: hosted
13721372
version: "3.1.3"
13731373
sdks:
1374-
dart: ">=3.9.0 <4.0.0"
1375-
flutter: ">=3.35.0"
1374+
dart: ">=3.8.0 <4.0.0"
1375+
flutter: ">=3.29.0"

0 commit comments

Comments
 (0)