feat: update preferredLocations field to List<String> across staff-related entities and mutations
- Changed preferredLocations from AnyValue to List<String> in GetStaffByIdStaff, GetStaffByUserIdStaffs, ListStaffStaffs, and UpdateStaffVariablesBuilder classes. - Updated JSON serialization/deserialization for preferredLocations to handle List<String>. - Modified Staff entity to include preferredLocations as List<String>. - Adjusted ProfileSetupBloc and PersonalInfoBloc to accommodate changes in preferredLocations. - Updated PersonalInfoRepositoryImpl to handle preferredLocations as List<String>. - Refactored PersonalInfoContent and PersonalInfoForm to use locations instead of address. - Updated GraphQL mutations and schema to reflect the new List<String> type for preferredLocations.
This commit is contained in:
committed by
José Salazar
parent
c041796b38
commit
f345e715ad
@@ -1,16 +1,16 @@
|
||||
# Basic Usage
|
||||
|
||||
```dart
|
||||
ExampleConnector.instance.createStaffRole(createStaffRoleVariables).execute();
|
||||
ExampleConnector.instance.deleteStaffRole(deleteStaffRoleVariables).execute();
|
||||
ExampleConnector.instance.createTeamMember(createTeamMemberVariables).execute();
|
||||
ExampleConnector.instance.updateTeamMember(updateTeamMemberVariables).execute();
|
||||
ExampleConnector.instance.updateTeamMemberInviteStatus(updateTeamMemberInviteStatusVariables).execute();
|
||||
ExampleConnector.instance.acceptInviteByCode(acceptInviteByCodeVariables).execute();
|
||||
ExampleConnector.instance.cancelInviteByCode(cancelInviteByCodeVariables).execute();
|
||||
ExampleConnector.instance.deleteTeamMember(deleteTeamMemberVariables).execute();
|
||||
ExampleConnector.instance.createUserConversation(createUserConversationVariables).execute();
|
||||
ExampleConnector.instance.updateUserConversation(updateUserConversationVariables).execute();
|
||||
ExampleConnector.instance.createTeamHudDepartment(createTeamHudDepartmentVariables).execute();
|
||||
ExampleConnector.instance.updateTeamHudDepartment(updateTeamHudDepartmentVariables).execute();
|
||||
ExampleConnector.instance.deleteTeamHudDepartment(deleteTeamHudDepartmentVariables).execute();
|
||||
ExampleConnector.instance.CreateUser(createUserVariables).execute();
|
||||
ExampleConnector.instance.UpdateUser(updateUserVariables).execute();
|
||||
ExampleConnector.instance.DeleteUser(deleteUserVariables).execute();
|
||||
ExampleConnector.instance.createVendorBenefitPlan(createVendorBenefitPlanVariables).execute();
|
||||
ExampleConnector.instance.updateVendorBenefitPlan(updateVendorBenefitPlanVariables).execute();
|
||||
ExampleConnector.instance.deleteVendorBenefitPlan(deleteVendorBenefitPlanVariables).execute();
|
||||
ExampleConnector.instance.getShiftRoleById(getShiftRoleByIdVariables).execute();
|
||||
|
||||
```
|
||||
|
||||
@@ -23,8 +23,8 @@ Optional fields can be discovered based on classes that have `Optional` object t
|
||||
This is an example of a mutation with an optional field:
|
||||
|
||||
```dart
|
||||
await ExampleConnector.instance.updateShift({ ... })
|
||||
.title(...)
|
||||
await ExampleConnector.instance.updateStaffAvailabilityStats({ ... })
|
||||
.needWorkIndex(...)
|
||||
.execute();
|
||||
```
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@ class CreateStaffVariablesBuilder {
|
||||
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> _preferredLocations = Optional.optional(AnyValue.fromJson, defaultSerializer);
|
||||
Optional<List<String>> _preferredLocations = Optional.optional(listDeserializer(nativeFromJson), listSerializer(nativeToJson));
|
||||
Optional<int> _maxDistanceMiles = Optional.optional(nativeFromJson, nativeToJson);
|
||||
Optional<AnyValue> _languages = Optional.optional(AnyValue.fromJson, defaultSerializer);
|
||||
Optional<AnyValue> _itemsAttire = Optional.optional(AnyValue.fromJson, defaultSerializer);
|
||||
@@ -92,7 +92,7 @@ class CreateStaffVariablesBuilder {
|
||||
_industries.value = t;
|
||||
return this;
|
||||
}
|
||||
CreateStaffVariablesBuilder preferredLocations(AnyValue? t) {
|
||||
CreateStaffVariablesBuilder preferredLocations(List<String>? t) {
|
||||
_preferredLocations.value = t;
|
||||
return this;
|
||||
}
|
||||
@@ -264,7 +264,7 @@ class CreateStaffVariables {
|
||||
late final Optional<String>bio;
|
||||
late final Optional<AnyValue>skills;
|
||||
late final Optional<AnyValue>industries;
|
||||
late final Optional<AnyValue>preferredLocations;
|
||||
late final Optional<List<String>>preferredLocations;
|
||||
late final Optional<int>maxDistanceMiles;
|
||||
late final Optional<AnyValue>languages;
|
||||
late final Optional<AnyValue>itemsAttire;
|
||||
@@ -347,8 +347,10 @@ class CreateStaffVariables {
|
||||
industries.value = json['industries'] == null ? null : AnyValue.fromJson(json['industries']);
|
||||
|
||||
|
||||
preferredLocations = Optional.optional(AnyValue.fromJson, defaultSerializer);
|
||||
preferredLocations.value = json['preferredLocations'] == null ? null : AnyValue.fromJson(json['preferredLocations']);
|
||||
preferredLocations = Optional.optional(listDeserializer(nativeFromJson), listSerializer(nativeToJson));
|
||||
preferredLocations.value = json['preferredLocations'] == null ? null : (json['preferredLocations'] as List<dynamic>)
|
||||
.map((e) => nativeFromJson<String>(e))
|
||||
.toList();
|
||||
|
||||
|
||||
maxDistanceMiles = Optional.optional(nativeFromJson, nativeToJson);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -39,7 +39,7 @@ class GetStaffByIdStaff {
|
||||
final String? bio;
|
||||
final AnyValue? skills;
|
||||
final AnyValue? industries;
|
||||
final AnyValue? preferredLocations;
|
||||
final List<String>? preferredLocations;
|
||||
final int? maxDistanceMiles;
|
||||
final AnyValue? languages;
|
||||
final AnyValue? itemsAttire;
|
||||
@@ -79,7 +79,9 @@ class GetStaffByIdStaff {
|
||||
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']),
|
||||
preferredLocations = json['preferredLocations'] == null ? null : AnyValue.fromJson(json['preferredLocations']),
|
||||
preferredLocations = json['preferredLocations'] == null ? null : (json['preferredLocations'] as List<dynamic>)
|
||||
.map((e) => nativeFromJson<String>(e))
|
||||
.toList(),
|
||||
maxDistanceMiles = json['maxDistanceMiles'] == null ? null : nativeFromJson<int>(json['maxDistanceMiles']),
|
||||
languages = json['languages'] == null ? null : AnyValue.fromJson(json['languages']),
|
||||
itemsAttire = json['itemsAttire'] == null ? null : AnyValue.fromJson(json['itemsAttire']),
|
||||
@@ -208,7 +210,7 @@ class GetStaffByIdStaff {
|
||||
json['industries'] = industries!.toJson();
|
||||
}
|
||||
if (preferredLocations != null) {
|
||||
json['preferredLocations'] = preferredLocations!.toJson();
|
||||
json['preferredLocations'] = preferredLocations?.map((e) => nativeToJson<String>(e)).toList();
|
||||
}
|
||||
if (maxDistanceMiles != null) {
|
||||
json['maxDistanceMiles'] = nativeToJson<int?>(maxDistanceMiles);
|
||||
|
||||
@@ -38,7 +38,7 @@ class GetStaffByUserIdStaffs {
|
||||
final String? bio;
|
||||
final AnyValue? skills;
|
||||
final AnyValue? industries;
|
||||
final AnyValue? preferredLocations;
|
||||
final List<String>? preferredLocations;
|
||||
final int? maxDistanceMiles;
|
||||
final AnyValue? languages;
|
||||
final AnyValue? itemsAttire;
|
||||
@@ -77,7 +77,9 @@ class GetStaffByUserIdStaffs {
|
||||
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']),
|
||||
preferredLocations = json['preferredLocations'] == null ? null : AnyValue.fromJson(json['preferredLocations']),
|
||||
preferredLocations = json['preferredLocations'] == null ? null : (json['preferredLocations'] as List<dynamic>)
|
||||
.map((e) => nativeFromJson<String>(e))
|
||||
.toList(),
|
||||
maxDistanceMiles = json['maxDistanceMiles'] == null ? null : nativeFromJson<int>(json['maxDistanceMiles']),
|
||||
languages = json['languages'] == null ? null : AnyValue.fromJson(json['languages']),
|
||||
itemsAttire = json['itemsAttire'] == null ? null : AnyValue.fromJson(json['itemsAttire']),
|
||||
@@ -202,7 +204,7 @@ class GetStaffByUserIdStaffs {
|
||||
json['industries'] = industries!.toJson();
|
||||
}
|
||||
if (preferredLocations != null) {
|
||||
json['preferredLocations'] = preferredLocations!.toJson();
|
||||
json['preferredLocations'] = preferredLocations?.map((e) => nativeToJson<String>(e)).toList();
|
||||
}
|
||||
if (maxDistanceMiles != null) {
|
||||
json['maxDistanceMiles'] = nativeToJson<int?>(maxDistanceMiles);
|
||||
|
||||
@@ -38,7 +38,7 @@ class ListStaffStaffs {
|
||||
final String? bio;
|
||||
final AnyValue? skills;
|
||||
final AnyValue? industries;
|
||||
final AnyValue? preferredLocations;
|
||||
final List<String>? preferredLocations;
|
||||
final int? maxDistanceMiles;
|
||||
final AnyValue? languages;
|
||||
final AnyValue? itemsAttire;
|
||||
@@ -76,7 +76,9 @@ class ListStaffStaffs {
|
||||
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']),
|
||||
preferredLocations = json['preferredLocations'] == null ? null : AnyValue.fromJson(json['preferredLocations']),
|
||||
preferredLocations = json['preferredLocations'] == null ? null : (json['preferredLocations'] as List<dynamic>)
|
||||
.map((e) => nativeFromJson<String>(e))
|
||||
.toList(),
|
||||
maxDistanceMiles = json['maxDistanceMiles'] == null ? null : nativeFromJson<int>(json['maxDistanceMiles']),
|
||||
languages = json['languages'] == null ? null : AnyValue.fromJson(json['languages']),
|
||||
itemsAttire = json['itemsAttire'] == null ? null : AnyValue.fromJson(json['itemsAttire']),
|
||||
@@ -201,7 +203,7 @@ class ListStaffStaffs {
|
||||
json['industries'] = industries!.toJson();
|
||||
}
|
||||
if (preferredLocations != null) {
|
||||
json['preferredLocations'] = preferredLocations!.toJson();
|
||||
json['preferredLocations'] = preferredLocations?.map((e) => nativeToJson<String>(e)).toList();
|
||||
}
|
||||
if (maxDistanceMiles != null) {
|
||||
json['maxDistanceMiles'] = nativeToJson<int?>(maxDistanceMiles);
|
||||
|
||||
@@ -18,7 +18,7 @@ class UpdateStaffVariablesBuilder {
|
||||
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> _preferredLocations = Optional.optional(AnyValue.fromJson, defaultSerializer);
|
||||
Optional<List<String>> _preferredLocations = Optional.optional(listDeserializer(nativeFromJson), listSerializer(nativeToJson));
|
||||
Optional<int> _maxDistanceMiles = Optional.optional(nativeFromJson, nativeToJson);
|
||||
Optional<AnyValue> _languages = Optional.optional(AnyValue.fromJson, defaultSerializer);
|
||||
Optional<AnyValue> _itemsAttire = Optional.optional(AnyValue.fromJson, defaultSerializer);
|
||||
@@ -101,7 +101,7 @@ class UpdateStaffVariablesBuilder {
|
||||
_industries.value = t;
|
||||
return this;
|
||||
}
|
||||
UpdateStaffVariablesBuilder preferredLocations(AnyValue? t) {
|
||||
UpdateStaffVariablesBuilder preferredLocations(List<String>? t) {
|
||||
_preferredLocations.value = t;
|
||||
return this;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ class UpdateStaffVariables {
|
||||
late final Optional<String>bio;
|
||||
late final Optional<AnyValue>skills;
|
||||
late final Optional<AnyValue>industries;
|
||||
late final Optional<AnyValue>preferredLocations;
|
||||
late final Optional<List<String>>preferredLocations;
|
||||
late final Optional<int>maxDistanceMiles;
|
||||
late final Optional<AnyValue>languages;
|
||||
late final Optional<AnyValue>itemsAttire;
|
||||
@@ -365,8 +365,10 @@ class UpdateStaffVariables {
|
||||
industries.value = json['industries'] == null ? null : AnyValue.fromJson(json['industries']);
|
||||
|
||||
|
||||
preferredLocations = Optional.optional(AnyValue.fromJson, defaultSerializer);
|
||||
preferredLocations.value = json['preferredLocations'] == null ? null : AnyValue.fromJson(json['preferredLocations']);
|
||||
preferredLocations = Optional.optional(listDeserializer(nativeFromJson), listSerializer(nativeToJson));
|
||||
preferredLocations.value = json['preferredLocations'] == null ? null : (json['preferredLocations'] as List<dynamic>)
|
||||
.map((e) => nativeFromJson<String>(e))
|
||||
.toList();
|
||||
|
||||
|
||||
maxDistanceMiles = Optional.optional(nativeFromJson, nativeToJson);
|
||||
|
||||
@@ -44,6 +44,7 @@ class Staff extends Equatable {
|
||||
this.noShowCount,
|
||||
this.cancellationCount,
|
||||
this.reliabilityScore,
|
||||
this.preferredLocations,
|
||||
});
|
||||
/// Unique identifier for the staff profile.
|
||||
final String id;
|
||||
@@ -89,6 +90,9 @@ class Staff extends Equatable {
|
||||
/// The reliability score (0-100).
|
||||
final int? reliabilityScore;
|
||||
|
||||
/// Preferred work locations.
|
||||
final List<String>? preferredLocations;
|
||||
|
||||
@override
|
||||
List<Object?> get props => <Object?>[
|
||||
id,
|
||||
@@ -105,5 +109,6 @@ class Staff extends Equatable {
|
||||
noShowCount,
|
||||
cancellationCount,
|
||||
reliabilityScore,
|
||||
preferredLocations,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class ProfileSetupBloc extends Bloc<ProfileSetupEvent, ProfileSetupState> {
|
||||
fullName: state.fullName,
|
||||
)
|
||||
.bio(state.bio.isEmpty ? null : state.bio)
|
||||
.preferredLocations(fdc.AnyValue(state.preferredLocations))
|
||||
.preferredLocations(state.preferredLocations)
|
||||
.maxDistanceMiles(state.maxDistanceMiles.toInt())
|
||||
.industries(fdc.AnyValue(state.industries))
|
||||
.skills(fdc.AnyValue(state.skills))
|
||||
|
||||
@@ -65,7 +65,10 @@ class PersonalInfoRepositoryImpl implements PersonalInfoRepositoryInterface {
|
||||
if (data.containsKey('avatar')) {
|
||||
updateBuilder = updateBuilder.photoUrl(data['avatar'] as String?);
|
||||
}
|
||||
// Add other fields as they become available in the schema and map
|
||||
if (data.containsKey('preferredLocations')) {
|
||||
// After schema update and SDK regeneration, preferredLocations accepts List<String>
|
||||
updateBuilder = updateBuilder.preferredLocations(data['preferredLocations'] as List<String>);
|
||||
}
|
||||
|
||||
// Execute the update
|
||||
final OperationResult<UpdateStaffData, UpdateStaffVariables> result =
|
||||
@@ -107,6 +110,8 @@ class PersonalInfoRepositoryImpl implements PersonalInfoRepositoryInterface {
|
||||
noShowCount: dto.noShowCount,
|
||||
cancellationCount: dto.cancellationCount,
|
||||
reliabilityScore: dto.reliabilityScore,
|
||||
// After schema update and SDK regeneration, preferredLocations is List<String>?
|
||||
preferredLocations: dto.preferredLocations,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,11 +42,14 @@ class PersonalInfoBloc extends Bloc<PersonalInfoEvent, PersonalInfoState>
|
||||
final Staff staff = await _getPersonalInfoUseCase();
|
||||
|
||||
// Initialize form values from staff entity
|
||||
// Note: Staff entity currently stores address as a string, but we want to map it to 'preferredLocations'
|
||||
final Map<String, dynamic> initialValues = {
|
||||
'name': staff.name,
|
||||
'email': staff.email,
|
||||
'phone': staff.phone,
|
||||
'address': staff.address,
|
||||
'preferredLocations': staff.address != null
|
||||
? [staff.address]
|
||||
: [], // TODO: Map correctly when Staff entity supports list
|
||||
'avatar': staff.avatar,
|
||||
};
|
||||
|
||||
@@ -94,7 +97,9 @@ class PersonalInfoBloc extends Bloc<PersonalInfoEvent, PersonalInfoState>
|
||||
'name': updatedStaff.name,
|
||||
'email': updatedStaff.email,
|
||||
'phone': updatedStaff.phone,
|
||||
'address': updatedStaff.address,
|
||||
'preferredLocations': updatedStaff.address != null
|
||||
? [updatedStaff.address]
|
||||
: [],
|
||||
'avatar': updatedStaff.avatar,
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class PersonalInfoLoadRequested extends PersonalInfoEvent {
|
||||
/// Event to update a field value.
|
||||
class PersonalInfoFieldUpdated extends PersonalInfoEvent {
|
||||
final String field;
|
||||
final String value;
|
||||
final dynamic value;
|
||||
|
||||
const PersonalInfoFieldUpdated({
|
||||
required this.field,
|
||||
|
||||
@@ -33,23 +33,23 @@ class PersonalInfoContent extends StatefulWidget {
|
||||
|
||||
class _PersonalInfoContentState extends State<PersonalInfoContent> {
|
||||
late final TextEditingController _phoneController;
|
||||
late final TextEditingController _addressController;
|
||||
late final TextEditingController _locationsController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_phoneController = TextEditingController(text: widget.staff.phone ?? '');
|
||||
_addressController = TextEditingController(text: widget.staff.address ?? '');
|
||||
_locationsController = TextEditingController(text: widget.staff.preferredLocations?.join(', ')?? '');
|
||||
|
||||
// Listen to changes and update BLoC
|
||||
_phoneController.addListener(_onPhoneChanged);
|
||||
_addressController.addListener(_onAddressChanged);
|
||||
_locationsController.addListener(_onAddressChanged);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_phoneController.dispose();
|
||||
_addressController.dispose();
|
||||
_locationsController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -64,10 +64,18 @@ class _PersonalInfoContentState extends State<PersonalInfoContent> {
|
||||
}
|
||||
|
||||
void _onAddressChanged() {
|
||||
// Split the comma-separated string into a list for storage
|
||||
// The backend expects List<AnyValue> (JSON/List) for preferredLocations
|
||||
final List<String> locations = _locationsController.text
|
||||
.split(',')
|
||||
.map((e) => e.trim())
|
||||
.where((e) => e.isNotEmpty)
|
||||
.toList();
|
||||
|
||||
context.read<PersonalInfoBloc>().add(
|
||||
PersonalInfoFieldUpdated(
|
||||
field: 'address',
|
||||
value: _addressController.text,
|
||||
field: 'preferredLocations',
|
||||
value: locations,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -107,7 +115,7 @@ class _PersonalInfoContentState extends State<PersonalInfoContent> {
|
||||
fullName: widget.staff.name,
|
||||
email: widget.staff.email,
|
||||
phoneController: _phoneController,
|
||||
addressController: _addressController,
|
||||
locationsController: _locationsController,
|
||||
enabled: !isSaving,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space16), // Space for bottom button
|
||||
|
||||
@@ -19,7 +19,7 @@ class PersonalInfoForm extends StatelessWidget {
|
||||
final TextEditingController phoneController;
|
||||
|
||||
/// Controller for the address field.
|
||||
final TextEditingController addressController;
|
||||
final TextEditingController locationsController;
|
||||
|
||||
/// Whether the form fields are enabled for editing.
|
||||
final bool enabled;
|
||||
@@ -30,7 +30,7 @@ class PersonalInfoForm extends StatelessWidget {
|
||||
required this.fullName,
|
||||
required this.email,
|
||||
required this.phoneController,
|
||||
required this.addressController,
|
||||
required this.locationsController,
|
||||
this.enabled = true,
|
||||
});
|
||||
|
||||
@@ -63,7 +63,7 @@ class PersonalInfoForm extends StatelessWidget {
|
||||
_FieldLabel(text: i18n.locations_label),
|
||||
const SizedBox(height: UiConstants.space2),
|
||||
_EditableField(
|
||||
controller: addressController,
|
||||
controller: locationsController,
|
||||
hint: i18n.locations_hint,
|
||||
enabled: enabled,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user