registration and login ready, with some validations

This commit is contained in:
José Salazar
2026-01-26 10:48:33 -05:00
parent 7bd276269b
commit 0ba5a9ae16
23 changed files with 21278 additions and 21055 deletions

View File

@@ -24,3 +24,4 @@ export 'src/session/client_session_store.dart';
// Export the generated Data Connect SDK // Export the generated Data Connect SDK
export 'src/dataconnect_generated/generated.dart'; export 'src/dataconnect_generated/generated.dart';
export 'src/session/staff_session_store.dart';

View File

@@ -1,16 +1,16 @@
# Basic Usage # Basic Usage
```dart ```dart
ExampleConnector.instance.createTeamMember(createTeamMemberVariables).execute(); ExampleConnector.instance.CreateUser(createUserVariables).execute();
ExampleConnector.instance.updateTeamMember(updateTeamMemberVariables).execute(); ExampleConnector.instance.UpdateUser(updateUserVariables).execute();
ExampleConnector.instance.updateTeamMemberInviteStatus(updateTeamMemberInviteStatusVariables).execute(); ExampleConnector.instance.DeleteUser(deleteUserVariables).execute();
ExampleConnector.instance.acceptInviteByCode(acceptInviteByCodeVariables).execute(); ExampleConnector.instance.listVendorRates().execute();
ExampleConnector.instance.cancelInviteByCode(cancelInviteByCodeVariables).execute(); ExampleConnector.instance.getVendorRateById(getVendorRateByIdVariables).execute();
ExampleConnector.instance.deleteTeamMember(deleteTeamMemberVariables).execute(); ExampleConnector.instance.listApplications().execute();
ExampleConnector.instance.listActivityLogs(listActivityLogsVariables).execute(); ExampleConnector.instance.getApplicationById(getApplicationByIdVariables).execute();
ExampleConnector.instance.getActivityLogById(getActivityLogByIdVariables).execute(); ExampleConnector.instance.getApplicationsByShiftId(getApplicationsByShiftIdVariables).execute();
ExampleConnector.instance.listActivityLogsByUserId(listActivityLogsByUserIdVariables).execute(); ExampleConnector.instance.getApplicationsByShiftIdAndStatus(getApplicationsByShiftIdAndStatusVariables).execute();
ExampleConnector.instance.listUnreadActivityLogsByUserId(listUnreadActivityLogsByUserIdVariables).execute(); ExampleConnector.instance.getApplicationsByStaffId(getApplicationsByStaffIdVariables).execute();
``` ```
@@ -23,7 +23,7 @@ Optional fields can be discovered based on classes that have `Optional` object t
This is an example of a mutation with an optional field: This is an example of a mutation with an optional field:
```dart ```dart
await ExampleConnector.instance.getRapidOrders({ ... }) await ExampleConnector.instance.listStaffAvailabilitiesByDay({ ... })
.offset(...) .offset(...)
.execute(); .execute();
``` ```

View File

