From ccddb96373c39651ddb254d79ca0fc67a171214b Mon Sep 17 00:00:00 2001 From: JohnRamberger Date: Wed, 8 Feb 2023 14:38:53 -0500 Subject: [PATCH 1/7] backend --- .../api/hacklyticsportal2023/cli-inputs.json | 2 +- .../api/hacklyticsportal2023/schema.graphql | 26 +- .../hacklyticsportal2023/transform.conf.json | 2 +- lib/models/Checkin.dart | 5 +- lib/models/Event.dart | 44 +++- lib/models/EventRSVP.dart | 240 ++++++++++++++++++ lib/models/ModelProvider.dart | 8 +- lib/models/ScavengerHunt.dart | 2 +- lib/models/ScavengerHuntCheckin.dart | 2 +- 9 files changed, 316 insertions(+), 15 deletions(-) create mode 100644 lib/models/EventRSVP.dart diff --git a/amplify/backend/api/hacklyticsportal2023/cli-inputs.json b/amplify/backend/api/hacklyticsportal2023/cli-inputs.json index dc7de0e..3b32282 100644 --- a/amplify/backend/api/hacklyticsportal2023/cli-inputs.json +++ b/amplify/backend/api/hacklyticsportal2023/cli-inputs.json @@ -9,7 +9,7 @@ }, "conflictResolution": { "defaultResolutionStrategy": { - "type": "OPTIMISTIC_CONCURRENCY" + "type": "AUTOMERGE" } }, "additionalAuthTypes": [ diff --git a/amplify/backend/api/hacklyticsportal2023/schema.graphql b/amplify/backend/api/hacklyticsportal2023/schema.graphql index b34d14f..3e09b47 100644 --- a/amplify/backend/api/hacklyticsportal2023/schema.graphql +++ b/amplify/backend/api/hacklyticsportal2023/schema.graphql @@ -31,6 +31,8 @@ type Event name: String! description: String status: Boolean + requireRSVP: Boolean + canRSVP: Boolean start: AWSDateTime end: AWSDateTime location: String @@ -47,7 +49,7 @@ type Checkin groups: ["Administrator"] operations: [read, create, update, delete] } - { allow: private, operations: [read] } + { allow: private, operations: [create, read, update, delete] } ] ) { id: ID! @@ -87,7 +89,7 @@ type ScavengerHunt rules: [ { allow: groups - groups: ["Administrator"] + groups: ["Administrator", "Scavenger"] operations: [read, create, update, delete] } { allow: private, operations: [read] } @@ -106,7 +108,7 @@ type ScavengerHuntCheckin rules: [ { allow: groups - groups: ["Administrator"] + groups: ["Administrator", "Scavenger"] operations: [read, create, update, delete] } { allow: private, operations: [read, create] } @@ -116,3 +118,21 @@ type ScavengerHuntCheckin checkpointID: String! userID: String! } + +type EventRSVP + @model + @auth( + rules: [ + { + allow: groups + groups: ["Administrator"] + operations: [read, create, update, delete] + } + { allow: owner, operations: [read, create, update, delete] } + ] + ) { + id: ID! + userID: String! + userName: String! + eventID: String! +} diff --git a/amplify/backend/api/hacklyticsportal2023/transform.conf.json b/amplify/backend/api/hacklyticsportal2023/transform.conf.json index 4ebdca8..1a748d4 100644 --- a/amplify/backend/api/hacklyticsportal2023/transform.conf.json +++ b/amplify/backend/api/hacklyticsportal2023/transform.conf.json @@ -3,7 +3,7 @@ "ElasticsearchWarning": true, "ResolverConfig": { "project": { - "ConflictHandler": "OPTIMISTIC_CONCURRENCY", + "ConflictHandler": "AUTOMERGE", "ConflictDetection": "VERSION" } } diff --git a/lib/models/Checkin.dart b/lib/models/Checkin.dart index 9dcbd44..894e1b2 100644 --- a/lib/models/Checkin.dart +++ b/lib/models/Checkin.dart @@ -224,7 +224,10 @@ class Checkin extends Model { AuthRule( authStrategy: AuthStrategy.PRIVATE, operations: [ - ModelOperation.READ + ModelOperation.CREATE, + ModelOperation.READ, + ModelOperation.UPDATE, + ModelOperation.DELETE ]) ]; diff --git a/lib/models/Event.dart b/lib/models/Event.dart index cc20489..a5e842d 100644 --- a/lib/models/Event.dart +++ b/lib/models/Event.dart @@ -33,6 +33,8 @@ class Event extends Model { final String? _name; final String? _description; final bool? _status; + final bool? _requireRSVP; + final bool? _canRSVP; final TemporalDateTime? _start; final TemporalDateTime? _end; final String? _location; @@ -70,6 +72,14 @@ class Event extends Model { return _status; } + bool? get requireRSVP { + return _requireRSVP; + } + + bool? get canRSVP { + return _canRSVP; + } + TemporalDateTime? get start { return _start; } @@ -98,14 +108,16 @@ class Event extends Model { return _updatedAt; } - const Event._internal({required this.id, required name, description, status, start, end, location, points, checkins, createdAt, updatedAt}): _name = name, _description = description, _status = status, _start = start, _end = end, _location = location, _points = points, _checkins = checkins, _createdAt = createdAt, _updatedAt = updatedAt; + const Event._internal({required this.id, required name, description, status, requireRSVP, canRSVP, start, end, location, points, checkins, createdAt, updatedAt}): _name = name, _description = description, _status = status, _requireRSVP = requireRSVP, _canRSVP = canRSVP, _start = start, _end = end, _location = location, _points = points, _checkins = checkins, _createdAt = createdAt, _updatedAt = updatedAt; - factory Event({String? id, required String name, String? description, bool? status, TemporalDateTime? start, TemporalDateTime? end, String? location, int? points, List? checkins}) { + factory Event({String? id, required String name, String? description, bool? status, bool? requireRSVP, bool? canRSVP, TemporalDateTime? start, TemporalDateTime? end, String? location, int? points, List? checkins}) { return Event._internal( id: id == null ? UUID.getUUID() : id, name: name, description: description, status: status, + requireRSVP: requireRSVP, + canRSVP: canRSVP, start: start, end: end, location: location, @@ -125,6 +137,8 @@ class Event extends Model { _name == other._name && _description == other._description && _status == other._status && + _requireRSVP == other._requireRSVP && + _canRSVP == other._canRSVP && _start == other._start && _end == other._end && _location == other._location && @@ -144,6 +158,8 @@ class Event extends Model { buffer.write("name=" + "$_name" + ", "); buffer.write("description=" + "$_description" + ", "); buffer.write("status=" + (_status != null ? _status!.toString() : "null") + ", "); + buffer.write("requireRSVP=" + (_requireRSVP != null ? _requireRSVP!.toString() : "null") + ", "); + buffer.write("canRSVP=" + (_canRSVP != null ? _canRSVP!.toString() : "null") + ", "); buffer.write("start=" + (_start != null ? _start!.format() : "null") + ", "); buffer.write("end=" + (_end != null ? _end!.format() : "null") + ", "); buffer.write("location=" + "$_location" + ", "); @@ -155,12 +171,14 @@ class Event extends Model { return buffer.toString(); } - Event copyWith({String? id, String? name, String? description, bool? status, TemporalDateTime? start, TemporalDateTime? end, String? location, int? points, List? checkins}) { + Event copyWith({String? id, String? name, String? description, bool? status, bool? requireRSVP, bool? canRSVP, TemporalDateTime? start, TemporalDateTime? end, String? location, int? points, List? checkins}) { return Event._internal( id: id ?? this.id, name: name ?? this.name, description: description ?? this.description, status: status ?? this.status, + requireRSVP: requireRSVP ?? this.requireRSVP, + canRSVP: canRSVP ?? this.canRSVP, start: start ?? this.start, end: end ?? this.end, location: location ?? this.location, @@ -173,6 +191,8 @@ class Event extends Model { _name = json['name'], _description = json['description'], _status = json['status'], + _requireRSVP = json['requireRSVP'], + _canRSVP = json['canRSVP'], _start = json['start'] != null ? TemporalDateTime.fromString(json['start']) : null, _end = json['end'] != null ? TemporalDateTime.fromString(json['end']) : null, _location = json['location'], @@ -187,17 +207,19 @@ class Event extends Model { _updatedAt = json['updatedAt'] != null ? TemporalDateTime.fromString(json['updatedAt']) : null; Map toJson() => { - 'id': id, 'name': _name, 'description': _description, 'status': _status, 'start': _start?.format(), 'end': _end?.format(), 'location': _location, 'points': _points, 'checkins': _checkins?.map((Checkin? e) => e?.toJson()).toList(), 'createdAt': _createdAt?.format(), 'updatedAt': _updatedAt?.format() + 'id': id, 'name': _name, 'description': _description, 'status': _status, 'requireRSVP': _requireRSVP, 'canRSVP': _canRSVP, 'start': _start?.format(), 'end': _end?.format(), 'location': _location, 'points': _points, 'checkins': _checkins?.map((Checkin? e) => e?.toJson()).toList(), 'createdAt': _createdAt?.format(), 'updatedAt': _updatedAt?.format() }; Map toMap() => { - 'id': id, 'name': _name, 'description': _description, 'status': _status, 'start': _start, 'end': _end, 'location': _location, 'points': _points, 'checkins': _checkins, 'createdAt': _createdAt, 'updatedAt': _updatedAt + 'id': id, 'name': _name, 'description': _description, 'status': _status, 'requireRSVP': _requireRSVP, 'canRSVP': _canRSVP, 'start': _start, 'end': _end, 'location': _location, 'points': _points, 'checkins': _checkins, 'createdAt': _createdAt, 'updatedAt': _updatedAt }; static final QueryField ID = QueryField(fieldName: "id"); static final QueryField NAME = QueryField(fieldName: "name"); static final QueryField DESCRIPTION = QueryField(fieldName: "description"); static final QueryField STATUS = QueryField(fieldName: "status"); + static final QueryField REQUIRERSVP = QueryField(fieldName: "requireRSVP"); + static final QueryField CANRSVP = QueryField(fieldName: "canRSVP"); static final QueryField START = QueryField(fieldName: "start"); static final QueryField END = QueryField(fieldName: "end"); static final QueryField LOCATION = QueryField(fieldName: "location"); @@ -248,6 +270,18 @@ class Event extends Model { ofType: ModelFieldType(ModelFieldTypeEnum.bool) )); + modelSchemaDefinition.addField(ModelFieldDefinition.field( + key: Event.REQUIRERSVP, + isRequired: false, + ofType: ModelFieldType(ModelFieldTypeEnum.bool) + )); + + modelSchemaDefinition.addField(ModelFieldDefinition.field( + key: Event.CANRSVP, + isRequired: false, + ofType: ModelFieldType(ModelFieldTypeEnum.bool) + )); + modelSchemaDefinition.addField(ModelFieldDefinition.field( key: Event.START, isRequired: false, diff --git a/lib/models/EventRSVP.dart b/lib/models/EventRSVP.dart new file mode 100644 index 0000000..bebb42a --- /dev/null +++ b/lib/models/EventRSVP.dart @@ -0,0 +1,240 @@ +/* +* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"). +* You may not use this file except in compliance with the License. +* A copy of the License is located at +* +* http://aws.amazon.com/apache2.0 +* +* or in the "license" file accompanying this file. This file is distributed +* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +* express or implied. See the License for the specific language governing +* permissions and limitations under the License. +*/ + +// NOTE: This file is generated and may not follow lint rules defined in your app +// Generated files can be excluded from analysis in analysis_options.yaml +// For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis + +// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously + +import 'package:amplify_core/amplify_core.dart'; +import 'package:flutter/foundation.dart'; + + +/** This is an auto generated class representing the EventRSVP type in your schema. */ +@immutable +class EventRSVP extends Model { + static const classType = const _EventRSVPModelType(); + final String id; + final String? _userID; + final String? _userName; + final String? _eventID; + final TemporalDateTime? _createdAt; + final TemporalDateTime? _updatedAt; + + @override + getInstanceType() => classType; + + @override + String getId() { + return id; + } + + String get userID { + try { + return _userID!; + } catch(e) { + throw new AmplifyCodeGenModelException( + AmplifyExceptionMessages.codeGenRequiredFieldForceCastExceptionMessage, + recoverySuggestion: + AmplifyExceptionMessages.codeGenRequiredFieldForceCastRecoverySuggestion, + underlyingException: e.toString() + ); + } + } + + String get userName { + try { + return _userName!; + } catch(e) { + throw new AmplifyCodeGenModelException( + AmplifyExceptionMessages.codeGenRequiredFieldForceCastExceptionMessage, + recoverySuggestion: + AmplifyExceptionMessages.codeGenRequiredFieldForceCastRecoverySuggestion, + underlyingException: e.toString() + ); + } + } + + String get eventID { + try { + return _eventID!; + } catch(e) { + throw new AmplifyCodeGenModelException( + AmplifyExceptionMessages.codeGenRequiredFieldForceCastExceptionMessage, + recoverySuggestion: + AmplifyExceptionMessages.codeGenRequiredFieldForceCastRecoverySuggestion, + underlyingException: e.toString() + ); + } + } + + TemporalDateTime? get createdAt { + return _createdAt; + } + + TemporalDateTime? get updatedAt { + return _updatedAt; + } + + const EventRSVP._internal({required this.id, required userID, required userName, required eventID, createdAt, updatedAt}): _userID = userID, _userName = userName, _eventID = eventID, _createdAt = createdAt, _updatedAt = updatedAt; + + factory EventRSVP({String? id, required String userID, required String userName, required String eventID}) { + return EventRSVP._internal( + id: id == null ? UUID.getUUID() : id, + userID: userID, + userName: userName, + eventID: eventID); + } + + bool equals(Object other) { + return this == other; + } + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is EventRSVP && + id == other.id && + _userID == other._userID && + _userName == other._userName && + _eventID == other._eventID; + } + + @override + int get hashCode => toString().hashCode; + + @override + String toString() { + var buffer = new StringBuffer(); + + buffer.write("EventRSVP {"); + buffer.write("id=" + "$id" + ", "); + buffer.write("userID=" + "$_userID" + ", "); + buffer.write("userName=" + "$_userName" + ", "); + buffer.write("eventID=" + "$_eventID" + ", "); + buffer.write("createdAt=" + (_createdAt != null ? _createdAt!.format() : "null") + ", "); + buffer.write("updatedAt=" + (_updatedAt != null ? _updatedAt!.format() : "null")); + buffer.write("}"); + + return buffer.toString(); + } + + EventRSVP copyWith({String? id, String? userID, String? userName, String? eventID}) { + return EventRSVP._internal( + id: id ?? this.id, + userID: userID ?? this.userID, + userName: userName ?? this.userName, + eventID: eventID ?? this.eventID); + } + + EventRSVP.fromJson(Map json) + : id = json['id'], + _userID = json['userID'], + _userName = json['userName'], + _eventID = json['eventID'], + _createdAt = json['createdAt'] != null ? TemporalDateTime.fromString(json['createdAt']) : null, + _updatedAt = json['updatedAt'] != null ? TemporalDateTime.fromString(json['updatedAt']) : null; + + Map toJson() => { + 'id': id, 'userID': _userID, 'userName': _userName, 'eventID': _eventID, 'createdAt': _createdAt?.format(), 'updatedAt': _updatedAt?.format() + }; + + Map toMap() => { + 'id': id, 'userID': _userID, 'userName': _userName, 'eventID': _eventID, 'createdAt': _createdAt, 'updatedAt': _updatedAt + }; + + static final QueryField ID = QueryField(fieldName: "id"); + static final QueryField USERID = QueryField(fieldName: "userID"); + static final QueryField USERNAME = QueryField(fieldName: "userName"); + static final QueryField EVENTID = QueryField(fieldName: "eventID"); + static var schema = Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { + modelSchemaDefinition.name = "EventRSVP"; + modelSchemaDefinition.pluralName = "EventRSVPS"; + + modelSchemaDefinition.authRules = [ + AuthRule( + authStrategy: AuthStrategy.GROUPS, + groupClaim: "cognito:groups", + groups: [ "Administrator" ], + provider: AuthRuleProvider.USERPOOLS, + operations: [ + ModelOperation.READ, + ModelOperation.CREATE, + ModelOperation.UPDATE, + ModelOperation.DELETE + ]), + AuthRule( + authStrategy: AuthStrategy.OWNER, + ownerField: "owner", + identityClaim: "cognito:username", + provider: AuthRuleProvider.USERPOOLS, + operations: [ + ModelOperation.READ, + ModelOperation.CREATE, + ModelOperation.UPDATE, + ModelOperation.DELETE + ]) + ]; + + modelSchemaDefinition.addField(ModelFieldDefinition.id()); + + modelSchemaDefinition.addField(ModelFieldDefinition.field( + key: EventRSVP.USERID, + isRequired: true, + ofType: ModelFieldType(ModelFieldTypeEnum.string) + )); + + modelSchemaDefinition.addField(ModelFieldDefinition.field( + key: EventRSVP.USERNAME, + isRequired: true, + ofType: ModelFieldType(ModelFieldTypeEnum.string) + )); + + modelSchemaDefinition.addField(ModelFieldDefinition.field( + key: EventRSVP.EVENTID, + isRequired: true, + ofType: ModelFieldType(ModelFieldTypeEnum.string) + )); + + modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( + fieldName: 'createdAt', + isRequired: false, + isReadOnly: true, + ofType: ModelFieldType(ModelFieldTypeEnum.dateTime) + )); + + modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( + fieldName: 'updatedAt', + isRequired: false, + isReadOnly: true, + ofType: ModelFieldType(ModelFieldTypeEnum.dateTime) + )); + }); +} + +class _EventRSVPModelType extends ModelType { + const _EventRSVPModelType(); + + @override + EventRSVP fromJson(Map jsonData) { + return EventRSVP.fromJson(jsonData); + } + + @override + String modelName() { + return 'EventRSVP'; + } +} \ No newline at end of file diff --git a/lib/models/ModelProvider.dart b/lib/models/ModelProvider.dart index 5e1aee0..613de8a 100644 --- a/lib/models/ModelProvider.dart +++ b/lib/models/ModelProvider.dart @@ -23,6 +23,7 @@ import 'package:amplify_core/amplify_core.dart'; import 'AdminSettings.dart'; import 'Checkin.dart'; import 'Event.dart'; +import 'EventRSVP.dart'; import 'Points.dart'; import 'ScavengerHunt.dart'; import 'ScavengerHuntCheckin.dart'; @@ -30,15 +31,16 @@ import 'ScavengerHuntCheckin.dart'; export 'AdminSettings.dart'; export 'Checkin.dart'; export 'Event.dart'; +export 'EventRSVP.dart'; export 'Points.dart'; export 'ScavengerHunt.dart'; export 'ScavengerHuntCheckin.dart'; class ModelProvider implements ModelProviderInterface { @override - String version = "011fd582fc955d92c04e4469c7437e23"; + String version = "b4aae938e90bcef4c9683ea82285c203"; @override - List modelSchemas = [AdminSettings.schema, Checkin.schema, Event.schema, Points.schema, ScavengerHunt.schema, ScavengerHuntCheckin.schema]; + List modelSchemas = [AdminSettings.schema, Checkin.schema, Event.schema, EventRSVP.schema, Points.schema, ScavengerHunt.schema, ScavengerHuntCheckin.schema]; static final ModelProvider _instance = ModelProvider(); @override List customTypeSchemas = []; @@ -53,6 +55,8 @@ class ModelProvider implements ModelProviderInterface { return Checkin.classType; case "Event": return Event.classType; + case "EventRSVP": + return EventRSVP.classType; case "Points": return Points.classType; case "ScavengerHunt": diff --git a/lib/models/ScavengerHunt.dart b/lib/models/ScavengerHunt.dart index cc4d58c..b4748e0 100644 --- a/lib/models/ScavengerHunt.dart +++ b/lib/models/ScavengerHunt.dart @@ -161,7 +161,7 @@ class ScavengerHunt extends Model { AuthRule( authStrategy: AuthStrategy.GROUPS, groupClaim: "cognito:groups", - groups: [ "Administrator" ], + groups: [ "Administrator", "Scavenger" ], provider: AuthRuleProvider.USERPOOLS, operations: [ ModelOperation.READ, diff --git a/lib/models/ScavengerHuntCheckin.dart b/lib/models/ScavengerHuntCheckin.dart index 7086a86..fd63bad 100644 --- a/lib/models/ScavengerHuntCheckin.dart +++ b/lib/models/ScavengerHuntCheckin.dart @@ -148,7 +148,7 @@ class ScavengerHuntCheckin extends Model { AuthRule( authStrategy: AuthStrategy.GROUPS, groupClaim: "cognito:groups", - groups: [ "Administrator" ], + groups: [ "Administrator", "Scavenger" ], provider: AuthRuleProvider.USERPOOLS, operations: [ ModelOperation.READ, From 6faa00f74b4791927ff55dfcdc023d283afdf191 Mon Sep 17 00:00:00 2001 From: JohnRamberger Date: Wed, 8 Feb 2023 15:28:18 -0500 Subject: [PATCH 2/7] event rsvp checkin --- lib/App.dart | 10 ++-- lib/viewmodel/checkin.viewmodel.dart | 86 ++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 5 deletions(-) diff --git a/lib/App.dart b/lib/App.dart index ca980e7..0ef93a2 100644 --- a/lib/App.dart +++ b/lib/App.dart @@ -1,7 +1,7 @@ // amplify packages import 'package:amplify_auth_cognito/amplify_auth_cognito.dart'; import 'package:amplify_authenticator/amplify_authenticator.dart'; -// import 'package:amplify_datastore/amplify_datastore.dart'; +import 'package:amplify_datastore/amplify_datastore.dart'; import 'package:amplify_flutter/amplify_flutter.dart'; import 'package:amplify_api/amplify_api.dart'; import 'package:hacklytics_checkin_flutter/models/ModelProvider.dart'; @@ -35,10 +35,10 @@ class _MyAppState extends State { await Amplify.addPlugin( AmplifyAPI(modelProvider: ModelProvider.instance)); - // var dataPlugin = AmplifyDataStore( - // modelProvider: ModelProvider.instance, - // authModeStrategy: AuthModeStrategy.multiAuth); - // await Amplify.addPlugin(dataPlugin); + var dataPlugin = AmplifyDataStore( + modelProvider: ModelProvider.instance, + authModeStrategy: AuthModeStrategy.multiAuth); + await Amplify.addPlugin(dataPlugin); await Amplify.configure(amplifyconfig); } on Exception catch (e) { diff --git a/lib/viewmodel/checkin.viewmodel.dart b/lib/viewmodel/checkin.viewmodel.dart index f6f1386..d0ed00b 100644 --- a/lib/viewmodel/checkin.viewmodel.dart +++ b/lib/viewmodel/checkin.viewmodel.dart @@ -115,6 +115,61 @@ class CheckinViewModel extends ChangeNotifier { return; } + // check for rsvp + if (event.requireRSVP == true) { + // check if user has rsvp'd + var rsvps = await Amplify.DataStore.query(EventRSVP.classType, + where: EventRSVP.EVENTID + .eq(event.id) + .and(EventRSVP.USERID.eq(_user.username))); + + if (rsvps.isEmpty) { + // user has not rsvp'd + _error = "User has not RSVP'd to this event"; + _loadingUser = false; + if (_mounted) notifyListeners(); + return; + } + + // _loadingUser = false; + // if (_mounted) notifyListeners(); + // return; + // var request = ModelQueries.list(EventRSVP.classType, where: ) + + // var request = GraphQLRequest(document: ''' + // query queryRSVPs { + // listEventRSVPS(filter: {and: {userID: {eq: "${_user.username}"}, eventID: {eq: "${event.id}"}}}) { + // items { + // id + // eventID + // userName + // userID + // deleted:_deleted + // } + // } + // } + // '''); + + // var operation = Amplify.API.query(request: request); + // var response = await operation.response; + // if (response.errors.isNotEmpty) { + // _error = response.errors[0].message; + // _loadingUser = false; + // if (_mounted) notifyListeners(); + // return; + // } + // var data = response.data; + // var res = responseGetRsvp(data, event); + + // if (!res.rsvped) { + // // user is not rsvp'd + // _error = "User is not RSVP'd to this event"; + // _loadingUser = false; + // if (_mounted) notifyListeners(); + // return; + // } + } + String currentUserName = currentUser.attributes .where((a) => a.userAttributeKey.key == "name") .first @@ -286,3 +341,34 @@ class responseGetCheckins { } } } + +// class responseGetRsvp { +// late bool rsvped = false; +// late String error = ""; +// responseGetRsvp(String data, Event event) { +// // print(data); +// var json = jsonDecode(data); +// var rsvps = json['listEventRSVPS']['items']; +// print(rsvps); +// if (rsvps == null || rsvps.isEmpty) { +// // user is not rsvped in +// return; +// } else { +// for (var rsvp in rsvps) { +// if (rsvp['deleted'] == false) { +// // user is rsvped in +// rsvped = true; +// return; +// } +// } +// } +// // // check if event matches +// // for (var checkin in checkins) { +// // if (checkin['event']['id'] == event.id) { +// // // user is checked in +// // checkedIn = true; +// // return; +// // } +// // } +// } +// } From 02aef51be24c22a8c3c2764c20d10bea8bbbcd2f Mon Sep 17 00:00:00 2001 From: JohnRamberger Date: Wed, 8 Feb 2023 15:30:50 -0500 Subject: [PATCH 3/7] Update EventCard.component.dart --- lib/components/EventCard.component.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/components/EventCard.component.dart b/lib/components/EventCard.component.dart index 514d5d2..15db670 100644 --- a/lib/components/EventCard.component.dart +++ b/lib/components/EventCard.component.dart @@ -44,6 +44,8 @@ class EventCard extends StatelessWidget { _buildListTileDate("End", event.end), // const Divider(), _buildListTileStatus("Status", event.status), + _buildListTileStatus("Requires RSVP", event.requireRSVP, + greenText: "Yes", redText: "No"), ]); } @@ -56,12 +58,17 @@ class EventCard extends StatelessWidget { ); } - _buildListTileStatus(String title, bool? status) { + _buildListTileStatus( + String title, + bool? status, { + greenText = "Open", + redText = "Closed", + }) { return ListTile( title: Text(title), subtitle: status != null && status == true - ? _buildGreenText("Open") - : _buildRedText("Closed"), + ? _buildGreenText(greenText) + : _buildRedText(redText), ); } From 8f9cb01ce0a17e140515d3ec450a6ba617c69152 Mon Sep 17 00:00:00 2001 From: JohnRamberger Date: Wed, 8 Feb 2023 15:36:32 -0500 Subject: [PATCH 4/7] date formatting --- lib/components/EventCard.component.dart | 3 ++- lib/view/CheckinUserList.view.dart | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/components/EventCard.component.dart b/lib/components/EventCard.component.dart index 15db670..42e2017 100644 --- a/lib/components/EventCard.component.dart +++ b/lib/components/EventCard.component.dart @@ -73,7 +73,8 @@ class EventCard extends StatelessWidget { } _buildListTileDate(String title, TemporalDateTime? date) { - final DateFormat formatter = DateFormat('MMM d, yyyy h:mm a'); + final DateFormat formatter = DateFormat('EEEEE h:mm a'); + // final DateFormat formatter = DateFormat('MMM d, yyyy h:mm a'); // format date // String formattedDate = // date != null ? formatter.format(date as DateTime) : ""; diff --git a/lib/view/CheckinUserList.view.dart b/lib/view/CheckinUserList.view.dart index 1b1b70c..921e8bf 100644 --- a/lib/view/CheckinUserList.view.dart +++ b/lib/view/CheckinUserList.view.dart @@ -198,7 +198,8 @@ class FakeCheckin { } _loadDateString() { - final DateFormat formatter = DateFormat('MMM d, yyyy h:mm a'); + // final DateFormat formatter = DateFormat('MMM d, yyyy h:mm a'); + final DateFormat formatter = DateFormat('EEEEE h:mm a'); createdAtString = formatter.format(createdAt); } } From 0f17cc45eb597a9965794191573e7e5465d2b0ea Mon Sep 17 00:00:00 2001 From: JohnRamberger Date: Wed, 8 Feb 2023 16:14:09 -0500 Subject: [PATCH 5/7] backend --- .../hacklyticsportal2023listusers/src/index.js | 10 +++++++++- .../hacklyticsportal2023listusers/src/yarn.lock | 9 ++------- amplify/team-provider-info.json | 6 +++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/amplify/backend/function/hacklyticsportal2023listusers/src/index.js b/amplify/backend/function/hacklyticsportal2023listusers/src/index.js index 77098f9..b925ad7 100644 --- a/amplify/backend/function/hacklyticsportal2023listusers/src/index.js +++ b/amplify/backend/function/hacklyticsportal2023listusers/src/index.js @@ -34,6 +34,14 @@ exports.handler = async (event) => { }); var users = x.Users; if (users.length > 0) { + users = users.map((user) => { + return { + username: user.Username, + email: user.Attributes.find((attr) => attr.Name === "email").Value, + name: user.Attributes.find((attr) => attr.Name === "name").Value, + enabled: user.Enabled, + }; + }); return JSON.stringify({ statusCode: 200, // Uncomment below to enable CORS requests @@ -41,7 +49,7 @@ exports.handler = async (event) => { // "Access-Control-Allow-Origin": "*", // "Access-Control-Allow-Headers": "*" // }, - body: { ok: 1, users: users }, + body: { ok: 1, userCount: users.length, users: users }, }); } else { return JSON.stringify({ diff --git a/amplify/backend/function/hacklyticsportal2023listusers/src/yarn.lock b/amplify/backend/function/hacklyticsportal2023listusers/src/yarn.lock index 4d5ef4e..35d06e2 100644 --- a/amplify/backend/function/hacklyticsportal2023listusers/src/yarn.lock +++ b/amplify/backend/function/hacklyticsportal2023listusers/src/yarn.lock @@ -2,11 +2,6 @@ # yarn lockfile v1 -"@types/aws-lambda@^8.10.92": - version "8.10.110" - resolved "https://registry.yarnpkg.com/@types/aws-lambda/-/aws-lambda-8.10.110.tgz#32a1f9d40b855d69830243492bbb6408098f4c88" - integrity sha512-r6egf2Cwv/JaFTTrF9OXFVUB3j/SXTgM9BwrlbBRjWAa2Tu6GWoDoLflppAZ8uSfbUJdXvC7Br3DjuN9pQ2NUQ== - available-typed-arrays@^1.0.5: version "1.0.5" resolved "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz" @@ -102,7 +97,7 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" -ieee754@1.1.13, ieee754@^1.1.4: +ieee754@^1.1.4, ieee754@1.1.13: version "1.1.13" resolved "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz" integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg== @@ -163,7 +158,7 @@ querystring@0.2.0: resolved "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz" integrity sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g== -sax@1.2.1, sax@>=0.6.0: +sax@>=0.6.0, sax@1.2.1: version "1.2.1" resolved "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz" integrity sha512-8I2a3LovHTOpm7NV5yOyO8IHqgVsfK4+UuySrXU8YXkSRX7k6hCV9b3HrkKCr3nMpgj+0bmocaJJWpvp1oc7ZA== diff --git a/amplify/team-provider-info.json b/amplify/team-provider-info.json index 0439bf9..38912a2 100644 --- a/amplify/team-provider-info.json +++ b/amplify/team-provider-info.json @@ -21,11 +21,11 @@ "function": { "hacklyticsportal20232e32fd51": { "deploymentBucketName": "amplify-hacklyticsportal2023-prod-221126-deployment", - "s3Key": "amplify-builds/hacklyticsportal20232e32fd51-70577737482b35743137-build.zip" + "s3Key": "amplify-builds/hacklyticsportal20232e32fd51-7769506364764973302b-build.zip" }, "hacklyticsportal2023listusers": { "deploymentBucketName": "amplify-hacklyticsportal2023-prod-221126-deployment", - "s3Key": "amplify-builds/hacklyticsportal2023listusers-434a3932506667747356-build.zip" + "s3Key": "amplify-builds/hacklyticsportal2023listusers-646e39457a3579306641-build.zip" } }, "api": { @@ -62,7 +62,7 @@ }, "hacklyticsportal2023listusers": { "deploymentBucketName": "amplify-amplify0f0acd1e2a0b4-staging-14346-deployment", - "s3Key": "amplify-builds/hacklyticsportal2023listusers-3768654f6b65734e6168-build.zip" + "s3Key": "amplify-builds/hacklyticsportal2023listusers-646e39457a3579306641-build.zip" } } } From d050e06ed11937553e01d94ce006e551e402be79 Mon Sep 17 00:00:00 2001 From: JohnRamberger Date: Wed, 8 Feb 2023 16:14:51 -0500 Subject: [PATCH 6/7] v2 user --- lib/model/user.dart | 8 ++++++++ lib/view/userlist.view.dart | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/model/user.dart b/lib/model/user.dart index c47dc2e..baee80e 100644 --- a/lib/model/user.dart +++ b/lib/model/user.dart @@ -45,6 +45,14 @@ class User { } } } + User.v2(userData) { + username = userData['username']; + censoredUsername = + '${username.substring(0, usernameCensorLength)}...${username.substring(username.length - usernameCensorLength)}'; + attributes['name'] = userData['name']; + attributes['email'] = userData['email']; + enabled = userData['enabled']; + } @override String toString() { diff --git a/lib/view/userlist.view.dart b/lib/view/userlist.view.dart index 1bae5ab..6c8457b 100644 --- a/lib/view/userlist.view.dart +++ b/lib/view/userlist.view.dart @@ -143,7 +143,7 @@ class ResponseListUsers { List usersStr = body['users']; for (var userStr in usersStr) { - User user = User(userStr); + User user = User.v2(userStr); users.add(user); } } else { From cd4e83930cc47843bfda670108c813114a80569a Mon Sep 17 00:00:00 2001 From: JohnRamberger Date: Wed, 8 Feb 2023 16:17:02 -0500 Subject: [PATCH 7/7] Update pubspec.yaml --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index b476bc3..6eef66c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.35 +version: 1.0.36 environment: sdk: '>=2.18.5 <3.0.0'