feat: Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
enum StateStatus {
|
||||
idle,
|
||||
loading,
|
||||
error,
|
||||
success,
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/models/event/business_member_model.dart';
|
||||
|
||||
part 'client.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class ClientModel {
|
||||
String id;
|
||||
String firstName;
|
||||
String lastName;
|
||||
String? avatar;
|
||||
|
||||
AuthInfo? authInfo;
|
||||
|
||||
ClientModel(
|
||||
this.firstName,
|
||||
this.lastName,
|
||||
this.avatar,
|
||||
this.id,
|
||||
this.authInfo,
|
||||
);
|
||||
|
||||
factory ClientModel.fromJson(Map<String, dynamic> json) {
|
||||
return _$ClientModelFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$ClientModelToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'addon_model.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class AddonModel {
|
||||
String id;
|
||||
String? name;
|
||||
int? price;
|
||||
|
||||
AddonModel({required this.id, this.name, this.price});
|
||||
|
||||
factory AddonModel.fromJson(Map<String, dynamic> json) {
|
||||
return _$AddonModelFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$AddonModelToJson(this);
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode ^ name.hashCode ^ price.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
if (other is! AddonModel) return false;
|
||||
return id == other.id && name == other.name && price == other.price;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'business_contact_model.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class BusinessContactModel{
|
||||
final String id;
|
||||
final String? firstName;
|
||||
final String? lastName;
|
||||
final String? email;
|
||||
final String? phone;
|
||||
final String? address;
|
||||
|
||||
BusinessContactModel({
|
||||
required this.id,
|
||||
this.firstName,
|
||||
this.lastName,
|
||||
this.email,
|
||||
this.phone,
|
||||
this.address,
|
||||
});
|
||||
|
||||
factory BusinessContactModel.fromJson(Map<String, dynamic> json) {
|
||||
return _$BusinessContactModelFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$BusinessContactModelToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'business_member_model.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class BusinessMemberModel {
|
||||
final String id;
|
||||
final String firstName;
|
||||
final String lastName;
|
||||
final String title;
|
||||
final AuthInfo? authInfo;
|
||||
|
||||
BusinessMemberModel({
|
||||
required this.id,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.title,
|
||||
this.authInfo,
|
||||
});
|
||||
|
||||
factory BusinessMemberModel.fromJson(Map<String, dynamic> json) {
|
||||
return _$BusinessMemberModelFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$BusinessMemberModelToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class AuthInfo {
|
||||
final String email;
|
||||
final String phone;
|
||||
|
||||
AuthInfo({
|
||||
required this.email,
|
||||
required this.phone,
|
||||
});
|
||||
|
||||
factory AuthInfo.fromJson(Map<String, dynamic> json) {
|
||||
return _$AuthInfoFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$AuthInfoToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/models/event/addon_model.dart';
|
||||
import 'package:krow/core/data/models/event/business_contact_model.dart';
|
||||
|
||||
part 'business_model.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class BusinessModel {
|
||||
String? name;
|
||||
String? avatar;
|
||||
String? registration;
|
||||
List<AddonModel>? addons;
|
||||
BusinessContactModel? contact;
|
||||
|
||||
BusinessModel({this.name, this.avatar, this.addons, this.registration, this.contact});
|
||||
|
||||
factory BusinessModel.fromJson(Map<String, dynamic> json) {
|
||||
return _$BusinessModelFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$BusinessModelToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/models/event/addon_model.dart';
|
||||
import 'package:krow/core/data/models/event/business_model.dart';
|
||||
import 'package:krow/core/data/models/event/hub_model.dart';
|
||||
import 'package:krow/core/data/models/event/tag_model.dart';
|
||||
import 'package:krow/core/data/models/shift/shift_model.dart';
|
||||
import 'package:krow/core/entity/event_entity.dart';
|
||||
|
||||
part 'event_model.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class EventModel {
|
||||
final String id;
|
||||
final BusinessModel? business;
|
||||
final HubModel? hub;
|
||||
final String name;
|
||||
@JsonKey(unknownEnumValue: EventStatus.draft)
|
||||
final EventStatus status;
|
||||
final String date;
|
||||
final String startTime;
|
||||
final String endTime;
|
||||
final String? purchaseOrder;
|
||||
// @JsonKey(unknownEnumValue: EventContractType.direct)
|
||||
// final EventContractType contractType;
|
||||
@JsonKey(unknownEnumValue: EventScheduleType.oneTime)
|
||||
final EventScheduleType? scheduleType;
|
||||
final String? additionalInfo;
|
||||
@JsonKey(defaultValue: [])
|
||||
final List<AddonModel> addons;
|
||||
@JsonKey(defaultValue: [])
|
||||
final List<TagModel> tags;
|
||||
@JsonKey(defaultValue: [])
|
||||
final List<ShiftModel> shifts;
|
||||
|
||||
EventModel(
|
||||
{required this.id,
|
||||
required this.business,
|
||||
required this.hub,
|
||||
required this.name,
|
||||
required this.status,
|
||||
required this.date,
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
required this.purchaseOrder,
|
||||
// required this.contractType,
|
||||
required this.scheduleType,
|
||||
required this.additionalInfo,
|
||||
required this.addons,
|
||||
required this.tags,
|
||||
required this.shifts});
|
||||
|
||||
factory EventModel.fromJson(Map<String, dynamic> json) {
|
||||
return _$EventModelFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$EventModelToJson(this);
|
||||
}
|
||||
|
||||
@JsonEnum(fieldRename: FieldRename.snake)
|
||||
enum EventContractType {
|
||||
direct,
|
||||
contract,
|
||||
purchaseOrder,
|
||||
}
|
||||
|
||||
@JsonEnum(fieldRename: FieldRename.snake)
|
||||
enum EventScheduleType {
|
||||
oneTime,
|
||||
recurring,
|
||||
}
|
||||
|
||||
extension on EventScheduleType {
|
||||
String get formattedName {
|
||||
return switch (this) {
|
||||
EventScheduleType.oneTime => 'One Time',
|
||||
EventScheduleType.recurring => 'Recurring'
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
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'],
|
||||
);
|
||||
}
|
||||
|
||||
bool isValid() {
|
||||
return formattedAddress != null &&
|
||||
latitude != null &&
|
||||
longitude != null &&
|
||||
streetNumber != null &&
|
||||
city != null &&
|
||||
street != null &&
|
||||
region != null &&
|
||||
zipCode != null &&
|
||||
country != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:krow/core/data/models/event/full_address_model.dart';
|
||||
|
||||
part 'hub_model.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class HubModel {
|
||||
String id;
|
||||
String? name;
|
||||
String? address;
|
||||
FullAddress? fullAddress;
|
||||
|
||||
HubModel({required this.id, this.name, this.address, this.fullAddress});
|
||||
|
||||
factory HubModel.fromJson(Map<String, dynamic> json) {
|
||||
return _$HubModelFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$HubModelToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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/client-app/lib/core/data/models/event/skill.dart
Normal file
30
mobile-apps/client-app/lib/core/data/models/event/skill.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/models/event/role_kit.dart';
|
||||
import 'package:krow/core/data/models/event/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,19 @@
|
||||
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,34 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'tag_model.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class TagModel {
|
||||
String id;
|
||||
String name;
|
||||
|
||||
TagModel({required this.id, required this.name});
|
||||
|
||||
factory TagModel.fromJson(Map<String, dynamic> json) {
|
||||
return _$TagModelFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$TagModelToJson(this);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TagModel{id: $id, name: $name}';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is TagModel && other.id == id && other.name == name;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return id.hashCode ^ name.hashCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
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,
|
||||
required 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).map((e) {
|
||||
return Edge(cursor: e['cursor'], node: convertor?.call(e['node']) as T);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/models/event/skill.dart';
|
||||
|
||||
part 'business_skill_model.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class BusinessSkillModel {
|
||||
final String? id;
|
||||
final Skill? skill;
|
||||
final double? price;
|
||||
final bool? isActive;
|
||||
|
||||
BusinessSkillModel({
|
||||
required this.id,
|
||||
required this.skill,
|
||||
this.price = 0,
|
||||
this.isActive = true,
|
||||
});
|
||||
|
||||
factory BusinessSkillModel.fromJson(Map<String, dynamic> json) {
|
||||
try {
|
||||
return _$BusinessSkillModelFromJson(json);
|
||||
} catch (e) {
|
||||
return BusinessSkillModel(
|
||||
id: '',
|
||||
skill: null,
|
||||
price: 0.0,
|
||||
isActive: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$BusinessSkillModelToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'department_model.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class DepartmentModel {
|
||||
final String id;
|
||||
final String name;
|
||||
|
||||
DepartmentModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
});
|
||||
|
||||
factory DepartmentModel.fromJson(Map<String, dynamic> json) {
|
||||
return _$DepartmentModelFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$DepartmentModelToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/models/shift/business_skill_model.dart';
|
||||
import 'package:krow/core/data/models/shift/department_model.dart';
|
||||
import 'package:krow/core/data/models/staff/staff_model.dart';
|
||||
|
||||
part 'event_shift_position_model.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class EventShiftPositionModel {
|
||||
final String id;
|
||||
|
||||
final int count;
|
||||
final String startTime;
|
||||
final String endTime;
|
||||
final double rate;
|
||||
@JsonKey(name: 'break')
|
||||
final int breakTime;
|
||||
final BusinessSkillModel businessSkill;
|
||||
final List<StaffModel>? staff;
|
||||
final DepartmentModel? department;
|
||||
|
||||
EventShiftPositionModel({
|
||||
required this.id,
|
||||
required this.count,
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
required this.rate,
|
||||
required this.breakTime,
|
||||
required this.businessSkill,
|
||||
required this.staff,
|
||||
required this.department,
|
||||
});
|
||||
|
||||
factory EventShiftPositionModel.fromJson(Map<String, dynamic> json) {
|
||||
return _$EventShiftPositionModelFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$EventShiftPositionModelToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/models/event/business_member_model.dart';
|
||||
import 'package:krow/core/data/models/event/full_address_model.dart';
|
||||
import 'package:krow/core/data/models/shift/event_shift_position_model.dart';
|
||||
|
||||
part 'shift_model.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class ShiftModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final FullAddress fullAddress;
|
||||
final List<BusinessMemberModel>? contacts;
|
||||
final List<EventShiftPositionModel>? positions;
|
||||
|
||||
ShiftModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.fullAddress,
|
||||
required this.contacts,
|
||||
required this.positions,
|
||||
});
|
||||
|
||||
factory ShiftModel.fromJson(Map<String, dynamic> json) {
|
||||
return _$ShiftModelFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$ShiftModelToJson(this);
|
||||
}
|
||||
99
mobile-apps/client-app/lib/core/data/models/staff/pivot.dart
Normal file
99
mobile-apps/client-app/lib/core/data/models/staff/pivot.dart
Normal file
@@ -0,0 +1,99 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/models/shift/event_shift_position_model.dart';
|
||||
import 'package:krow/core/data/models/staff/staff_cancel_reason.dart';
|
||||
|
||||
part 'pivot.g.dart';
|
||||
|
||||
@JsonEnum(fieldRename: FieldRename.snake)
|
||||
enum PivotStatus {
|
||||
assigned,
|
||||
confirmed,
|
||||
ongoing,
|
||||
completed,
|
||||
declineByStaff,
|
||||
canceledByStaff,
|
||||
canceledByBusiness,
|
||||
canceledByAdmin,
|
||||
requestedReplace,
|
||||
noShowed,
|
||||
|
||||
}
|
||||
|
||||
extension PivotStatusToString on PivotStatus {
|
||||
String get formattedName {
|
||||
switch (this) {
|
||||
case PivotStatus.assigned:
|
||||
return 'Assigned';
|
||||
case PivotStatus.confirmed:
|
||||
return 'Confirmed';
|
||||
case PivotStatus.ongoing:
|
||||
return 'Ongoing';
|
||||
case PivotStatus.completed:
|
||||
return 'Completed';
|
||||
case PivotStatus.declineByStaff:
|
||||
return 'Declined by Staff';
|
||||
case PivotStatus.canceledByStaff:
|
||||
return 'Canceled by Staff';
|
||||
case PivotStatus.canceledByBusiness:
|
||||
return 'Canceled by Business';
|
||||
case PivotStatus.canceledByAdmin:
|
||||
return 'Canceled by Admin';
|
||||
case PivotStatus.requestedReplace:
|
||||
return 'Requested Replace';
|
||||
case PivotStatus.noShowed:
|
||||
return 'No Showed';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class Pivot {
|
||||
String id;
|
||||
@JsonKey(unknownEnumValue: PivotStatus.assigned)
|
||||
PivotStatus status;
|
||||
String? statusUpdatedAt;
|
||||
String startAt;
|
||||
String endAt;
|
||||
String? clockIn;
|
||||
String? clockOut;
|
||||
String? breakIn;
|
||||
String? breakOut;
|
||||
EventShiftPositionModel? position;
|
||||
List<StaffCancelReason>? cancelReason;
|
||||
Rating? rating;
|
||||
|
||||
Pivot({
|
||||
required this.id,
|
||||
required this.status,
|
||||
this.statusUpdatedAt,
|
||||
required this.startAt,
|
||||
required this.endAt,
|
||||
this.clockIn,
|
||||
this.clockOut,
|
||||
this.breakIn,
|
||||
this.breakOut,
|
||||
this.position,
|
||||
this.cancelReason,
|
||||
});
|
||||
|
||||
factory Pivot.fromJson(Map<String, dynamic> json) {
|
||||
return _$PivotFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$PivotToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class Rating {
|
||||
final String id;
|
||||
final double rating;
|
||||
|
||||
Rating({required this.id, required this.rating});
|
||||
|
||||
factory Rating.fromJson(Map<String, dynamic> json) {
|
||||
return _$RatingFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$RatingToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'staff_cancel_reason.g.dart';
|
||||
|
||||
@JsonEnum(fieldRename: FieldRename.snake)
|
||||
enum StaffCancelReasonType {
|
||||
cancelShift,
|
||||
declineShift,
|
||||
noBreak
|
||||
}
|
||||
|
||||
@JsonEnum(fieldRename: FieldRename.snake,)
|
||||
enum ShiftCancelReason {
|
||||
sickLeave,
|
||||
vacation,
|
||||
other,
|
||||
health,
|
||||
transportation,
|
||||
personal,
|
||||
scheduleConflict,
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class StaffCancelReason {
|
||||
@JsonKey(unknownEnumValue: StaffCancelReasonType.cancelShift)
|
||||
final StaffCancelReasonType? type;
|
||||
@JsonKey(unknownEnumValue: ShiftCancelReason.sickLeave)
|
||||
final ShiftCancelReason? reason;
|
||||
final String? details;
|
||||
|
||||
StaffCancelReason(
|
||||
{required this.type, required this.reason, required this.details});
|
||||
|
||||
factory StaffCancelReason.fromJson(Map<String, dynamic> json) {
|
||||
return _$StaffCancelReasonFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$StaffCancelReasonToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/models/staff/pivot.dart';
|
||||
|
||||
part 'staff_model.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class StaffModel {
|
||||
String? id;
|
||||
String? firstName;
|
||||
String? lastName;
|
||||
String? email;
|
||||
String? phone;
|
||||
String? avatar;
|
||||
Pivot? pivot;
|
||||
|
||||
StaffModel({
|
||||
required this.id,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.email,
|
||||
required this.phone,
|
||||
required this.avatar,
|
||||
required this.pivot,
|
||||
});
|
||||
|
||||
factory StaffModel.fromJson(Map<String, dynamic> json) {
|
||||
return _$StaffModelFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$StaffModelToJson(this);
|
||||
}
|
||||
Reference in New Issue
Block a user