From 88973c7dfbc04a91ca03c367ba38a7e835db837e Mon Sep 17 00:00:00 2001 From: PSYCHNERD2512 Date: Tue, 2 Jan 2024 22:22:10 +0530 Subject: [PATCH] FIX: Events Push Mail Check --- lib/src/api/apiclient.dart | 2 +- lib/src/api/model/event.dart | 3 +++ lib/src/api/model/event.g.dart | 2 ++ lib/src/routes/eventpage.dart | 29 +++++++++++++++-------------- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/lib/src/api/apiclient.dart b/lib/src/api/apiclient.dart index c0e8cc5..ed5a2fe 100644 --- a/lib/src/api/apiclient.dart +++ b/lib/src/api/apiclient.dart @@ -45,7 +45,7 @@ import 'model/offersecret.dart'; part 'apiclient.g.dart'; -@rt.RestApi(baseUrl: "http://127.0.0.1:8000/api") +// @rt.RestApi(baseUrl: "http://127.0.0.1:8000/api") // @rt.RestApi(baseUrl: "http://10.105.177.150/api") @rt.RestApi(baseUrl: "https://gymkhana.iitb.ac.in/instiapp/api") // @rt.RestApi(baseUrl: "https://dcae-2405-201-5004-30e9-a45d-9897-ea81-3414.ngrok-free.app/api") diff --git a/lib/src/api/model/event.dart b/lib/src/api/model/event.dart index 75ef0e0..344c630 100644 --- a/lib/src/api/model/event.dart +++ b/lib/src/api/model/event.dart @@ -49,6 +49,9 @@ class Event extends elt.Event { @JsonKey(name: "all_day") bool? allDayEvent; + @JsonKey(name: "email_verified") + bool? emailVerified; + @JsonKey(name: "venues") List? eventVenues; diff --git a/lib/src/api/model/event.g.dart b/lib/src/api/model/event.g.dart index 762d9aa..f3ff096 100644 --- a/lib/src/api/model/event.g.dart +++ b/lib/src/api/model/event.g.dart @@ -44,6 +44,7 @@ Event _$EventFromJson(Map json) => Event( .toList(), ) ..eventLongDescription = json['longdescription'] as String? + ..emailVerified = json['email_verified'] as bool? ..eventStartDate = json['eventStartDate'] == null ? null : DateTime.parse(json['eventStartDate'] as String); @@ -59,6 +60,7 @@ Map _$EventToJson(Event instance) => { 'start_time': instance.eventStartTime, 'end_time': instance.eventEndTime, 'all_day': instance.allDayEvent, + 'email_verified': instance.emailVerified, 'venues': instance.eventVenues, 'bodies': instance.eventBodies, 'offered_achievements': instance.eventOfferedAchievements, diff --git a/lib/src/routes/eventpage.dart b/lib/src/routes/eventpage.dart index 7c87905..b253734 100644 --- a/lib/src/routes/eventpage.dart +++ b/lib/src/routes/eventpage.dart @@ -20,7 +20,6 @@ import 'package:markdown/markdown.dart' as markdown; import 'package:device_calendar/device_calendar.dart' as cal; import 'package:timezone/timezone.dart' as tz; - class EventPage extends StatefulWidget { final Event? initialEvent; final Future eventFuture; @@ -236,10 +235,11 @@ class _EventPageState extends State { height: 64.0, ), Container( - child: (bloc.currSession?.profile?.userRoles?.any( - (role) => role.rolePermissions! - .contains("VerE")) ?? - false) + child: !(event!.emailVerified ?? false) && + ((bloc.currSession?.profile?.userRoles?.any( + (role) => role.rolePermissions! + .contains("VerE")) ?? + false)) ? Padding( padding: const EdgeInsets.symmetric( horizontal: 28.0, vertical: 16.0), @@ -252,10 +252,11 @@ class _EventPageState extends State { : null, ), Container( - child: bloc.currSession?.profile?.userRoles?.any( - (role) => role.rolePermissions! - .contains("VerE")) ?? - false + child: !(event!.emailVerified ?? false) && + ((bloc.currSession?.profile?.userRoles?.any( + (role) => role.rolePermissions! + .contains("VerE")) ?? + false)) ? Padding( padding: const EdgeInsets.all(8.0), child: TextButton( @@ -278,10 +279,11 @@ class _EventPageState extends State { : null, ), Container( - child: bloc.currSession?.profile?.userRoles?.any( - (role) => role.rolePermissions! - .contains("VerE")) ?? - false + child: !(event!.emailVerified ?? false) && + ((bloc.currSession?.profile?.userRoles?.any( + (role) => role.rolePermissions! + .contains("VerE")) ?? + false)) ? Padding( padding: const EdgeInsets.all(8.0), child: TextButton( @@ -345,7 +347,6 @@ class _EventPageState extends State { ), onTap: () { BodyPage.navigateWith(context, bloc, body: body); - }, ); }