feat: Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
enum PaginationStatus {
|
||||
initial(true),
|
||||
loading(false),
|
||||
idle(true),
|
||||
empty(false),
|
||||
error(true),
|
||||
end(false);
|
||||
|
||||
const PaginationStatus(this.allowLoad);
|
||||
|
||||
final bool allowLoad;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
enum StaffSkillStatus {
|
||||
verified,
|
||||
pending,
|
||||
declined,
|
||||
deactivated,
|
||||
}
|
||||
|
||||
enum StaffSkillLevel {
|
||||
beginner,
|
||||
skilled,
|
||||
professional,
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
enum StateStatus {
|
||||
idle,
|
||||
loading,
|
||||
error,
|
||||
success,
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'pagination_wrapper.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class PageInfo {
|
||||
final bool? hasNextPage;
|
||||
final bool? hasPreviousPage;
|
||||
final String? startCursor;
|
||||
final String? endCursor;
|
||||
|
||||
PageInfo({
|
||||
required this.hasNextPage,
|
||||
this.hasPreviousPage,
|
||||
this.startCursor,
|
||||
this.endCursor,
|
||||
});
|
||||
|
||||
factory PageInfo.fromJson(Map<String, dynamic> json) {
|
||||
return _$PageInfoFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$PageInfoToJson(this);
|
||||
}
|
||||
|
||||
class Edge<T> {
|
||||
final String? cursor;
|
||||
final T node;
|
||||
|
||||
Edge({
|
||||
required this.cursor,
|
||||
required this.node,
|
||||
});
|
||||
|
||||
factory Edge.fromJson(Map<String, dynamic> json) {
|
||||
return Edge(
|
||||
cursor: json['cursor'],
|
||||
node: json['node'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PaginationWrapper<T> {
|
||||
final PageInfo? pageInfo;
|
||||
final List<Edge<T>> edges;
|
||||
|
||||
PaginationWrapper({
|
||||
required this.pageInfo,
|
||||
required this.edges,
|
||||
});
|
||||
|
||||
factory PaginationWrapper.fromJson(
|
||||
Map<String, dynamic> json,
|
||||
T Function(Map<String, dynamic>) convertor,
|
||||
) {
|
||||
return PaginationWrapper(
|
||||
pageInfo: PageInfo.fromJson(json['pageInfo']),
|
||||
edges: (json['edges'] as List<dynamic>).map(
|
||||
(e) {
|
||||
return Edge(
|
||||
cursor: e['cursor'],
|
||||
node: convertor.call(e['node']),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
22
mobile-apps/staff-app/lib/core/data/models/role_kit.dart
Normal file
22
mobile-apps/staff-app/lib/core/data/models/role_kit.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'role_kit.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class RoleKit {
|
||||
final String id;
|
||||
final String? name;
|
||||
final bool? isRequired;
|
||||
final bool? photoRequired;
|
||||
|
||||
RoleKit({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.isRequired,
|
||||
required this.photoRequired,
|
||||
});
|
||||
|
||||
factory RoleKit.fromJson(Map<String, dynamic> json) => _$RoleKitFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$RoleKitToJson(this);
|
||||
}
|
||||
30
mobile-apps/staff-app/lib/core/data/models/skill.dart
Normal file
30
mobile-apps/staff-app/lib/core/data/models/skill.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/models/role_kit.dart';
|
||||
import 'package:krow/core/data/models/skill_category.dart';
|
||||
|
||||
part 'skill.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class Skill {
|
||||
final String id;
|
||||
final String name;
|
||||
final String? slug;
|
||||
final double ?price;
|
||||
final List<RoleKit>? uniforms;
|
||||
final List<RoleKit>? equipments;
|
||||
final SkillCategory? category;
|
||||
|
||||
Skill({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.slug,
|
||||
required this.price,
|
||||
required this.uniforms,
|
||||
required this.equipments,
|
||||
this.category,
|
||||
});
|
||||
|
||||
factory Skill.fromJson(Map<String, dynamic> json) => _$SkillFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$SkillToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'skill_category.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class SkillCategory {
|
||||
final String name;
|
||||
final String slug;
|
||||
|
||||
SkillCategory({
|
||||
required this.name,
|
||||
required this.slug,
|
||||
});
|
||||
|
||||
factory SkillCategory.fromJson(Map<String, dynamic> json) => _$SkillCategoryFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$SkillCategoryToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'bank_acc.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class BankAcc {
|
||||
final String? holderName;
|
||||
final String? bankName;
|
||||
final String? number;
|
||||
final String? routingNumber;
|
||||
final String? country;
|
||||
final String? state;
|
||||
final String? city;
|
||||
final String? street;
|
||||
final String? building;
|
||||
final String? zip;
|
||||
|
||||
BankAcc({
|
||||
required this.holderName,
|
||||
required this.bankName,
|
||||
required this.number,
|
||||
required this.routingNumber,
|
||||
required this.country,
|
||||
required this.state,
|
||||
required this.city,
|
||||
required this.street,
|
||||
required this.building,
|
||||
required this.zip,
|
||||
});
|
||||
|
||||
factory BankAcc.fromJson(Map<String, dynamic> json) {
|
||||
return _$BankAccFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$BankAccToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
part 'full_address_model.g.dart';
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class FullAddress {
|
||||
String? streetNumber;
|
||||
String? zipCode;
|
||||
double? latitude;
|
||||
double? longitude;
|
||||
String? formattedAddress;
|
||||
String? street;
|
||||
String? region;
|
||||
String? city;
|
||||
String? country;
|
||||
|
||||
FullAddress({
|
||||
this.streetNumber,
|
||||
this.zipCode,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.formattedAddress,
|
||||
this.street,
|
||||
this.region,
|
||||
this.city,
|
||||
this.country,
|
||||
});
|
||||
|
||||
factory FullAddress.fromJson(Map<String, dynamic> json) {
|
||||
return _$FullAddressFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$FullAddressToJson(this);
|
||||
|
||||
static FullAddress fromGoogle(Map<String, dynamic> fullAddress) {
|
||||
return FullAddress(
|
||||
streetNumber: fullAddress['street_number'],
|
||||
zipCode: fullAddress['postal_code'],
|
||||
latitude: fullAddress['lat'],
|
||||
longitude: fullAddress['lng'],
|
||||
formattedAddress: fullAddress['formatted_address'],
|
||||
street: fullAddress['street'],
|
||||
region: fullAddress['state'],
|
||||
city: fullAddress['city'],
|
||||
country: fullAddress['country'],
|
||||
);
|
||||
}
|
||||
}
|
||||
65
mobile-apps/staff-app/lib/core/data/models/staff/staff.dart
Normal file
65
mobile-apps/staff-app/lib/core/data/models/staff/staff.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/models/staff/full_address_model.dart';
|
||||
import 'package:krow/core/data/models/staff/workin_area.dart';
|
||||
import 'package:krow/core/data/models/staff/bank_acc.dart';
|
||||
import 'package:krow/core/data/models/staff_role.dart';
|
||||
import 'package:krow/features/profile/certificates/data/models/staff_certificate.dart';
|
||||
|
||||
part 'staff.g.dart';
|
||||
|
||||
enum StaffStatus {
|
||||
active,
|
||||
deactivated,
|
||||
pending,
|
||||
registered,
|
||||
declined,
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class Staff {
|
||||
final String id;
|
||||
final String? firstName;
|
||||
final String? lastName;
|
||||
final String? middleName;
|
||||
final String? email;
|
||||
final String? phone;
|
||||
final String? address;
|
||||
final StaffStatus? status;
|
||||
final FullAddress? fullAddress;
|
||||
final String? avatar;
|
||||
final List<WorkingArea>? workingAreas;
|
||||
final List<BankAcc>? bankAccount;
|
||||
final List<StaffRole>? roles;
|
||||
final List<StaffCertificate>? certificates;
|
||||
final double? averageRating;
|
||||
|
||||
Staff({
|
||||
required this.id,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.middleName,
|
||||
required this.email,
|
||||
required this.phone,
|
||||
required this.address,
|
||||
required this.status,
|
||||
required this.workingAreas,
|
||||
required this.fullAddress,
|
||||
required this.bankAccount,
|
||||
required this.roles,
|
||||
required this.certificates,
|
||||
this.averageRating,
|
||||
this.avatar,
|
||||
});
|
||||
|
||||
factory Staff.fromJson(Map<String, dynamic> json) => _$StaffFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$StaffToJson(this);
|
||||
|
||||
static var staffStatusEnumMap = {
|
||||
StaffStatus.active: 'active',
|
||||
StaffStatus.deactivated: 'deactivated',
|
||||
StaffStatus.pending: 'pending',
|
||||
StaffStatus.registered: 'registered',
|
||||
StaffStatus.declined: 'declined',
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
class WorkingArea{
|
||||
final String id;
|
||||
final String address;
|
||||
|
||||
WorkingArea({required this.id, required this.address});
|
||||
|
||||
factory WorkingArea.fromJson(Map<String, dynamic> json) {
|
||||
return WorkingArea(
|
||||
id: json['id'],
|
||||
address: json['address']
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'address': address
|
||||
};
|
||||
}
|
||||
}
|
||||
93
mobile-apps/staff-app/lib/core/data/models/staff_role.dart
Normal file
93
mobile-apps/staff-app/lib/core/data/models/staff_role.dart
Normal file
@@ -0,0 +1,93 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/enums/staff_skill_enums.dart';
|
||||
import 'package:krow/core/data/models/skill.dart';
|
||||
import 'package:krow/core/data/models/staff_role_kit.dart';
|
||||
|
||||
part 'staff_role.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class StaffRole {
|
||||
final String? id;
|
||||
final Skill? skill;
|
||||
final StaffSkillLevel? level;
|
||||
final int? experience;
|
||||
final StaffSkillStatus? status;
|
||||
final String? photo;
|
||||
final List<StaffRoleKit>? confirmedUniforms;
|
||||
final List<StaffRoleKit>? confirmedEquipments;
|
||||
|
||||
StaffRole({
|
||||
this.id,
|
||||
this.skill,
|
||||
this.level,
|
||||
this.experience,
|
||||
this.status,
|
||||
this.photo,
|
||||
this.confirmedUniforms,
|
||||
this.confirmedEquipments,
|
||||
});
|
||||
|
||||
factory StaffRole.empty() {
|
||||
return StaffRole(
|
||||
id: '',
|
||||
);
|
||||
}
|
||||
|
||||
factory StaffRole.fromJson(Map<String, dynamic> json) =>
|
||||
_$StaffRoleFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$StaffRoleToJson(this);
|
||||
|
||||
StaffRole copyWith({
|
||||
String? id,
|
||||
Skill? skill,
|
||||
StaffSkillLevel? level,
|
||||
int? experience,
|
||||
StaffSkillStatus? status,
|
||||
String? photo,
|
||||
List<StaffRoleKit>? confirmedUniforms,
|
||||
List<StaffRoleKit>? confirmedEquipments,
|
||||
}) {
|
||||
return StaffRole(
|
||||
id: id ?? this.id,
|
||||
skill: skill ?? this.skill,
|
||||
level: level ?? this.level,
|
||||
experience: experience ?? this.experience,
|
||||
status: status ?? this.status,
|
||||
photo: photo ?? this.photo,
|
||||
confirmedUniforms: confirmedUniforms ?? this.confirmedUniforms,
|
||||
confirmedEquipments: confirmedEquipments ?? this.confirmedEquipments,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'StaffRole{id: $id, skill: $skill, level: $level, experience: $experience, status: $status, photo: $photo, confirmedUniforms: $confirmedUniforms, confirmedEquipments: $confirmedEquipments}';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is StaffRole &&
|
||||
runtimeType == other.runtimeType &&
|
||||
id == other.id &&
|
||||
skill == other.skill &&
|
||||
level == other.level &&
|
||||
experience == other.experience &&
|
||||
status == other.status &&
|
||||
photo == other.photo &&
|
||||
confirmedUniforms == other.confirmedUniforms &&
|
||||
confirmedEquipments == other.confirmedEquipments;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
id.hashCode ^
|
||||
skill.hashCode ^
|
||||
level.hashCode ^
|
||||
experience.hashCode ^
|
||||
status.hashCode ^
|
||||
photo.hashCode ^
|
||||
confirmedUniforms.hashCode ^
|
||||
confirmedEquipments.hashCode;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'staff_role_kit.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class StaffRoleKit{
|
||||
String id;
|
||||
String skillKitId;
|
||||
String? photo;
|
||||
|
||||
StaffRoleKit({
|
||||
required this.id,
|
||||
required this.skillKitId,
|
||||
this.photo,
|
||||
});
|
||||
|
||||
factory StaffRoleKit.fromJson(Map<String, dynamic> json) {
|
||||
return _$StaffRoleKitFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$StaffRoleKitToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
abstract class ContactsData {
|
||||
static const supportEmail = 'orders@legendaryeventstaff.com';
|
||||
static const supportPhone = '+1 (408) 315-5343';
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
abstract class EmailValidationConstants {
|
||||
static const storedEmailKey = 'user_pre_validation_email';
|
||||
static const oobCodeKey = 'oobCode';
|
||||
}
|
||||
Reference in New Issue
Block a user