feat: Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/models/skill.dart';
|
||||
|
||||
part 'business_skill.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class BusinessSkill {
|
||||
Skill? skill;
|
||||
|
||||
BusinessSkill({this.skill});
|
||||
|
||||
factory BusinessSkill.fromJson(Map<String, dynamic> json) {
|
||||
return _$BusinessSkillFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$BusinessSkillToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'cancellation_reason.g.dart';
|
||||
|
||||
@JsonEnum(fieldRename: FieldRename.snake)
|
||||
enum CancellationReason {
|
||||
sickLeave,
|
||||
vacation,
|
||||
other,
|
||||
health,
|
||||
transportation,
|
||||
personal,
|
||||
scheduleConflict,
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class CancellationReasonModel {
|
||||
final String type;
|
||||
final CancellationReason? reason;
|
||||
final String? details;
|
||||
|
||||
CancellationReasonModel({
|
||||
required this.type,
|
||||
required this.reason,
|
||||
required this.details,
|
||||
});
|
||||
|
||||
factory CancellationReasonModel.fromJson(Map<String, dynamic> json) {
|
||||
return _$CancellationReasonModelFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$CancellationReasonModelToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/features/shifts/data/models/event_tag.dart';
|
||||
|
||||
part 'event.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class Event {
|
||||
String? id;
|
||||
Business? business;
|
||||
String? name;
|
||||
String? date;
|
||||
String? additionalInfo;
|
||||
List<Addon>? addons;
|
||||
List<EventTag>? tags;
|
||||
|
||||
|
||||
Event({
|
||||
this.business,
|
||||
this.name,
|
||||
this.date,
|
||||
this.additionalInfo,
|
||||
this.addons,
|
||||
this.tags,
|
||||
});
|
||||
|
||||
factory Event.fromJson(Map<String, dynamic> json) {
|
||||
return _$EventFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$EventToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class Business {
|
||||
String? name;
|
||||
String? avatar;
|
||||
|
||||
Business({this.name, this.avatar});
|
||||
|
||||
factory Business.fromJson(Map<String, dynamic> json) {
|
||||
return _$BusinessFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$BusinessToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class Addon {
|
||||
String? name;
|
||||
|
||||
Addon({this.name});
|
||||
|
||||
factory Addon.fromJson(Map<String, dynamic> json) {
|
||||
return Addon(
|
||||
name: json['name'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/core/data/models/staff/full_address_model.dart';
|
||||
import 'package:krow/features/shifts/data/models/event.dart';
|
||||
import 'package:krow/features/shifts/data/models/shift_contact.dart';
|
||||
|
||||
part 'event_shift.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class Shift {
|
||||
String? id;
|
||||
String? name;
|
||||
String? address;
|
||||
FullAddress? fullAddress;
|
||||
List<Contact>? contacts;
|
||||
Event? event;
|
||||
|
||||
Shift({
|
||||
this.id,
|
||||
this.name,
|
||||
this.address,
|
||||
this.event,
|
||||
this.contacts,
|
||||
this.fullAddress,
|
||||
});
|
||||
|
||||
factory Shift.fromJson(Map<String, dynamic> json) {
|
||||
return _$ShiftFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$ShiftToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'event_tag.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class EventTag{
|
||||
final String id;
|
||||
final String name;
|
||||
final String? slug;
|
||||
|
||||
EventTag({required this.name, required this.id, required this.slug});
|
||||
|
||||
factory EventTag.fromJson(Map<String, dynamic> json) {
|
||||
return _$EventTagFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$EventTagToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/features/shifts/data/models/business_skill.dart';
|
||||
import 'package:krow/features/shifts/data/models/event_shift.dart';
|
||||
|
||||
part 'position.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class Position {
|
||||
String? id;
|
||||
String? startTime;
|
||||
String? endTime;
|
||||
Shift? shift;
|
||||
BusinessSkill? businessSkill;
|
||||
double? rate;
|
||||
@JsonKey(name: 'break')
|
||||
int? breakMinutes;
|
||||
|
||||
Position({
|
||||
this.id,
|
||||
this.startTime,
|
||||
this.endTime,
|
||||
this.shift,
|
||||
this.businessSkill,
|
||||
});
|
||||
|
||||
factory Position.fromJson(Map<String, dynamic> json) =>
|
||||
_$PositionFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$PositionToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'shift_contact.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class Contact {
|
||||
final String id;
|
||||
final String firstName;
|
||||
final String? avatar;
|
||||
final String lastName;
|
||||
final String title;
|
||||
final AuthInfo authInfo;
|
||||
|
||||
Contact({
|
||||
required this.id,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.title,
|
||||
required this.avatar,
|
||||
required this.authInfo,
|
||||
});
|
||||
|
||||
factory Contact.fromJson(Map<String, dynamic> json) {
|
||||
return _$ContactFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$ContactToJson(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,73 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:krow/features/shifts/data/models/cancellation_reason.dart';
|
||||
import 'package:krow/features/shifts/data/models/position.dart';
|
||||
|
||||
part 'staff_shift.g.dart';
|
||||
|
||||
@JsonEnum(fieldRename: FieldRename.snake)
|
||||
enum EventShiftRoleStaffStatus {
|
||||
assigned,
|
||||
confirmed,
|
||||
ongoing,
|
||||
completed,
|
||||
canceledByStaff,
|
||||
canceledByBusiness,
|
||||
canceledByAdmin,
|
||||
requestedReplace,
|
||||
declineByStaff,
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class StaffShift {
|
||||
String id;
|
||||
DateTime? statusUpdatedAt;
|
||||
EventShiftRoleStaffStatus status;
|
||||
Position? position;
|
||||
DateTime? startAt;
|
||||
DateTime? endAt;
|
||||
DateTime? clockIn;
|
||||
DateTime? clockOut;
|
||||
DateTime? breakIn;
|
||||
DateTime? breakOut;
|
||||
List<CancellationReasonModel>? cancelReason;
|
||||
StaffRating? rating;
|
||||
|
||||
|
||||
// Staff? staff;
|
||||
|
||||
StaffShift({
|
||||
required this.id,
|
||||
required this.status,
|
||||
this.statusUpdatedAt,
|
||||
this.position,
|
||||
this.startAt,
|
||||
this.endAt,
|
||||
this.clockIn,
|
||||
this.clockOut,
|
||||
this.breakIn,
|
||||
this.breakOut,
|
||||
this.rating,
|
||||
// this.staff
|
||||
});
|
||||
|
||||
factory StaffShift.fromJson(Map<String, dynamic> json) {
|
||||
return _$StaffShiftFromJson(json);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$StaffShiftToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class StaffRating{
|
||||
final String id;
|
||||
final double rating;
|
||||
|
||||
factory StaffRating.fromJson(Map<String, dynamic> json) {
|
||||
return _$StaffRatingFromJson(json);
|
||||
}
|
||||
|
||||
StaffRating({required this.id, required this.rating});
|
||||
|
||||
Map<String, dynamic> toJson() => _$StaffRatingToJson(this);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user