From b270512e5614d43f92f97ecc4c4a8de469add0be Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Thu, 16 Mar 2023 14:44:50 +0530 Subject: [PATCH] fix: event page (#204) * fix: event page * fix: condiionally render lectures * manage roll number state --- .../data/remote/graphql/graphql_service.dart | 9 +++- elaichi/lib/data/remote/graphql/queries.dart | 6 +-- .../home/fest/explore/explore_page.dart | 47 ++++++++++++------- .../profile/bloc/profile_bloc.dart | 7 +-- 4 files changed, 41 insertions(+), 28 deletions(-) diff --git a/elaichi/lib/data/remote/graphql/graphql_service.dart b/elaichi/lib/data/remote/graphql/graphql_service.dart index e32b762b..c69a4d50 100644 --- a/elaichi/lib/data/remote/graphql/graphql_service.dart +++ b/elaichi/lib/data/remote/graphql/graphql_service.dart @@ -120,7 +120,14 @@ class GraphQLService { Future> getOrgs() async { try { - final result = await query(queryString: Queries.getOrgs); + final result = await query( + queryString: Queries.getOrgs, + variables: { + //change this to 0, 1 to get latest org after PR merge in backend + 'pagination': {'skip': 1, 'take': 1}, + 'orgType': 'FEST' + }, + ); final orgsList = (result.data!['org'] as List) .map((e) => Org.fromJson(e as Map)) diff --git a/elaichi/lib/data/remote/graphql/queries.dart b/elaichi/lib/data/remote/graphql/queries.dart index 06a160f1..56bbef5b 100644 --- a/elaichi/lib/data/remote/graphql/queries.dart +++ b/elaichi/lib/data/remote/graphql/queries.dart @@ -17,9 +17,9 @@ class Queries { } '''; - static const getOrgs = ''' - query Org { - org { + static const getOrgs = r''' + query Org ($pagination: paginationInputType, $orgType: OrgType){ + org(pagination: $pagination, orgType: $orgType){ id name description diff --git a/elaichi/lib/presentation/home/fest/explore/explore_page.dart b/elaichi/lib/presentation/home/fest/explore/explore_page.dart index 735ce5b6..cd3b2901 100644 --- a/elaichi/lib/presentation/home/fest/explore/explore_page.dart +++ b/elaichi/lib/presentation/home/fest/explore/explore_page.dart @@ -177,28 +177,30 @@ class _ExplorePageState extends State crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Pro Shows', + '${categorisedEvents!.keys.toList()[0][0].toUpperCase()}${categorisedEvents.keys.toList()[0].substring(1).toLowerCase()}', style: interTextTheme.headline2, ), const SizedBox(height: 24), HighPriorityEventList( - events: categorisedEvents!['PRO']!, + events: + categorisedEvents[categorisedEvents.keys.toList()[0]]!, ), const SizedBox(height: 80), Text( - 'Technical Events', + '${categorisedEvents.keys.toList()[1][0].toUpperCase()}${categorisedEvents.keys.toList()[1].substring(1).toLowerCase()}', style: interTextTheme.headline2, ), const SizedBox(height: 24), HighPriorityEventList( - events: categorisedEvents['TECHNICAL']!, + events: + categorisedEvents[categorisedEvents.keys.toList()[1]]!, ), const SizedBox(height: 80), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - 'Fun Events', + '${categorisedEvents.keys.toList()[2][0].toUpperCase()}${categorisedEvents.keys.toList()[2].substring(1).toLowerCase()}', style: interTextTheme.headline2, ), GestureDetector( @@ -220,14 +222,15 @@ class _ExplorePageState extends State ), const SizedBox(height: 24), LowPriorityEventsList( - events: categorisedEvents['FUN']!, + events: + categorisedEvents[categorisedEvents.keys.toList()[2]]!, ), const SizedBox(height: 80), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - 'Exhibitions', + '${categorisedEvents.keys.toList()[3][0].toUpperCase()}${categorisedEvents.keys.toList()[3].substring(1).toLowerCase()}', style: interTextTheme.headline2, ), GestureDetector( @@ -249,18 +252,26 @@ class _ExplorePageState extends State ), const SizedBox(height: 24), LowPriorityEventsList( - events: categorisedEvents['EXHIBITIONS']!, - ), - const SizedBox(height: 80), - Text( - 'Guest Lectures', - style: interTextTheme.headline2, - ), - const SizedBox(height: 24), - SpeakerEventList( - events: categorisedEvents['GUEST-LECTURES ']!, + events: + categorisedEvents[categorisedEvents.keys.toList()[3]]!, ), const SizedBox(height: 80), + if ((categorisedEvents['GUEST-LECTURES '] ?? + categorisedEvents['WORKSHOPS'] ?? + []) + .isNotEmpty) ...[ + Text( + 'Guest Lectures', + style: interTextTheme.headline2, + ), + const SizedBox(height: 24), + SpeakerEventList( + events: categorisedEvents['GUEST-LECTURES '] ?? + categorisedEvents['WORKSHOPS'] ?? + [], + ), + const SizedBox(height: 80), + ], Text( 'Our Schedule', style: interTextTheme.headline2, @@ -284,7 +295,7 @@ class _ExplorePageState extends State class SpeakerEventList extends StatelessWidget { const SpeakerEventList({ Key? key, - required this.events, + this.events = const [], }) : super(key: key); final List events; diff --git a/elaichi/lib/presentation/profile/bloc/profile_bloc.dart b/elaichi/lib/presentation/profile/bloc/profile_bloc.dart index 18f743b8..b160b8b0 100644 --- a/elaichi/lib/presentation/profile/bloc/profile_bloc.dart +++ b/elaichi/lib/presentation/profile/bloc/profile_bloc.dart @@ -15,7 +15,6 @@ class ProfileBloc extends Bloc { }) : _userRepository = userRepository, _eventRepository = eventRepository, super(const _Initial()) { - getRollNumber(); on<_WebMailLogOut>((event, emit) { emit(const ProfileState.loading()); _userRepository.deleteWebMailDetails(); @@ -31,11 +30,7 @@ class ProfileBloc extends Bloc { final UserRepository _userRepository; final EventRepository _eventRepository; - String? rollNumber; - - void getRollNumber() { - rollNumber = _userRepository.rollNumber; - } + String? get rollNumber => _userRepository.rollNumber; bool get isZimraAuthenticated { if (_userRepository.rollNumber != null) {