@@ -15,6 +15,7 @@ class CreateStaffVariablesBuilder {
Optional<int> _cancellationCount = Optional.optional(nativeFromJson, nativeToJson); Optional<int> _cancellationCount = Optional.optional(nativeFromJson, nativeToJson);
Optional<int> _reliabilityScore = Optional.optional(nativeFromJson, nativeToJson); Optional<int> _reliabilityScore = Optional.optional(nativeFromJson, nativeToJson);
Optional<String> _bio = Optional.optional(nativeFromJson, nativeToJson); Optional<String> _bio = Optional.optional(nativeFromJson, nativeToJson);
Optional<AnyValue> _skills = Optional.optional(AnyValue.fromJson, defaultSerializer);
Optional<AnyValue> _industries = Optional.optional(AnyValue.fromJson, defaultSerializer); Optional<AnyValue> _industries = Optional.optional(AnyValue.fromJson, defaultSerializer);
Optional<AnyValue> _preferredLocations = Optional.optional(AnyValue.fromJson, defaultSerializer); Optional<AnyValue> _preferredLocations = Optional.optional(AnyValue.fromJson, defaultSerializer);
Optional<int> _maxDistanceMiles = Optional.optional(nativeFromJson, nativeToJson); Optional<int> _maxDistanceMiles = Optional.optional(nativeFromJson, nativeToJson);
@@ -83,6 +84,10 @@ class CreateStaffVariablesBuilder {
_bio.value = t; _bio.value = t;
return this; return this;
} }
CreateStaffVariablesBuilder skills(AnyValue? t) {
_skills.value = t;
return this;
}
CreateStaffVariablesBuilder industries(AnyValue? t) { CreateStaffVariablesBuilder industries(AnyValue? t) {
_industries.value = t; _industries.value = t;
return this; return this;
@@ -168,7 +173,7 @@ class CreateStaffVariablesBuilder {
} }
MutationRef<CreateStaffData, CreateStaffVariables> ref() { MutationRef<CreateStaffData, CreateStaffVariables> ref() {
CreateStaffVariables vars= CreateStaffVariables(userId: userId,fullName: fullName,level: _level,role: _role,phone: _phone,email: _email,photoUrl: _photoUrl,totalShifts: _totalShifts,averageRating: _averageRating,onTimeRate: _onTimeRate,noShowCount: _noShowCount,cancellationCount: _cancellationCount,reliabilityScore: _reliabilityScore,bio: _bio,industries: _industries,preferredLocations: _preferredLocations,maxDistanceMiles: _maxDistanceMiles,languages: _languages,itemsAttire: _itemsAttire,xp: _xp,badges: _badges,isRecommended: _isRecommended,ownerId: _ownerId,department: _department,hubId: _hubId,manager: _manager,english: _english,backgroundCheckStatus: _backgroundCheckStatus,employmentType: _employmentType,initial: _initial,englishRequired: _englishRequired,city: _city,addres: _addres,); CreateStaffVariables vars= CreateStaffVariables(userId: userId,fullName: fullName,level: _level,role: _role,phone: _phone,email: _email,photoUrl: _photoUrl,totalShifts: _totalShifts,averageRating: _averageRating,onTimeRate: _onTimeRate,noShowCount: _noShowCount,cancellationCount: _cancellationCount,reliabilityScore: _reliabilityScore,bio: _bio,skills: _skills,industries: _industries,preferredLocations: _preferredLocations,maxDistanceMiles: _maxDistanceMiles,languages: _languages,itemsAttire: _itemsAttire,xp: _xp,badges: _badges,isRecommended: _isRecommended,ownerId: _ownerId,department: _department,hubId: _hubId,manager: _manager,english: _english,backgroundCheckStatus: _backgroundCheckStatus,employmentType: _employmentType,initial: _initial,englishRequired: _englishRequired,city: _city,addres: _addres,);
return _dataConnect.mutation("CreateStaff", dataDeserializer, varsSerializer, vars); return _dataConnect.mutation("CreateStaff", dataDeserializer, varsSerializer, vars);
} }
} }
@@ -257,6 +262,7 @@ class CreateStaffVariables {
late final Optional<int>cancellationCount; late final Optional<int>cancellationCount;
late final Optional<int>reliabilityScore; late final Optional<int>reliabilityScore;
late final Optional<String>bio; late final Optional<String>bio;
late final Optional<AnyValue>skills;
late final Optional<AnyValue>industries; late final Optional<AnyValue>industries;
late final Optional<AnyValue>preferredLocations; late final Optional<AnyValue>preferredLocations;
late final Optional<int>maxDistanceMiles; late final Optional<int>maxDistanceMiles;
@@ -333,6 +339,10 @@ class CreateStaffVariables {
bio.value = json['bio'] == null ? null : nativeFromJson<String>(json['bio']); bio.value = json['bio'] == null ? null : nativeFromJson<String>(json['bio']);
skills = Optional.optional(AnyValue.fromJson, defaultSerializer);
skills.value = json['skills'] == null ? null : AnyValue.fromJson(json['skills']);
industries = Optional.optional(AnyValue.fromJson, defaultSerializer); industries = Optional.optional(AnyValue.fromJson, defaultSerializer);
industries.value = json['industries'] == null ? null : AnyValue.fromJson(json['industries']); industries.value = json['industries'] == null ? null : AnyValue.fromJson(json['industries']);
@@ -433,6 +443,7 @@ class CreateStaffVariables {
cancellationCount == otherTyped.cancellationCount && cancellationCount == otherTyped.cancellationCount &&
reliabilityScore == otherTyped.reliabilityScore && reliabilityScore == otherTyped.reliabilityScore &&
bio == otherTyped.bio && bio == otherTyped.bio &&
skills == otherTyped.skills &&
industries == otherTyped.industries && industries == otherTyped.industries &&
preferredLocations == otherTyped.preferredLocations && preferredLocations == otherTyped.preferredLocations &&
maxDistanceMiles == otherTyped.maxDistanceMiles && maxDistanceMiles == otherTyped.maxDistanceMiles &&
@@ -455,7 +466,7 @@ class CreateStaffVariables {
} }
@override @override
int get hashCode => Object.hashAll([userId.hashCode, fullName.hashCode, level.hashCode, role.hashCode, phone.hashCode, email.hashCode, photoUrl.hashCode, totalShifts.hashCode, averageRating.hashCode, onTimeRate.hashCode, noShowCount.hashCode, cancellationCount.hashCode, reliabilityScore.hashCode, bio.hashCode, industries.hashCode, preferredLocations.hashCode, maxDistanceMiles.hashCode, languages.hashCode, itemsAttire.hashCode, xp.hashCode, badges.hashCode, isRecommended.hashCode, ownerId.hashCode, department.hashCode, hubId.hashCode, manager.hashCode, english.hashCode, backgroundCheckStatus.hashCode, employmentType.hashCode, initial.hashCode, englishRequired.hashCode, city.hashCode, addres.hashCode]); int get hashCode => Object.hashAll([userId.hashCode, fullName.hashCode, level.hashCode, role.hashCode, phone.hashCode, email.hashCode, photoUrl.hashCode, totalShifts.hashCode, averageRating.hashCode, onTimeRate.hashCode, noShowCount.hashCode, cancellationCount.hashCode, reliabilityScore.hashCode, bio.hashCode, skills.hashCode, industries.hashCode, preferredLocations.hashCode, maxDistanceMiles.hashCode, languages.hashCode, itemsAttire.hashCode, xp.hashCode, badges.hashCode, isRecommended.hashCode, ownerId.hashCode, department.hashCode, hubId.hashCode, manager.hashCode, english.hashCode, backgroundCheckStatus.hashCode, employmentType.hashCode, initial.hashCode, englishRequired.hashCode, city.hashCode, addres.hashCode]);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -498,6 +509,9 @@ class CreateStaffVariables {
if(bio.state == OptionalState.set) { if(bio.state == OptionalState.set) {
json['bio'] = bio.toJson(); json['bio'] = bio.toJson();
} }
if(skills.state == OptionalState.set) {
json['skills'] = skills.toJson();
}
if(industries.state == OptionalState.set) { if(industries.state == OptionalState.set) {
json['industries'] = industries.toJson(); json['industries'] = industries.toJson();
} }
@@ -573,6 +587,7 @@ class CreateStaffVariables {
required this.cancellationCount, required this.cancellationCount,
required this.reliabilityScore, required this.reliabilityScore,
required this.bio, required this.bio,
required this.skills,
required this.industries, required this.industries,
required this.preferredLocations, required this.preferredLocations,
required this.maxDistanceMiles, required this.maxDistanceMiles,

View File

@@ -51,6 +51,7 @@ class FilterStaffStaffs {
final int? totalShifts; final int? totalShifts;
final String? ownerId; final String? ownerId;
final bool? isRecommended; final bool? isRecommended;
final AnyValue? skills;
final EnumValue<BackgroundCheckStatus>? backgroundCheckStatus; final EnumValue<BackgroundCheckStatus>? backgroundCheckStatus;
final EnumValue<EmploymentType>? employmentType; final EnumValue<EmploymentType>? employmentType;
final String? initial; final String? initial;
@@ -71,6 +72,7 @@ class FilterStaffStaffs {
totalShifts = json['totalShifts'] == null ? null : nativeFromJson<int>(json['totalShifts']), totalShifts = json['totalShifts'] == null ? null : nativeFromJson<int>(json['totalShifts']),
ownerId = json['ownerId'] == null ? null : nativeFromJson<String>(json['ownerId']), ownerId = json['ownerId'] == null ? null : nativeFromJson<String>(json['ownerId']),
isRecommended = json['isRecommended'] == null ? null : nativeFromJson<bool>(json['isRecommended']), isRecommended = json['isRecommended'] == null ? null : nativeFromJson<bool>(json['isRecommended']),
skills = json['skills'] == null ? null : AnyValue.fromJson(json['skills']),
backgroundCheckStatus = json['backgroundCheckStatus'] == null ? null : backgroundCheckStatusDeserializer(json['backgroundCheckStatus']), backgroundCheckStatus = json['backgroundCheckStatus'] == null ? null : backgroundCheckStatusDeserializer(json['backgroundCheckStatus']),
employmentType = json['employmentType'] == null ? null : employmentTypeDeserializer(json['employmentType']), employmentType = json['employmentType'] == null ? null : employmentTypeDeserializer(json['employmentType']),
initial = json['initial'] == null ? null : nativeFromJson<String>(json['initial']), initial = json['initial'] == null ? null : nativeFromJson<String>(json['initial']),
@@ -99,6 +101,7 @@ class FilterStaffStaffs {
totalShifts == otherTyped.totalShifts && totalShifts == otherTyped.totalShifts &&
ownerId == otherTyped.ownerId && ownerId == otherTyped.ownerId &&
isRecommended == otherTyped.isRecommended && isRecommended == otherTyped.isRecommended &&
skills == otherTyped.skills &&
backgroundCheckStatus == otherTyped.backgroundCheckStatus && backgroundCheckStatus == otherTyped.backgroundCheckStatus &&
employmentType == otherTyped.employmentType && employmentType == otherTyped.employmentType &&
initial == otherTyped.initial && initial == otherTyped.initial &&
@@ -108,7 +111,7 @@ class FilterStaffStaffs {
} }
@override @override
int get hashCode => Object.hashAll([id.hashCode, userId.hashCode, fullName.hashCode, level.hashCode, phone.hashCode, email.hashCode, photoUrl.hashCode, averageRating.hashCode, reliabilityScore.hashCode, totalShifts.hashCode, ownerId.hashCode, isRecommended.hashCode, backgroundCheckStatus.hashCode, employmentType.hashCode, initial.hashCode, englishRequired.hashCode, city.hashCode, addres.hashCode]); int get hashCode => Object.hashAll([id.hashCode, userId.hashCode, fullName.hashCode, level.hashCode, phone.hashCode, email.hashCode, photoUrl.hashCode, averageRating.hashCode, reliabilityScore.hashCode, totalShifts.hashCode, ownerId.hashCode, isRecommended.hashCode, skills.hashCode, backgroundCheckStatus.hashCode, employmentType.hashCode, initial.hashCode, englishRequired.hashCode, city.hashCode, addres.hashCode]);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -143,6 +146,9 @@ class FilterStaffStaffs {
if (isRecommended != null) { if (isRecommended != null) {
json['isRecommended'] = nativeToJson<bool?>(isRecommended); json['isRecommended'] = nativeToJson<bool?>(isRecommended);
} }
if (skills != null) {
json['skills'] = skills!.toJson();
}
if (backgroundCheckStatus != null) { if (backgroundCheckStatus != null) {
json['backgroundCheckStatus'] = json['backgroundCheckStatus'] =
backgroundCheckStatusSerializer(backgroundCheckStatus!) backgroundCheckStatusSerializer(backgroundCheckStatus!)
@@ -181,6 +187,7 @@ class FilterStaffStaffs {
this.totalShifts, this.totalShifts,
this.ownerId, this.ownerId,
this.isRecommended, this.isRecommended,
this.skills,
this.backgroundCheckStatus, this.backgroundCheckStatus,
this.employmentType, this.employmentType,
this.initial, this.initial,

View File

@@ -37,6 +37,7 @@ class GetStaffByIdStaff {
final AnyValue? badges; final AnyValue? badges;
final bool? isRecommended; final bool? isRecommended;
final String? bio; final String? bio;
final AnyValue? skills;
final AnyValue? industries; final AnyValue? industries;
final AnyValue? preferredLocations; final AnyValue? preferredLocations;
final int? maxDistanceMiles; final int? maxDistanceMiles;
@@ -76,6 +77,7 @@ class GetStaffByIdStaff {
badges = json['badges'] == null ? null : AnyValue.fromJson(json['badges']), badges = json['badges'] == null ? null : AnyValue.fromJson(json['badges']),
isRecommended = json['isRecommended'] == null ? null : nativeFromJson<bool>(json['isRecommended']), isRecommended = json['isRecommended'] == null ? null : nativeFromJson<bool>(json['isRecommended']),
bio = json['bio'] == null ? null : nativeFromJson<String>(json['bio']), bio = json['bio'] == null ? null : nativeFromJson<String>(json['bio']),
skills = json['skills'] == null ? null : AnyValue.fromJson(json['skills']),
industries = json['industries'] == null ? null : AnyValue.fromJson(json['industries']), industries = json['industries'] == null ? null : AnyValue.fromJson(json['industries']),
preferredLocations = json['preferredLocations'] == null ? null : AnyValue.fromJson(json['preferredLocations']), preferredLocations = json['preferredLocations'] == null ? null : AnyValue.fromJson(json['preferredLocations']),
maxDistanceMiles = json['maxDistanceMiles'] == null ? null : nativeFromJson<int>(json['maxDistanceMiles']), maxDistanceMiles = json['maxDistanceMiles'] == null ? null : nativeFromJson<int>(json['maxDistanceMiles']),
@@ -123,6 +125,7 @@ class GetStaffByIdStaff {
badges == otherTyped.badges && badges == otherTyped.badges &&
isRecommended == otherTyped.isRecommended && isRecommended == otherTyped.isRecommended &&
bio == otherTyped.bio && bio == otherTyped.bio &&
skills == otherTyped.skills &&
industries == otherTyped.industries && industries == otherTyped.industries &&
preferredLocations == otherTyped.preferredLocations && preferredLocations == otherTyped.preferredLocations &&
maxDistanceMiles == otherTyped.maxDistanceMiles && maxDistanceMiles == otherTyped.maxDistanceMiles &&
@@ -145,7 +148,7 @@ class GetStaffByIdStaff {
} }
@override @override
int get hashCode => Object.hashAll([id.hashCode, userId.hashCode, fullName.hashCode, role.hashCode, level.hashCode, phone.hashCode, email.hashCode, photoUrl.hashCode, totalShifts.hashCode, averageRating.hashCode, onTimeRate.hashCode, noShowCount.hashCode, cancellationCount.hashCode, reliabilityScore.hashCode, xp.hashCode, badges.hashCode, isRecommended.hashCode, bio.hashCode, industries.hashCode, preferredLocations.hashCode, maxDistanceMiles.hashCode, languages.hashCode, itemsAttire.hashCode, ownerId.hashCode, createdAt.hashCode, updatedAt.hashCode, createdBy.hashCode, department.hashCode, hubId.hashCode, manager.hashCode, english.hashCode, backgroundCheckStatus.hashCode, employmentType.hashCode, initial.hashCode, englishRequired.hashCode, city.hashCode, addres.hashCode]); int get hashCode => Object.hashAll([id.hashCode, userId.hashCode, fullName.hashCode, role.hashCode, level.hashCode, phone.hashCode, email.hashCode, photoUrl.hashCode, totalShifts.hashCode, averageRating.hashCode, onTimeRate.hashCode, noShowCount.hashCode, cancellationCount.hashCode, reliabilityScore.hashCode, xp.hashCode, badges.hashCode, isRecommended.hashCode, bio.hashCode, skills.hashCode, industries.hashCode, preferredLocations.hashCode, maxDistanceMiles.hashCode, languages.hashCode, itemsAttire.hashCode, ownerId.hashCode, createdAt.hashCode, updatedAt.hashCode, createdBy.hashCode, department.hashCode, hubId.hashCode, manager.hashCode, english.hashCode, backgroundCheckStatus.hashCode, employmentType.hashCode, initial.hashCode, englishRequired.hashCode, city.hashCode, addres.hashCode]);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -198,6 +201,9 @@ class GetStaffByIdStaff {
if (bio != null) { if (bio != null) {
json['bio'] = nativeToJson<String?>(bio); json['bio'] = nativeToJson<String?>(bio);
} }
if (skills != null) {
json['skills'] = skills!.toJson();
}
if (industries != null) { if (industries != null) {
json['industries'] = industries!.toJson(); json['industries'] = industries!.toJson();
} }
@@ -285,6 +291,7 @@ class GetStaffByIdStaff {
this.badges, this.badges,
this.isRecommended, this.isRecommended,
this.bio, this.bio,
this.skills,
this.industries, this.industries,
this.preferredLocations, this.preferredLocations,
this.maxDistanceMiles, this.maxDistanceMiles,

View File

@@ -36,6 +36,7 @@ class GetStaffByUserIdStaffs {
final AnyValue? badges; final AnyValue? badges;
final bool? isRecommended; final bool? isRecommended;
final String? bio; final String? bio;
final AnyValue? skills;
final AnyValue? industries; final AnyValue? industries;
final AnyValue? preferredLocations; final AnyValue? preferredLocations;
final int? maxDistanceMiles; final int? maxDistanceMiles;
@@ -74,6 +75,7 @@ class GetStaffByUserIdStaffs {
badges = json['badges'] == null ? null : AnyValue.fromJson(json['badges']), badges = json['badges'] == null ? null : AnyValue.fromJson(json['badges']),
isRecommended = json['isRecommended'] == null ? null : nativeFromJson<bool>(json['isRecommended']), isRecommended = json['isRecommended'] == null ? null : nativeFromJson<bool>(json['isRecommended']),
bio = json['bio'] == null ? null : nativeFromJson<String>(json['bio']), bio = json['bio'] == null ? null : nativeFromJson<String>(json['bio']),
skills = json['skills'] == null ? null : AnyValue.fromJson(json['skills']),
industries = json['industries'] == null ? null : AnyValue.fromJson(json['industries']), industries = json['industries'] == null ? null : AnyValue.fromJson(json['industries']),
preferredLocations = json['preferredLocations'] == null ? null : AnyValue.fromJson(json['preferredLocations']), preferredLocations = json['preferredLocations'] == null ? null : AnyValue.fromJson(json['preferredLocations']),
maxDistanceMiles = json['maxDistanceMiles'] == null ? null : nativeFromJson<int>(json['maxDistanceMiles']), maxDistanceMiles = json['maxDistanceMiles'] == null ? null : nativeFromJson<int>(json['maxDistanceMiles']),
@@ -120,6 +122,7 @@ class GetStaffByUserIdStaffs {
badges == otherTyped.badges && badges == otherTyped.badges &&
isRecommended == otherTyped.isRecommended && isRecommended == otherTyped.isRecommended &&
bio == otherTyped.bio && bio == otherTyped.bio &&
skills == otherTyped.skills &&
industries == otherTyped.industries && industries == otherTyped.industries &&
preferredLocations == otherTyped.preferredLocations && preferredLocations == otherTyped.preferredLocations &&
maxDistanceMiles == otherTyped.maxDistanceMiles && maxDistanceMiles == otherTyped.maxDistanceMiles &&
@@ -142,7 +145,7 @@ class GetStaffByUserIdStaffs {
} }
@override @override
int get hashCode => Object.hashAll([id.hashCode, userId.hashCode, fullName.hashCode, level.hashCode, phone.hashCode, email.hashCode, photoUrl.hashCode, totalShifts.hashCode, averageRating.hashCode, onTimeRate.hashCode, noShowCount.hashCode, cancellationCount.hashCode, reliabilityScore.hashCode, xp.hashCode, badges.hashCode, isRecommended.hashCode, bio.hashCode, industries.hashCode, preferredLocations.hashCode, maxDistanceMiles.hashCode, languages.hashCode, itemsAttire.hashCode, ownerId.hashCode, createdAt.hashCode, updatedAt.hashCode, createdBy.hashCode, department.hashCode, hubId.hashCode, manager.hashCode, english.hashCode, backgroundCheckStatus.hashCode, employmentType.hashCode, initial.hashCode, englishRequired.hashCode, city.hashCode, addres.hashCode]); int get hashCode => Object.hashAll([id.hashCode, userId.hashCode, fullName.hashCode, level.hashCode, phone.hashCode, email.hashCode, photoUrl.hashCode, totalShifts.hashCode, averageRating.hashCode, onTimeRate.hashCode, noShowCount.hashCode, cancellationCount.hashCode, reliabilityScore.hashCode, xp.hashCode, badges.hashCode, isRecommended.hashCode, bio.hashCode, skills.hashCode, industries.hashCode, preferredLocations.hashCode, maxDistanceMiles.hashCode, languages.hashCode, itemsAttire.hashCode, ownerId.hashCode, createdAt.hashCode, updatedAt.hashCode, createdBy.hashCode, department.hashCode, hubId.hashCode, manager.hashCode, english.hashCode, backgroundCheckStatus.hashCode, employmentType.hashCode, initial.hashCode, englishRequired.hashCode, city.hashCode, addres.hashCode]);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -192,6 +195,9 @@ class GetStaffByUserIdStaffs {
if (bio != null) { if (bio != null) {
json['bio'] = nativeToJson<String?>(bio); json['bio'] = nativeToJson<String?>(bio);
} }
if (skills != null) {
json['skills'] = skills!.toJson();
}
if (industries != null) { if (industries != null) {
json['industries'] = industries!.toJson(); json['industries'] = industries!.toJson();
} }
@@ -278,6 +284,7 @@ class GetStaffByUserIdStaffs {
this.badges, this.badges,
this.isRecommended, this.isRecommended,
this.bio, this.bio,
this.skills,
this.industries, this.industries,
this.preferredLocations, this.preferredLocations,
this.maxDistanceMiles, this.maxDistanceMiles,

View File

@@ -36,6 +36,7 @@ class ListStaffStaffs {
final AnyValue? badges; final AnyValue? badges;
final bool? isRecommended; final bool? isRecommended;
final String? bio; final String? bio;
final AnyValue? skills;
final AnyValue? industries; final AnyValue? industries;
final AnyValue? preferredLocations; final AnyValue? preferredLocations;
final int? maxDistanceMiles; final int? maxDistanceMiles;
@@ -73,6 +74,7 @@ class ListStaffStaffs {
badges = json['badges'] == null ? null : AnyValue.fromJson(json['badges']), badges = json['badges'] == null ? null : AnyValue.fromJson(json['badges']),
isRecommended = json['isRecommended'] == null ? null : nativeFromJson<bool>(json['isRecommended']), isRecommended = json['isRecommended'] == null ? null : nativeFromJson<bool>(json['isRecommended']),
bio = json['bio'] == null ? null : nativeFromJson<String>(json['bio']), bio = json['bio'] == null ? null : nativeFromJson<String>(json['bio']),
skills = json['skills'] == null ? null : AnyValue.fromJson(json['skills']),
industries = json['industries'] == null ? null : AnyValue.fromJson(json['industries']), industries = json['industries'] == null ? null : AnyValue.fromJson(json['industries']),
preferredLocations = json['preferredLocations'] == null ? null : AnyValue.fromJson(json['preferredLocations']), preferredLocations = json['preferredLocations'] == null ? null : AnyValue.fromJson(json['preferredLocations']),
maxDistanceMiles = json['maxDistanceMiles'] == null ? null : nativeFromJson<int>(json['maxDistanceMiles']), maxDistanceMiles = json['maxDistanceMiles'] == null ? null : nativeFromJson<int>(json['maxDistanceMiles']),
@@ -118,6 +120,7 @@ class ListStaffStaffs {
badges == otherTyped.badges && badges == otherTyped.badges &&
isRecommended == otherTyped.isRecommended && isRecommended == otherTyped.isRecommended &&
bio == otherTyped.bio && bio == otherTyped.bio &&
skills == otherTyped.skills &&
industries == otherTyped.industries && industries == otherTyped.industries &&
preferredLocations == otherTyped.preferredLocations && preferredLocations == otherTyped.preferredLocations &&
maxDistanceMiles == otherTyped.maxDistanceMiles && maxDistanceMiles == otherTyped.maxDistanceMiles &&
@@ -138,7 +141,7 @@ class ListStaffStaffs {
} }
@override @override
int get hashCode => Object.hashAll([id.hashCode, userId.hashCode, fullName.hashCode, level.hashCode, role.hashCode, phone.hashCode, email.hashCode, photoUrl.hashCode, totalShifts.hashCode, averageRating.hashCode, onTimeRate.hashCode, noShowCount.hashCode, cancellationCount.hashCode, reliabilityScore.hashCode, xp.hashCode, badges.hashCode, isRecommended.hashCode, bio.hashCode, industries.hashCode, preferredLocations.hashCode, maxDistanceMiles.hashCode, languages.hashCode, itemsAttire.hashCode, ownerId.hashCode, createdAt.hashCode, department.hashCode, hubId.hashCode, manager.hashCode, english.hashCode, backgroundCheckStatus.hashCode, employmentType.hashCode, initial.hashCode, englishRequired.hashCode, city.hashCode, addres.hashCode]); int get hashCode => Object.hashAll([id.hashCode, userId.hashCode, fullName.hashCode, level.hashCode, role.hashCode, phone.hashCode, email.hashCode, photoUrl.hashCode, totalShifts.hashCode, averageRating.hashCode, onTimeRate.hashCode, noShowCount.hashCode, cancellationCount.hashCode, reliabilityScore.hashCode, xp.hashCode, badges.hashCode, isRecommended.hashCode, bio.hashCode, skills.hashCode, industries.hashCode, preferredLocations.hashCode, maxDistanceMiles.hashCode, languages.hashCode, itemsAttire.hashCode, ownerId.hashCode, createdAt.hashCode, department.hashCode, hubId.hashCode, manager.hashCode, english.hashCode, backgroundCheckStatus.hashCode, employmentType.hashCode, initial.hashCode, englishRequired.hashCode, city.hashCode, addres.hashCode]);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -191,6 +194,9 @@ class ListStaffStaffs {
if (bio != null) { if (bio != null) {
json['bio'] = nativeToJson<String?>(bio); json['bio'] = nativeToJson<String?>(bio);
} }
if (skills != null) {
json['skills'] = skills!.toJson();
}
if (industries != null) { if (industries != null) {
json['industries'] = industries!.toJson(); json['industries'] = industries!.toJson();
} }
@@ -272,6 +278,7 @@ class ListStaffStaffs {
this.badges, this.badges,
this.isRecommended, this.isRecommended,
this.bio, this.bio,
this.skills,
this.industries, this.industries,
this.preferredLocations, this.preferredLocations,
this.maxDistanceMiles, this.maxDistanceMiles,

View File

@@ -16,6 +16,7 @@ class UpdateStaffVariablesBuilder {
Optional<int> _cancellationCount = Optional.optional(nativeFromJson, nativeToJson); Optional<int> _cancellationCount = Optional.optional(nativeFromJson, nativeToJson);
Optional<int> _reliabilityScore = Optional.optional(nativeFromJson, nativeToJson); Optional<int> _reliabilityScore = Optional.optional(nativeFromJson, nativeToJson);
Optional<String> _bio = Optional.optional(nativeFromJson, nativeToJson); Optional<String> _bio = Optional.optional(nativeFromJson, nativeToJson);
Optional<AnyValue> _skills = Optional.optional(AnyValue.fromJson, defaultSerializer);
Optional<AnyValue> _industries = Optional.optional(AnyValue.fromJson, defaultSerializer); Optional<AnyValue> _industries = Optional.optional(AnyValue.fromJson, defaultSerializer);
Optional<AnyValue> _preferredLocations = Optional.optional(AnyValue.fromJson, defaultSerializer); Optional<AnyValue> _preferredLocations = Optional.optional(AnyValue.fromJson, defaultSerializer);
Optional<int> _maxDistanceMiles = Optional.optional(nativeFromJson, nativeToJson); Optional<int> _maxDistanceMiles = Optional.optional(nativeFromJson, nativeToJson);
@@ -92,6 +93,10 @@ class UpdateStaffVariablesBuilder {
_bio.value = t; _bio.value = t;
return this; return this;
} }
UpdateStaffVariablesBuilder skills(AnyValue? t) {
_skills.value = t;
return this;
}
UpdateStaffVariablesBuilder industries(AnyValue? t) { UpdateStaffVariablesBuilder industries(AnyValue? t) {
_industries.value = t; _industries.value = t;
return this; return this;
@@ -177,7 +182,7 @@ class UpdateStaffVariablesBuilder {
} }
MutationRef<UpdateStaffData, UpdateStaffVariables> ref() { MutationRef<UpdateStaffData, UpdateStaffVariables> ref() {
UpdateStaffVariables vars= UpdateStaffVariables(id: id,userId: _userId,fullName: _fullName,level: _level,role: _role,phone: _phone,email: _email,photoUrl: _photoUrl,totalShifts: _totalShifts,averageRating: _averageRating,onTimeRate: _onTimeRate,noShowCount: _noShowCount,cancellationCount: _cancellationCount,reliabilityScore: _reliabilityScore,bio: _bio,industries: _industries,preferredLocations: _preferredLocations,maxDistanceMiles: _maxDistanceMiles,languages: _languages,itemsAttire: _itemsAttire,xp: _xp,badges: _badges,isRecommended: _isRecommended,ownerId: _ownerId,department: _department,hubId: _hubId,manager: _manager,english: _english,backgroundCheckStatus: _backgroundCheckStatus,employmentType: _employmentType,initial: _initial,englishRequired: _englishRequired,city: _city,addres: _addres,); UpdateStaffVariables vars= UpdateStaffVariables(id: id,userId: _userId,fullName: _fullName,level: _level,role: _role,phone: _phone,email: _email,photoUrl: _photoUrl,totalShifts: _totalShifts,averageRating: _averageRating,onTimeRate: _onTimeRate,noShowCount: _noShowCount,cancellationCount: _cancellationCount,reliabilityScore: _reliabilityScore,bio: _bio,skills: _skills,industries: _industries,preferredLocations: _preferredLocations,maxDistanceMiles: _maxDistanceMiles,languages: _languages,itemsAttire: _itemsAttire,xp: _xp,badges: _badges,isRecommended: _isRecommended,ownerId: _ownerId,department: _department,hubId: _hubId,manager: _manager,english: _english,backgroundCheckStatus: _backgroundCheckStatus,employmentType: _employmentType,initial: _initial,englishRequired: _englishRequired,city: _city,addres: _addres,);
return _dataConnect.mutation("UpdateStaff", dataDeserializer, varsSerializer, vars); return _dataConnect.mutation("UpdateStaff", dataDeserializer, varsSerializer, vars);
} }
} }
@@ -269,6 +274,7 @@ class UpdateStaffVariables {
late final Optional<int>cancellationCount; late final Optional<int>cancellationCount;
late final Optional<int>reliabilityScore; late final Optional<int>reliabilityScore;
late final Optional<String>bio; late final Optional<String>bio;
late final Optional<AnyValue>skills;
late final Optional<AnyValue>industries; late final Optional<AnyValue>industries;
late final Optional<AnyValue>preferredLocations; late final Optional<AnyValue>preferredLocations;
late final Optional<int>maxDistanceMiles; late final Optional<int>maxDistanceMiles;
@@ -351,6 +357,10 @@ class UpdateStaffVariables {
bio.value = json['bio'] == null ? null : nativeFromJson<String>(json['bio']); bio.value = json['bio'] == null ? null : nativeFromJson<String>(json['bio']);
skills = Optional.optional(AnyValue.fromJson, defaultSerializer);
skills.value = json['skills'] == null ? null : AnyValue.fromJson(json['skills']);
industries = Optional.optional(AnyValue.fromJson, defaultSerializer); industries = Optional.optional(AnyValue.fromJson, defaultSerializer);
industries.value = json['industries'] == null ? null : AnyValue.fromJson(json['industries']); industries.value = json['industries'] == null ? null : AnyValue.fromJson(json['industries']);
@@ -452,6 +462,7 @@ class UpdateStaffVariables {
cancellationCount == otherTyped.cancellationCount && cancellationCount == otherTyped.cancellationCount &&
reliabilityScore == otherTyped.reliabilityScore && reliabilityScore == otherTyped.reliabilityScore &&
bio == otherTyped.bio && bio == otherTyped.bio &&
skills == otherTyped.skills &&
industries == otherTyped.industries && industries == otherTyped.industries &&
preferredLocations == otherTyped.preferredLocations && preferredLocations == otherTyped.preferredLocations &&
maxDistanceMiles == otherTyped.maxDistanceMiles && maxDistanceMiles == otherTyped.maxDistanceMiles &&
@@ -474,7 +485,7 @@ class UpdateStaffVariables {
} }
@override @override
int get hashCode => Object.hashAll([id.hashCode, userId.hashCode, fullName.hashCode, level.hashCode, role.hashCode, phone.hashCode, email.hashCode, photoUrl.hashCode, totalShifts.hashCode, averageRating.hashCode, onTimeRate.hashCode, noShowCount.hashCode, cancellationCount.hashCode, reliabilityScore.hashCode, bio.hashCode, industries.hashCode, preferredLocations.hashCode, maxDistanceMiles.hashCode, languages.hashCode, itemsAttire.hashCode, xp.hashCode, badges.hashCode, isRecommended.hashCode, ownerId.hashCode, department.hashCode, hubId.hashCode, manager.hashCode, english.hashCode, backgroundCheckStatus.hashCode, employmentType.hashCode, initial.hashCode, englishRequired.hashCode, city.hashCode, addres.hashCode]); int get hashCode => Object.hashAll([id.hashCode, userId.hashCode, fullName.hashCode, level.hashCode, role.hashCode, phone.hashCode, email.hashCode, photoUrl.hashCode, totalShifts.hashCode, averageRating.hashCode, onTimeRate.hashCode, noShowCount.hashCode, cancellationCount.hashCode, reliabilityScore.hashCode, bio.hashCode, skills.hashCode, industries.hashCode, preferredLocations.hashCode, maxDistanceMiles.hashCode, languages.hashCode, itemsAttire.hashCode, xp.hashCode, badges.hashCode, isRecommended.hashCode, ownerId.hashCode, department.hashCode, hubId.hashCode, manager.hashCode, english.hashCode, backgroundCheckStatus.hashCode, employmentType.hashCode, initial.hashCode, englishRequired.hashCode, city.hashCode, addres.hashCode]);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -522,6 +533,9 @@ class UpdateStaffVariables {
if(bio.state == OptionalState.set) { if(bio.state == OptionalState.set) {
json['bio'] = bio.toJson(); json['bio'] = bio.toJson();
} }
if(skills.state == OptionalState.set) {
json['skills'] = skills.toJson();
}
if(industries.state == OptionalState.set) { if(industries.state == OptionalState.set) {
json['industries'] = industries.toJson(); json['industries'] = industries.toJson();
} }
@@ -598,6 +612,7 @@ class UpdateStaffVariables {
required this.cancellationCount, required this.cancellationCount,
required this.reliabilityScore, required this.reliabilityScore,
required this.bio, required this.bio,
required this.skills,
required this.industries, required this.industries,
required this.preferredLocations, required this.preferredLocations,
required this.maxDistanceMiles, required this.maxDistanceMiles,

View File

@@ -0,0 +1,29 @@
import 'package:krow_domain/krow_domain.dart' as domain;
class StaffSession {
final domain.User user;
final domain.Staff? staff;
const StaffSession({
required this.user,
this.staff,
});
}
class StaffSessionStore {
StaffSession? _session;
StaffSession? get session => _session;
void setSession(StaffSession session) {
_session = session;
}
void clear() {
_session = null;
}
static final StaffSessionStore instance = StaffSessionStore._();
StaffSessionStore._();
}

View File

@@ -4,6 +4,7 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_data_connect/firebase_data_connect.dart'; import 'package:firebase_data_connect/firebase_data_connect.dart';
import 'package:krow_data_connect/krow_data_connect.dart'; import 'package:krow_data_connect/krow_data_connect.dart';
import 'package:krow_domain/krow_domain.dart' as domain; import 'package:krow_domain/krow_domain.dart' as domain;
import '../../domain/ui_entities/auth_mode.dart';
import '../../domain/repositories/auth_repository_interface.dart'; import '../../domain/repositories/auth_repository_interface.dart';
@@ -67,6 +68,7 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
/// Signs out the current user. /// Signs out the current user.
@override @override
Future<void> signOut() { Future<void> signOut() {
StaffSessionStore.instance.clear();
return firebaseAuth.signOut(); return firebaseAuth.signOut();
} }
@@ -75,6 +77,7 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
Future<domain.User?> verifyOtp({ Future<domain.User?> verifyOtp({
required String verificationId, required String verificationId,
required String smsCode, required String smsCode,
required AuthMode mode,
}) async { }) async {
final PhoneAuthCredential credential = PhoneAuthProvider.credential( final PhoneAuthCredential credential = PhoneAuthProvider.credential(
verificationId: verificationId, verificationId: verificationId,
@@ -86,33 +89,76 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
throw Exception('Phone verification failed, no Firebase user received.'); throw Exception('Phone verification failed, no Firebase user received.');
} }
final QueryResult<GetUserByIdData, GetUserByIdVariables> response = await dataConnect.getUserById( final QueryResult<GetUserByIdData, GetUserByIdVariables> response =
id: firebaseUser.uid, await dataConnect.getUserById(
).execute(); id: firebaseUser.uid,
).execute();
final GetUserByIdUser? user = response.data.user; final GetUserByIdUser? user = response.data.user;
if (user == null) {
await firebaseAuth.signOut(); if (mode == AuthMode.signup) {
throw Exception('Authenticated user profile not found in database.'); if (user == null) {
} await dataConnect
if (user.userRole != 'STAFF') { .createUser(
await firebaseAuth.signOut(); id: firebaseUser.uid,
throw Exception('User is not authorized for this app.'); role: UserBaseRole.USER,
)
.userRole('STAFF')
.execute();
} else {
if (user.userRole != 'STAFF') {
await firebaseAuth.signOut();
throw Exception('User is not authorized for this app.');
}
final QueryResult<GetStaffByUserIdData, GetStaffByUserIdVariables>
staffResponse = await dataConnect.getStaffByUserId(
userId: firebaseUser.uid,
).execute();
if (staffResponse.data.staffs.isNotEmpty) {
await firebaseAuth.signOut();
throw Exception(
'This user already has a staff profile. Please log in.',
);
}
}
} else {
if (user == null) {
await firebaseAuth.signOut();
throw Exception('Authenticated user profile not found in database.');
}
if (user.userRole != 'STAFF') {
await firebaseAuth.signOut();
throw Exception('User is not authorized for this app.');
}
final QueryResult<GetStaffByUserIdData, GetStaffByUserIdVariables>
staffResponse = await dataConnect.getStaffByUserId(
userId: firebaseUser.uid,
).execute();
if (staffResponse.data.staffs.isEmpty) {
await firebaseAuth.signOut();
throw Exception(
'Your account is not registered yet. Please register first.',
);
}
} }
final String email = user.email ?? ''; final String email = user?.email ?? '';
if (email.isEmpty) { if (mode != AuthMode.signup && email.isEmpty) {
await firebaseAuth.signOut(); await firebaseAuth.signOut();
throw Exception('User email is missing in profile data.'); throw Exception('User email is missing in profile data.');
} }
//TO-DO: validate if user has staff account, else logout, throw message and login
//TO-DO: create(registration) user and staff account //TO-DO: create(registration) user and staff account
//TO-DO: save user data locally //TO-DO: save user data locally
return domain.User( final domain.User domainUser = domain.User(
id: user.id, id: firebaseUser.uid,
email: email, email: email,
phone: firebaseUser.phoneNumber, phone: firebaseUser.phoneNumber,
role: user.role.stringValue, role: user?.role.stringValue ?? 'USER',
); );
StaffSessionStore.instance.setSession(
StaffSession(user: domainUser, staff: null),
);
return domainUser;
} }
} }

View File

@@ -1,4 +1,5 @@
import 'package:krow_core/core.dart'; import 'package:krow_core/core.dart';
import '../ui_entities/auth_mode.dart';
/// Represents the arguments required for the [VerifyOtpUseCase]. /// Represents the arguments required for the [VerifyOtpUseCase].
/// ///
@@ -11,14 +12,18 @@ class VerifyOtpArguments extends UseCaseArgument {
/// The one-time password (OTP) sent to the user's phone. /// The one-time password (OTP) sent to the user's phone.
final String smsCode; final String smsCode;
/// The authentication mode (login or signup).
final AuthMode mode;
/// Creates a [VerifyOtpArguments] instance. /// Creates a [VerifyOtpArguments] instance.
/// ///
/// Both [verificationId] and [smsCode] are required. /// Both [verificationId] and [smsCode] are required.
const VerifyOtpArguments({ const VerifyOtpArguments({
required this.verificationId, required this.verificationId,
required this.smsCode, required this.smsCode,
required this.mode,
}); });
@override @override
List<Object> get props => <Object>[verificationId, smsCode]; List<Object> get props => <Object>[verificationId, smsCode, mode];
} }

View File

@@ -1,4 +1,5 @@
import 'package:krow_domain/krow_domain.dart'; import 'package:krow_domain/krow_domain.dart';
import '../ui_entities/auth_mode.dart';
/// Interface for authentication repository. /// Interface for authentication repository.
abstract interface class AuthRepositoryInterface { abstract interface class AuthRepositoryInterface {
@@ -11,6 +12,7 @@ abstract interface class AuthRepositoryInterface {
Future<User?> verifyOtp({ Future<User?> verifyOtp({
required String verificationId, required String verificationId,
required String smsCode, required String smsCode,
required AuthMode mode,
}); });
/// Signs out the current user. /// Signs out the current user.

View File

@@ -19,6 +19,7 @@ class VerifyOtpUseCase implements UseCase<VerifyOtpArguments, User?> {
return _repository.verifyOtp( return _repository.verifyOtp(
verificationId: arguments.verificationId, verificationId: arguments.verificationId,
smsCode: arguments.smsCode, smsCode: arguments.smsCode,
mode: arguments.mode,
); );
} }
} }

View File

@@ -93,6 +93,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> implements Disposable {
VerifyOtpArguments( VerifyOtpArguments(
verificationId: event.verificationId, verificationId: event.verificationId,
smsCode: event.smsCode, smsCode: event.smsCode,
mode: event.mode,
), ),
); );
emit(state.copyWith(status: AuthStatus.authenticated, user: user)); emit(state.copyWith(status: AuthStatus.authenticated, user: user));

View File

@@ -33,10 +33,17 @@ class AuthOtpSubmitted extends AuthEvent {
/// The SMS code (OTP) entered by the user. /// The SMS code (OTP) entered by the user.
final String smsCode; final String smsCode;
const AuthOtpSubmitted({required this.verificationId, required this.smsCode}); /// The authentication mode (login or signup).
final AuthMode mode;
const AuthOtpSubmitted({
required this.verificationId,
required this.smsCode,
required this.mode,
});
@override @override
List<Object> get props => <Object>[verificationId, smsCode]; List<Object> get props => <Object>[verificationId, smsCode, mode];
} }
/// Event for clearing any authentication error in the state. /// Event for clearing any authentication error in the state.

View File

@@ -1,5 +1,9 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:firebase_auth/firebase_auth.dart' as auth;
import 'package:firebase_data_connect/firebase_data_connect.dart' as fdc;
import 'package:krow_data_connect/krow_data_connect.dart' as dc;
import 'package:krow_domain/krow_domain.dart';
import 'profile_setup_event.dart'; import 'profile_setup_event.dart';
import 'profile_setup_state.dart'; import 'profile_setup_state.dart';
@@ -8,8 +12,12 @@ export 'profile_setup_state.dart';
/// BLoC responsible for managing the profile setup state and logic. /// BLoC responsible for managing the profile setup state and logic.
class ProfileSetupBloc extends Bloc<ProfileSetupEvent, ProfileSetupState> { class ProfileSetupBloc extends Bloc<ProfileSetupEvent, ProfileSetupState> {
/// Creates a [ProfileSetupBloc] with an initial state. ProfileSetupBloc({
ProfileSetupBloc() : super(const ProfileSetupState()) { required auth.FirebaseAuth firebaseAuth,
required dc.ExampleConnector dataConnect,
}) : _firebaseAuth = firebaseAuth,
_dataConnect = dataConnect,
super(const ProfileSetupState()) {
on<ProfileSetupFullNameChanged>(_onFullNameChanged); on<ProfileSetupFullNameChanged>(_onFullNameChanged);
on<ProfileSetupBioChanged>(_onBioChanged); on<ProfileSetupBioChanged>(_onBioChanged);
on<ProfileSetupLocationsChanged>(_onLocationsChanged); on<ProfileSetupLocationsChanged>(_onLocationsChanged);
@@ -19,6 +27,9 @@ class ProfileSetupBloc extends Bloc<ProfileSetupEvent, ProfileSetupState> {
on<ProfileSetupSubmitted>(_onSubmitted); on<ProfileSetupSubmitted>(_onSubmitted);
} }
final auth.FirebaseAuth _firebaseAuth;
final dc.ExampleConnector _dataConnect;
/// Handles the [ProfileSetupFullNameChanged] event. /// Handles the [ProfileSetupFullNameChanged] event.
void _onFullNameChanged( void _onFullNameChanged(
ProfileSetupFullNameChanged event, ProfileSetupFullNameChanged event,
@@ -75,17 +86,44 @@ class ProfileSetupBloc extends Bloc<ProfileSetupEvent, ProfileSetupState> {
emit(state.copyWith(status: ProfileSetupStatus.loading)); emit(state.copyWith(status: ProfileSetupStatus.loading));
try { try {
// In a real app, we would send this data to a UseCase final auth.User? firebaseUser = _firebaseAuth.currentUser;
debugPrint('Submitting Profile:'); if (firebaseUser == null) {
debugPrint('Name: ${state.fullName}'); throw Exception('User not authenticated.');
debugPrint('Bio: ${state.bio}'); }
debugPrint('Locations: ${state.preferredLocations}');
debugPrint('Distance: ${state.maxDistanceMiles}');
debugPrint('Skills: ${state.skills}');
debugPrint('Industries: ${state.industries}');
// Mocking profile creation delay final dc.StaffSession? session = dc.StaffSessionStore.instance.session;
await Future.delayed(const Duration(milliseconds: 1500)); final String email = session?.user.email ?? '';
final String? phone = firebaseUser.phoneNumber;
final fdc.OperationResult<dc.CreateStaffData, dc.CreateStaffVariables>
result = await _dataConnect
.createStaff(
userId: firebaseUser.uid,
fullName: state.fullName,
)
.bio(state.bio.isEmpty ? null : state.bio)
.preferredLocations(fdc.AnyValue(state.preferredLocations))
.maxDistanceMiles(state.maxDistanceMiles.toInt())
.industries(fdc.AnyValue(state.industries))
.skills(fdc.AnyValue(state.skills))
.email(email.isEmpty ? null : email)
.phone(phone)
.execute();
final String staffId = result.data?.staff_insert.id ?? '';
final Staff staff = Staff(
id: staffId,
authProviderId: firebaseUser.uid,
name: state.fullName,
email: email,
phone: phone,
status: StaffStatus.completedProfile,
);
if (session != null) {
dc.StaffSessionStore.instance.setSession(
dc.StaffSession(user: session.user, staff: staff),
);
}
emit(state.copyWith(status: ProfileSetupStatus.success)); emit(state.copyWith(status: ProfileSetupStatus.success));
} catch (e) { } catch (e) {

View File

@@ -50,7 +50,13 @@ class PhoneVerificationPage extends StatelessWidget {
}) { }) {
BlocProvider.of<AuthBloc>( BlocProvider.of<AuthBloc>(
context, context,
).add(AuthOtpSubmitted(verificationId: verificationId, smsCode: otp)); ).add(
AuthOtpSubmitted(
verificationId: verificationId,
smsCode: otp,
mode: mode,
),
);
} }
/// Handles the request to resend the verification code using the phone number in the state. /// Handles the request to resend the verification code using the phone number in the state.
@@ -72,6 +78,19 @@ class PhoneVerificationPage extends StatelessWidget {
} else { } else {
Modular.to.pushWorkerHome(); Modular.to.pushWorkerHome();
} }
} else if (state.status == AuthStatus.error &&
state.mode == AuthMode.signup) {
final String message = state.errorMessage ?? '';
if (message.contains('staff profile')) {
Modular.to.pushReplacementNamed(
'./phone-verification',
arguments: <String, String>{
'mode': AuthMode.login.name,
},
);
} else if (message.contains('not authorized')) {
Modular.to.pop();
}
} }
}, },
child: BlocBuilder<AuthBloc, AuthState>( child: BlocBuilder<AuthBloc, AuthState>(

View File

@@ -47,7 +47,12 @@ class StaffAuthenticationModule extends Module {
verifyOtpUseCase: i.get<VerifyOtpUseCase>(), verifyOtpUseCase: i.get<VerifyOtpUseCase>(),
), ),
); );
i.add<ProfileSetupBloc>(ProfileSetupBloc.new); i.add<ProfileSetupBloc>(
() => ProfileSetupBloc(
firebaseAuth: firebase.FirebaseAuth.instance,
dataConnect: ExampleConnector.instance,
),
);
} }
@override @override

View File

@@ -15,7 +15,7 @@ mutation CreateStaff(
$reliabilityScore: Int $reliabilityScore: Int
$bio: String $bio: String
#$skills: Any $skills: Any
$industries: Any $industries: Any
$preferredLocations: Any $preferredLocations: Any
$maxDistanceMiles: Int $maxDistanceMiles: Int
@@ -59,7 +59,7 @@ mutation CreateStaff(
reliabilityScore: $reliabilityScore reliabilityScore: $reliabilityScore
bio: $bio bio: $bio
#skills: $skills skills: $skills
industries: $industries industries: $industries
preferredLocations: $preferredLocations preferredLocations: $preferredLocations
maxDistanceMiles: $maxDistanceMiles maxDistanceMiles: $maxDistanceMiles
@@ -106,7 +106,7 @@ mutation UpdateStaff(
$reliabilityScore: Int $reliabilityScore: Int
$bio: String $bio: String
#$skills: Any $skills: Any
$industries: Any $industries: Any
$preferredLocations: Any $preferredLocations: Any
$maxDistanceMiles: Int $maxDistanceMiles: Int
@@ -151,7 +151,7 @@ mutation UpdateStaff(
reliabilityScore: $reliabilityScore reliabilityScore: $reliabilityScore
bio: $bio bio: $bio
#skills: $skills skills: $skills
industries: $industries industries: $industries
preferredLocations: $preferredLocations preferredLocations: $preferredLocations
maxDistanceMiles: $maxDistanceMiles maxDistanceMiles: $maxDistanceMiles

View File

@@ -20,7 +20,7 @@ query listStaff @auth(level: USER) {
isRecommended isRecommended
bio bio
#skills skills
industries industries
preferredLocations preferredLocations
maxDistanceMiles maxDistanceMiles
@@ -65,7 +65,7 @@ query getStaffById($id: UUID!) @auth(level: USER) {
isRecommended isRecommended
bio bio
#skills skills
industries industries
preferredLocations preferredLocations
maxDistanceMiles maxDistanceMiles
@@ -111,7 +111,7 @@ query getStaffByUserId($userId: String!) @auth(level: USER) {
isRecommended isRecommended
bio bio
#skills skills
industries industries
preferredLocations preferredLocations
maxDistanceMiles maxDistanceMiles
@@ -162,6 +162,7 @@ query filterStaff(
totalShifts totalShifts
ownerId ownerId
isRecommended isRecommended
skills
backgroundCheckStatus backgroundCheckStatus
employmentType employmentType

View File

@@ -61,7 +61,7 @@ type Staff @table(name: "staffs") {
# Profile # Profile
bio: String bio: String
#skills: Any changed it for staffRole skills: Any #changed it for staffRole
industries: Any industries: Any
preferredLocations: Any preferredLocations: Any
maxDistanceMiles: Int maxDistanceMiles: Int