runable
This commit is contained in:
425
lib/core/database/models/enums.dart
Normal file
425
lib/core/database/models/enums.dart
Normal file
@@ -0,0 +1,425 @@
|
||||
import 'package:hive_ce/hive.dart';
|
||||
|
||||
import 'package:worker/core/constants/storage_constants.dart';
|
||||
|
||||
part 'enums.g.dart';
|
||||
|
||||
/// Member Tier Levels
|
||||
///
|
||||
/// Represents the loyalty program membership tiers.
|
||||
/// Higher tiers receive more benefits and rewards.
|
||||
@HiveType(typeId: HiveTypeIds.memberTier)
|
||||
enum MemberTier {
|
||||
/// Gold tier - Entry level membership
|
||||
@HiveField(0)
|
||||
gold,
|
||||
|
||||
/// Platinum tier - Mid-level membership
|
||||
@HiveField(1)
|
||||
platinum,
|
||||
|
||||
/// Diamond tier - Premium membership
|
||||
@HiveField(2)
|
||||
diamond,
|
||||
}
|
||||
|
||||
/// User Type Categories
|
||||
///
|
||||
/// Represents the different types of users in the app.
|
||||
@HiveType(typeId: HiveTypeIds.userType)
|
||||
enum UserType {
|
||||
/// Construction contractor
|
||||
@HiveField(0)
|
||||
contractor,
|
||||
|
||||
/// Architect or designer
|
||||
@HiveField(1)
|
||||
architect,
|
||||
|
||||
/// Product distributor
|
||||
@HiveField(2)
|
||||
distributor,
|
||||
|
||||
/// Real estate broker
|
||||
@HiveField(3)
|
||||
broker,
|
||||
}
|
||||
|
||||
/// Order Status
|
||||
///
|
||||
/// Represents the current state of an order.
|
||||
@HiveType(typeId: HiveTypeIds.orderStatus)
|
||||
enum OrderStatus {
|
||||
/// Order placed, awaiting confirmation
|
||||
@HiveField(0)
|
||||
pending,
|
||||
|
||||
/// Order confirmed and being processed
|
||||
@HiveField(1)
|
||||
processing,
|
||||
|
||||
/// Order is being shipped/delivered
|
||||
@HiveField(2)
|
||||
shipping,
|
||||
|
||||
/// Order completed successfully
|
||||
@HiveField(3)
|
||||
completed,
|
||||
|
||||
/// Order cancelled
|
||||
@HiveField(4)
|
||||
cancelled,
|
||||
|
||||
/// Order refunded
|
||||
@HiveField(5)
|
||||
refunded,
|
||||
}
|
||||
|
||||
/// Project Status
|
||||
///
|
||||
/// Represents the current state of a construction project.
|
||||
@HiveType(typeId: HiveTypeIds.projectStatus)
|
||||
enum ProjectStatus {
|
||||
/// Project in planning phase
|
||||
@HiveField(0)
|
||||
planning,
|
||||
|
||||
/// Project actively in progress
|
||||
@HiveField(1)
|
||||
inProgress,
|
||||
|
||||
/// Project on hold
|
||||
@HiveField(2)
|
||||
onHold,
|
||||
|
||||
/// Project completed
|
||||
@HiveField(3)
|
||||
completed,
|
||||
|
||||
/// Project cancelled
|
||||
@HiveField(4)
|
||||
cancelled,
|
||||
}
|
||||
|
||||
/// Project Type
|
||||
///
|
||||
/// Represents the category of construction project.
|
||||
@HiveType(typeId: HiveTypeIds.projectType)
|
||||
enum ProjectType {
|
||||
/// Residential building project
|
||||
@HiveField(0)
|
||||
residential,
|
||||
|
||||
/// Commercial building project
|
||||
@HiveField(1)
|
||||
commercial,
|
||||
|
||||
/// Industrial facility project
|
||||
@HiveField(2)
|
||||
industrial,
|
||||
|
||||
/// Infrastructure project
|
||||
@HiveField(3)
|
||||
infrastructure,
|
||||
|
||||
/// Renovation project
|
||||
@HiveField(4)
|
||||
renovation,
|
||||
}
|
||||
|
||||
/// Loyalty Transaction Type
|
||||
///
|
||||
/// Represents the type of loyalty points transaction.
|
||||
@HiveType(typeId: HiveTypeIds.transactionType)
|
||||
enum TransactionType {
|
||||
/// Points earned from purchase
|
||||
@HiveField(0)
|
||||
earnedPurchase,
|
||||
|
||||
/// Points earned from referral
|
||||
@HiveField(1)
|
||||
earnedReferral,
|
||||
|
||||
/// Points earned from promotion
|
||||
@HiveField(2)
|
||||
earnedPromotion,
|
||||
|
||||
/// Bonus points from admin
|
||||
@HiveField(3)
|
||||
earnedBonus,
|
||||
|
||||
/// Points redeemed for reward
|
||||
@HiveField(4)
|
||||
redeemedReward,
|
||||
|
||||
/// Points redeemed for discount
|
||||
@HiveField(5)
|
||||
redeemedDiscount,
|
||||
|
||||
/// Points adjusted by admin
|
||||
@HiveField(6)
|
||||
adjustment,
|
||||
|
||||
/// Points expired
|
||||
@HiveField(7)
|
||||
expired,
|
||||
}
|
||||
|
||||
/// Gift Status
|
||||
///
|
||||
/// Represents the status of a redeemed gift/reward.
|
||||
@HiveType(typeId: HiveTypeIds.giftStatus)
|
||||
enum GiftStatus {
|
||||
/// Gift is active and can be used
|
||||
@HiveField(0)
|
||||
active,
|
||||
|
||||
/// Gift has been used
|
||||
@HiveField(1)
|
||||
used,
|
||||
|
||||
/// Gift has expired
|
||||
@HiveField(2)
|
||||
expired,
|
||||
|
||||
/// Gift is reserved but not activated
|
||||
@HiveField(3)
|
||||
reserved,
|
||||
|
||||
/// Gift has been cancelled
|
||||
@HiveField(4)
|
||||
cancelled,
|
||||
}
|
||||
|
||||
/// Payment Status
|
||||
///
|
||||
/// Represents the status of a payment transaction.
|
||||
@HiveType(typeId: HiveTypeIds.paymentStatus)
|
||||
enum PaymentStatus {
|
||||
/// Payment pending
|
||||
@HiveField(0)
|
||||
pending,
|
||||
|
||||
/// Payment being processed
|
||||
@HiveField(1)
|
||||
processing,
|
||||
|
||||
/// Payment completed successfully
|
||||
@HiveField(2)
|
||||
completed,
|
||||
|
||||
/// Payment failed
|
||||
@HiveField(3)
|
||||
failed,
|
||||
|
||||
/// Payment refunded
|
||||
@HiveField(4)
|
||||
refunded,
|
||||
|
||||
/// Payment cancelled
|
||||
@HiveField(5)
|
||||
cancelled,
|
||||
}
|
||||
|
||||
/// Notification Type
|
||||
///
|
||||
/// Represents different categories of notifications.
|
||||
@HiveType(typeId: HiveTypeIds.notificationType)
|
||||
enum NotificationType {
|
||||
/// Order-related notification
|
||||
@HiveField(0)
|
||||
order,
|
||||
|
||||
/// Promotion or offer notification
|
||||
@HiveField(1)
|
||||
promotion,
|
||||
|
||||
/// System announcement
|
||||
@HiveField(2)
|
||||
system,
|
||||
|
||||
/// Loyalty program notification
|
||||
@HiveField(3)
|
||||
loyalty,
|
||||
|
||||
/// Project-related notification
|
||||
@HiveField(4)
|
||||
project,
|
||||
|
||||
/// Payment notification
|
||||
@HiveField(5)
|
||||
payment,
|
||||
|
||||
/// General message
|
||||
@HiveField(6)
|
||||
message,
|
||||
}
|
||||
|
||||
/// Payment Method
|
||||
///
|
||||
/// Represents available payment methods.
|
||||
@HiveType(typeId: HiveTypeIds.paymentMethod)
|
||||
enum PaymentMethod {
|
||||
/// Cash on delivery
|
||||
@HiveField(0)
|
||||
cashOnDelivery,
|
||||
|
||||
/// Bank transfer
|
||||
@HiveField(1)
|
||||
bankTransfer,
|
||||
|
||||
/// Credit/Debit card
|
||||
@HiveField(2)
|
||||
card,
|
||||
|
||||
/// E-wallet (Momo, ZaloPay, etc.)
|
||||
@HiveField(3)
|
||||
eWallet,
|
||||
|
||||
/// QR code payment
|
||||
@HiveField(4)
|
||||
qrCode,
|
||||
|
||||
/// Pay later / Credit
|
||||
@HiveField(5)
|
||||
payLater,
|
||||
}
|
||||
|
||||
/// Extension methods for enums
|
||||
|
||||
extension MemberTierExtension on MemberTier {
|
||||
/// Get display name
|
||||
String get displayName {
|
||||
switch (this) {
|
||||
case MemberTier.gold:
|
||||
return 'Gold';
|
||||
case MemberTier.platinum:
|
||||
return 'Platinum';
|
||||
case MemberTier.diamond:
|
||||
return 'Diamond';
|
||||
}
|
||||
}
|
||||
|
||||
/// Get tier level (higher is better)
|
||||
int get level {
|
||||
switch (this) {
|
||||
case MemberTier.gold:
|
||||
return 1;
|
||||
case MemberTier.platinum:
|
||||
return 2;
|
||||
case MemberTier.diamond:
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension UserTypeExtension on UserType {
|
||||
/// Get display name (Vietnamese)
|
||||
String get displayName {
|
||||
switch (this) {
|
||||
case UserType.contractor:
|
||||
return 'Thầu thợ';
|
||||
case UserType.architect:
|
||||
return 'Kiến trúc sư';
|
||||
case UserType.distributor:
|
||||
return 'Đại lý phân phối';
|
||||
case UserType.broker:
|
||||
return 'Môi giới';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension OrderStatusExtension on OrderStatus {
|
||||
/// Get display name (Vietnamese)
|
||||
String get displayName {
|
||||
switch (this) {
|
||||
case OrderStatus.pending:
|
||||
return 'Chờ xác nhận';
|
||||
case OrderStatus.processing:
|
||||
return 'Đang xử lý';
|
||||
case OrderStatus.shipping:
|
||||
return 'Đang giao hàng';
|
||||
case OrderStatus.completed:
|
||||
return 'Hoàn thành';
|
||||
case OrderStatus.cancelled:
|
||||
return 'Đã hủy';
|
||||
case OrderStatus.refunded:
|
||||
return 'Đã hoàn tiền';
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if order is active
|
||||
bool get isActive {
|
||||
return this == OrderStatus.pending ||
|
||||
this == OrderStatus.processing ||
|
||||
this == OrderStatus.shipping;
|
||||
}
|
||||
|
||||
/// Check if order is final
|
||||
bool get isFinal {
|
||||
return this == OrderStatus.completed ||
|
||||
this == OrderStatus.cancelled ||
|
||||
this == OrderStatus.refunded;
|
||||
}
|
||||
}
|
||||
|
||||
extension ProjectStatusExtension on ProjectStatus {
|
||||
/// Get display name (Vietnamese)
|
||||
String get displayName {
|
||||
switch (this) {
|
||||
case ProjectStatus.planning:
|
||||
return 'Lập kế hoạch';
|
||||
case ProjectStatus.inProgress:
|
||||
return 'Đang thực hiện';
|
||||
case ProjectStatus.onHold:
|
||||
return 'Tạm dừng';
|
||||
case ProjectStatus.completed:
|
||||
return 'Hoàn thành';
|
||||
case ProjectStatus.cancelled:
|
||||
return 'Đã hủy';
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if project is active
|
||||
bool get isActive {
|
||||
return this == ProjectStatus.planning || this == ProjectStatus.inProgress;
|
||||
}
|
||||
}
|
||||
|
||||
extension TransactionTypeExtension on TransactionType {
|
||||
/// Check if transaction is earning points
|
||||
bool get isEarning {
|
||||
return this == TransactionType.earnedPurchase ||
|
||||
this == TransactionType.earnedReferral ||
|
||||
this == TransactionType.earnedPromotion ||
|
||||
this == TransactionType.earnedBonus;
|
||||
}
|
||||
|
||||
/// Check if transaction is spending points
|
||||
bool get isSpending {
|
||||
return this == TransactionType.redeemedReward ||
|
||||
this == TransactionType.redeemedDiscount;
|
||||
}
|
||||
|
||||
/// Get display name (Vietnamese)
|
||||
String get displayName {
|
||||
switch (this) {
|
||||
case TransactionType.earnedPurchase:
|
||||
return 'Mua hàng';
|
||||
case TransactionType.earnedReferral:
|
||||
return 'Giới thiệu bạn bè';
|
||||
case TransactionType.earnedPromotion:
|
||||
return 'Khuyến mãi';
|
||||
case TransactionType.earnedBonus:
|
||||
return 'Thưởng';
|
||||
case TransactionType.redeemedReward:
|
||||
return 'Đổi quà';
|
||||
case TransactionType.redeemedDiscount:
|
||||
return 'Đổi giảm giá';
|
||||
case TransactionType.adjustment:
|
||||
return 'Điều chỉnh';
|
||||
case TransactionType.expired:
|
||||
return 'Hết hạn';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user