update address

This commit is contained in:
Phuoc Nguyen
2025-11-18 17:04:00 +07:00
parent a5eb95fa64
commit 0dda402246
33 changed files with 4250 additions and 232 deletions

View File

@@ -57,6 +57,10 @@ class HiveBoxNames {
/// Offline request queue for failed API calls
static const String offlineQueueBox = 'offline_queue_box';
/// City and Ward boxes for location data
static const String cityBox = 'city_box';
static const String wardBox = 'ward_box';
/// Get all box names for initialization
static List<String> get allBoxes => [
userBox,
@@ -67,6 +71,8 @@ class HiveBoxNames {
quotes,
loyaltyBox,
rewardsBox,
cityBox,
wardBox,
settingsBox,
cacheBox,
syncStateBox,
@@ -114,7 +120,7 @@ class HiveTypeIds {
static const int chatRoomModel = 18;
static const int messageModel = 19;
// Extended Models (20-29)
// Extended Models (20-30)
static const int notificationModel = 20;
static const int showroomModel = 21;
static const int showroomProductModel = 22;
@@ -125,30 +131,33 @@ class HiveTypeIds {
static const int categoryModel = 27;
static const int favoriteModel = 28;
static const int businessUnitModel = 29;
static const int addressModel = 30;
static const int cityModel = 31;
static const int wardModel = 32;
// Enums (30-59)
static const int userRole = 30;
static const int userStatus = 31;
static const int loyaltyTier = 32;
static const int orderStatus = 33;
static const int invoiceType = 34;
static const int invoiceStatus = 35;
static const int paymentMethod = 36;
static const int paymentStatus = 37;
static const int entryType = 38;
static const int entrySource = 39;
static const int complaintStatus = 40;
static const int giftCategory = 41;
static const int giftStatus = 42;
static const int pointsStatus = 43;
static const int projectType = 44;
static const int submissionStatus = 45;
static const int designStatus = 46;
static const int quoteStatus = 47;
static const int roomType = 48;
static const int contentType = 49;
static const int reminderType = 50;
static const int notificationType = 51;
// Enums (33-62)
static const int userRole = 33;
static const int userStatus = 34;
static const int loyaltyTier = 35;
static const int orderStatus = 36;
static const int invoiceType = 37;
static const int invoiceStatus = 38;
static const int paymentMethod = 39;
static const int paymentStatus = 40;
static const int entryType = 41;
static const int entrySource = 42;
static const int complaintStatus = 43;
static const int giftCategory = 44;
static const int giftStatus = 45;
static const int pointsStatus = 46;
static const int projectType = 47;
static const int submissionStatus = 48;
static const int designStatus = 49;
static const int quoteStatus = 50;
static const int roomType = 51;
static const int contentType = 52;
static const int reminderType = 53;
static const int notificationType = 54;
// Aliases for backward compatibility and clarity
static const int memberTier = loyaltyTier; // Alias for loyaltyTier

View File

@@ -129,6 +129,12 @@ class HiveService {
debugPrint(
'HiveService: ${Hive.isAdapterRegistered(HiveTypeIds.userModel) ? "" : ""} UserModel adapter',
);
debugPrint(
'HiveService: ${Hive.isAdapterRegistered(HiveTypeIds.cityModel) ? "" : ""} CityModel adapter',
);
debugPrint(
'HiveService: ${Hive.isAdapterRegistered(HiveTypeIds.wardModel) ? "" : ""} WardModel adapter',
);
debugPrint('HiveService: Type adapters registered successfully');
}
@@ -158,6 +164,10 @@ class HiveService {
// Favorite products box (non-sensitive) - caches Product entities from wishlist API
Hive.openBox<dynamic>(HiveBoxNames.favoriteProductsBox),
// Location boxes (non-sensitive) - caches cities and wards for address forms
Hive.openBox<dynamic>(HiveBoxNames.cityBox),
Hive.openBox<dynamic>(HiveBoxNames.wardBox),
]);
// Open potentially encrypted boxes (sensitive data)

View File

@@ -8,7 +8,7 @@ part of 'enums.dart';
class UserRoleAdapter extends TypeAdapter<UserRole> {
@override
final typeId = 30;
final typeId = 33;
@override
UserRole read(BinaryReader reader) {
@@ -53,7 +53,7 @@ class UserRoleAdapter extends TypeAdapter<UserRole> {
class UserStatusAdapter extends TypeAdapter<UserStatus> {
@override
final typeId = 31;
final typeId = 34;
@override
UserStatus read(BinaryReader reader) {
@@ -98,7 +98,7 @@ class UserStatusAdapter extends TypeAdapter<UserStatus> {
class LoyaltyTierAdapter extends TypeAdapter<LoyaltyTier> {
@override
final typeId = 32;
final typeId = 35;
@override
LoyaltyTier read(BinaryReader reader) {
@@ -151,7 +151,7 @@ class LoyaltyTierAdapter extends TypeAdapter<LoyaltyTier> {
class OrderStatusAdapter extends TypeAdapter<OrderStatus> {
@override
final typeId = 33;
final typeId = 36;
@override
OrderStatus read(BinaryReader reader) {
@@ -216,7 +216,7 @@ class OrderStatusAdapter extends TypeAdapter<OrderStatus> {
class InvoiceTypeAdapter extends TypeAdapter<InvoiceType> {
@override
final typeId = 34;
final typeId = 37;
@override
InvoiceType read(BinaryReader reader) {
@@ -261,7 +261,7 @@ class InvoiceTypeAdapter extends TypeAdapter<InvoiceType> {
class InvoiceStatusAdapter extends TypeAdapter<InvoiceStatus> {
@override
final typeId = 35;
final typeId = 38;
@override
InvoiceStatus read(BinaryReader reader) {
@@ -318,7 +318,7 @@ class InvoiceStatusAdapter extends TypeAdapter<InvoiceStatus> {
class PaymentMethodAdapter extends TypeAdapter<PaymentMethod> {
@override
final typeId = 36;
final typeId = 39;
@override
PaymentMethod read(BinaryReader reader) {
@@ -375,7 +375,7 @@ class PaymentMethodAdapter extends TypeAdapter<PaymentMethod> {
class PaymentStatusAdapter extends TypeAdapter<PaymentStatus> {
@override
final typeId = 37;
final typeId = 40;
@override
PaymentStatus read(BinaryReader reader) {
@@ -428,7 +428,7 @@ class PaymentStatusAdapter extends TypeAdapter<PaymentStatus> {
class EntryTypeAdapter extends TypeAdapter<EntryType> {
@override
final typeId = 38;
final typeId = 41;
@override
EntryType read(BinaryReader reader) {
@@ -477,7 +477,7 @@ class EntryTypeAdapter extends TypeAdapter<EntryType> {
class EntrySourceAdapter extends TypeAdapter<EntrySource> {
@override
final typeId = 39;
final typeId = 42;
@override
EntrySource read(BinaryReader reader) {
@@ -538,7 +538,7 @@ class EntrySourceAdapter extends TypeAdapter<EntrySource> {
class ComplaintStatusAdapter extends TypeAdapter<ComplaintStatus> {
@override
final typeId = 40;
final typeId = 43;
@override
ComplaintStatus read(BinaryReader reader) {
@@ -587,7 +587,7 @@ class ComplaintStatusAdapter extends TypeAdapter<ComplaintStatus> {
class GiftCategoryAdapter extends TypeAdapter<GiftCategory> {
@override
final typeId = 41;
final typeId = 44;
@override
GiftCategory read(BinaryReader reader) {
@@ -636,7 +636,7 @@ class GiftCategoryAdapter extends TypeAdapter<GiftCategory> {
class GiftStatusAdapter extends TypeAdapter<GiftStatus> {
@override
final typeId = 42;
final typeId = 45;
@override
GiftStatus read(BinaryReader reader) {
@@ -681,7 +681,7 @@ class GiftStatusAdapter extends TypeAdapter<GiftStatus> {
class PointsStatusAdapter extends TypeAdapter<PointsStatus> {
@override
final typeId = 43;
final typeId = 46;
@override
PointsStatus read(BinaryReader reader) {
@@ -722,7 +722,7 @@ class PointsStatusAdapter extends TypeAdapter<PointsStatus> {
class ProjectTypeAdapter extends TypeAdapter<ProjectType> {
@override
final typeId = 44;
final typeId = 47;
@override
ProjectType read(BinaryReader reader) {
@@ -779,7 +779,7 @@ class ProjectTypeAdapter extends TypeAdapter<ProjectType> {
class SubmissionStatusAdapter extends TypeAdapter<SubmissionStatus> {
@override
final typeId = 45;
final typeId = 48;
@override
SubmissionStatus read(BinaryReader reader) {
@@ -828,7 +828,7 @@ class SubmissionStatusAdapter extends TypeAdapter<SubmissionStatus> {
class DesignStatusAdapter extends TypeAdapter<DesignStatus> {
@override
final typeId = 46;
final typeId = 49;
@override
DesignStatus read(BinaryReader reader) {
@@ -885,7 +885,7 @@ class DesignStatusAdapter extends TypeAdapter<DesignStatus> {
class QuoteStatusAdapter extends TypeAdapter<QuoteStatus> {
@override
final typeId = 47;
final typeId = 50;
@override
QuoteStatus read(BinaryReader reader) {
@@ -946,7 +946,7 @@ class QuoteStatusAdapter extends TypeAdapter<QuoteStatus> {
class RoomTypeAdapter extends TypeAdapter<RoomType> {
@override
final typeId = 48;
final typeId = 51;
@override
RoomType read(BinaryReader reader) {
@@ -995,7 +995,7 @@ class RoomTypeAdapter extends TypeAdapter<RoomType> {
class ContentTypeAdapter extends TypeAdapter<ContentType> {
@override
final typeId = 49;
final typeId = 52;
@override
ContentType read(BinaryReader reader) {
@@ -1056,7 +1056,7 @@ class ContentTypeAdapter extends TypeAdapter<ContentType> {
class ReminderTypeAdapter extends TypeAdapter<ReminderType> {
@override
final typeId = 50;
final typeId = 53;
@override
ReminderType read(BinaryReader reader) {

View File

@@ -8,10 +8,12 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:worker/features/account/domain/entities/address.dart';
import 'package:worker/features/account/presentation/pages/address_form_page.dart';
import 'package:worker/features/account/presentation/pages/addresses_page.dart';
import 'package:worker/features/auth/presentation/providers/auth_provider.dart';
import 'package:worker/features/account/presentation/pages/change_password_page.dart';
import 'package:worker/features/account/presentation/pages/profile_edit_page.dart';
import 'package:worker/features/auth/presentation/providers/auth_provider.dart';
import 'package:worker/features/auth/domain/entities/business_unit.dart';
import 'package:worker/features/auth/presentation/pages/business_unit_selection_page.dart';
import 'package:worker/features/auth/presentation/pages/forgot_password_page.dart';
@@ -369,6 +371,19 @@ final routerProvider = Provider<GoRouter>((ref) {
MaterialPage(key: state.pageKey, child: const AddressesPage()),
),
// Address Form Route (Create/Edit)
GoRoute(
path: RouteNames.addressForm,
name: RouteNames.addressForm,
pageBuilder: (context, state) {
final address = state.extra as Address?;
return MaterialPage(
key: state.pageKey,
child: AddressFormPage(address: address),
);
},
),
// Change Password Route
GoRoute(
path: RouteNames.changePassword,