import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:niogu_app/features/auth/presentation/screens/admin_login_screen.dart';
import 'package:niogu_app/features/auth/presentation/screens/forgot_password_screen.dart';
import 'package:niogu_app/features/auth/presentation/screens/owner_login_screen.dart';
import 'package:niogu_app/features/auth/presentation/screens/registration_screen.dart';
import 'package:niogu_app/features/auth/presentation/screens/verification_otp_screen.dart';
import 'package:niogu_app/features/customer/domain/entities/customer.dart';
import 'package:niogu_app/features/customer/presentation/screens/add_customer_screen.dart';
import 'package:niogu_app/features/customer/presentation/screens/customer_activities_screen.dart';
import 'package:niogu_app/features/customer/presentation/screens/customer_addresses_screen.dart';
import 'package:niogu_app/features/customer/presentation/screens/customer_screen.dart';
import 'package:niogu_app/features/customer/presentation/screens/edit_customer_screen.dart';
import 'package:niogu_app/features/customer/presentation/screens/map_customer_address_screen.dart';
import 'package:niogu_app/features/goods/presentation/screens/good_choice_screen.dart';
import 'package:niogu_app/features/goods/presentation/screens/good_screen.dart';
import 'package:niogu_app/features/goods/raw_materials/presentation/screens/add_raw_material_screen.dart';
import 'package:niogu_app/features/goods/raw_materials/presentation/screens/product_usage_raw_material_screen.dart';
import 'package:niogu_app/features/goods/raw_materials/presentation/screens/edit_raw_material_screen.dart';
import 'package:niogu_app/features/goods/products/presentation/screens/add_product_screen.dart';
import 'package:niogu_app/features/goods/products/presentation/screens/add_product_variant_screen.dart';
import 'package:niogu_app/features/goods/products/presentation/screens/edit_product_screen.dart';
import 'package:niogu_app/features/goods/products/presentation/screens/edit_product_variant_screen.dart';
import 'package:niogu_app/features/home/presentation/screens/home_screen.dart';
import 'package:niogu_app/features/online_store/domain/entities/online_store.dart';
import 'package:niogu_app/features/online_store/presentation/screens/add_campaign_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/campaign_screen.dart';
import 'package:niogu_app/features/profile/domain/entities/profile.dart';
import 'package:niogu_app/features/profile/presentation/screens/change_password_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/configure_online_store_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/detail_product_review_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/edit_campaign_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/full_product_review_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/link_campaign_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/online_store_order_detail_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/online_store_order_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/online_store_product_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/online_store_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/payment_method_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/product_review_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/rating_configuration_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/shipping_configuration_screen.dart';
import 'package:niogu_app/features/online_store/presentation/screens/target_outlet_screen.dart';
import 'package:niogu_app/features/outlets/domain/entities/outlet.dart';
import 'package:niogu_app/features/outlets/presentation/screens/add_outlet_screen.dart';
import 'package:niogu_app/features/outlets/presentation/screens/edit_outlet_screen.dart';
import 'package:niogu_app/features/outlets/presentation/screens/edit_staff_admin_screen.dart';
import 'package:niogu_app/features/outlets/presentation/screens/map_outlet_address_screen.dart';
import 'package:niogu_app/features/outlets/presentation/screens/outlet_screen.dart';
import 'package:niogu_app/features/pos/presentation/screens/already_customer_screen.dart';
import 'package:niogu_app/features/pos/presentation/screens/pos_screen.dart';
import 'package:niogu_app/features/profile/presentation/screens/business_info_screen.dart';
import 'package:niogu_app/features/profile/presentation/screens/outlet_info_screen.dart';
import 'package:niogu_app/features/profile/presentation/screens/profil_info_screen.dart';
import 'package:niogu_app/features/profile/presentation/screens/profile_screen.dart';
import 'package:niogu_app/features/report/presentation/screens/report_screen.dart';
import 'package:niogu_app/features/report/stock_report/domain/entities/stok_report.dart';
import 'package:niogu_app/features/report/stock_report/presentation/screens/stock_report_detail_screen.dart';
import 'package:niogu_app/features/report/transaction/domain/entities/transaction_report.dart';
import 'package:niogu_app/features/report/transaction/presentation/screens/transaction_report_order_detail_screen.dart';
import 'package:niogu_app/features/report/transaction/presentation/screens/transaction_report_purchase_detail_screen.dart';
import 'package:niogu_app/features/splash/screens/splash_screen.dart';
import 'package:niogu_app/features/stock_check/presentation/screens/stock_check_screen.dart';
import 'package:niogu_app/features/stock_in/presentation/screens/display_item_screen.dart';
import 'package:niogu_app/features/stock_in/presentation/screens/stock_in_screen.dart';
import 'package:niogu_app/features/stock_in/domain/entities/stock_in.dart';
import 'package:niogu_app/features/stock_in/presentation/screens/already_supplier_screen.dart';
import 'package:niogu_app/features/supplier/domain/entities/supplier.dart';
import 'package:niogu_app/features/supplier/presentation/screens/add_supplier_screen.dart';
import 'package:niogu_app/features/supplier/presentation/screens/edit_supplier_screen.dart';
import 'package:niogu_app/features/supplier/presentation/screens/supplier_activites_screen.dart';
import 'package:niogu_app/features/supplier/presentation/screens/supplier_screen.dart';
import 'package:niogu_app/main_wrapper.dart';

final _rootNavigatorKey = GlobalKey<NavigatorState>();

class AppRoute {
  static final String splashScreen = 'splash';
  static final String ownerLoginScreen = 'ownerLogin';
  static final String adminLoginScreen = 'adminLogin';
  static final String registrationScreen = 'registrationScreen';
  static final String forgotPasswordScreen = 'forgotPasswordScreen';
  static final String verificationOtpScreen = 'verificationOtp';
  static final String homeScreen = 'home';
  static final String stockCheckScreen = 'stockCheck';
  static final String stockInScreen = 'stockIn';
  static final String alreadySupplierScreen = 'alreadySupplier';
  static final String selectGoodScreen = 'selectGood';
  static final String customerScreen = 'customer';
  static final String addCustomerScreen = 'addCustomer';
  static final String editCustomerScreen = 'editCustomer';
  static final String mapCustomerAddressScreen = 'mapCustomerAddress';
  static final String customerAddressesScreen = 'customerAddresses';
  static final String customerActivitesScreen = 'customerActivites';
  static final String supplierScreen = 'supplier';
  static final String addSupplierScreen = 'addSupplier';
  static final String editSupplierScreen = 'editSupplier';
  static final String supplierActivityScreen = 'supplierActivities';
  static final String onlineStoreScreen = 'onlineStore';
  static final String configureStoreOnlineScreen = 'configureStoreOnline';
  static final String onlineStoreProductScreen = 'onlineStoreProduct';
  static final String onlineStoreOrderScreen = 'onlineStoreOrder';
  static final String onlineStoreOrderDetilScreen = 'onlineStoreOrderDetail';
  static final String shippingConfigurationScreen = 'shippingConfiguration';
  static final String paymentMethodScreen = 'paymentMethod';
  static final String productReviewScreen = 'productReview';
  static final String detailProductReviewScreen = 'detailProductReview';
  static final String fullProductReviewScreen = 'fullProductReview';
  static final String ratingConfigurationScreen = 'ratingConfiguration';
  static final String campaignScreen = 'campaigns';
  static final String addCampaignScreen = 'addCampaign';
  static final String editCampaignScreen = 'editCampaign';
  static final String linkCampaignScreen = 'linkCampaign';
  static final String targetOutletScreen = 'targetOutlet';
  static final String outletScreen = 'outlet';
  static final String addOutletScreen = 'addOutlet';
  static final String editOutletScreen = 'editOutlet';
  static final String editStaffAdminScreen = 'editStaffAdmin';
  static final String mapOutletAdressScreen = 'mapOutletAdress';
  static final String productScreen = 'products';
  static final String addProductScreen = "addProduct";
  static final String productChoiceScreen = 'productChoice';
  static final String editProductScreen = "editProduct";
  static final String addVariantProductScreen = "addVariantProduct";
  static final String editVariantProductScreen = "editVariantProduct";
  static final String addRawMaterialScreen = 'addRawMaterial';
  static final String rawMaterialChoiceScreen = 'rawMaterialChoice';
  static final String productUsageRawMaterialScreen = 'productUsageRawMaterial';
  static final String editRawMaterialScreen = 'editRawMaterial';
  static final String posScreen = 'pos';
  static final String alreadyCustomerScreen = 'alreadyCustomer';
  static final String transactionReportScreen = 'transactionReport';
  static final String transactionReportOrderDetailScreen =
      'transactionReportOrderDetail';
  static final String transactionReportPurchaseDetailScreen =
      'transactionReportPurchaseDetail';
  static final String stockReportDetailScreen = 'stockReportDetail';
  static final String profileScreen = 'profile';
  static final String profileInfoScreen = 'profileInfo';
  static final String businessInfoScreen = 'businessInfo';
  static final String outletInfoScreen = 'outletInfo';
  static final String changePasswordScreen = 'changePassword';

  static final router = GoRouter(
    navigatorKey: _rootNavigatorKey,
    initialLocation: '/splash',
    routes: [
      GoRoute(
        name: splashScreen,
        path: '/splash',
        builder: (context, state) => const SplashScreen(),
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: ownerLoginScreen,
        path: '/auth/owner/login',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const OwnerLoginScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: adminLoginScreen,
        path: '/auth/admin/login',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const AdminLoginScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: registrationScreen,
        path: '/auth/registration',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const RegistrationScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: forgotPasswordScreen,
        path: '/auth/forgot-password',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const ForgotPasswordScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: verificationOtpScreen,
        path: '/auth/verification-otp',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const VerificationOtpScreen(identifier: '081234567890'),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      StatefulShellRoute.indexedStack(
        builder: (context, state, navigationShell) {
          return MainWrapper(navigationShell: navigationShell);
        },
        branches: [
          StatefulShellBranch(
            routes: [
              GoRoute(
                name: homeScreen,
                path: '/home',
                builder: (context, state) => const HomeScreen(),
              ),
            ],
          ),
          StatefulShellBranch(
            routes: [
              GoRoute(
                name: productScreen,
                path: '/products',
                builder: (context, state) => const GoodScreen(),
              ),
            ],
          ),
          StatefulShellBranch(
            routes: [
              GoRoute(
                name: posScreen,
                path: '/pos',
                builder: (context, state) => const PosScreen(),
              ),
            ],
          ),
          StatefulShellBranch(
            routes: [
              GoRoute(
                name: transactionReportScreen,
                path: '/transactionReport',
                builder: (context, state) => const ReportScreen(),
              ),
            ],
          ),
          StatefulShellBranch(
            routes: [
              GoRoute(
                name: profileScreen,
                path: '/profile',
                builder: (context, state) => const ProfileScreen(),
              ),
            ],
          ),
        ],
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: stockCheckScreen,
        path: '/stock-check',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const StockCheckScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: stockInScreen,
        path: '/stock-in',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const StockInScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: alreadySupplierScreen,
        path: '/already-supplier',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const AlreadySupplierScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: selectGoodScreen,
        path: '/select-good',
        pageBuilder: (context, state) {
          final Map<String, dynamic> data = state.extra as Map<String, dynamic>;

          final type = data["type"] as SelectedItemType;

          final onPressed = data["on_pressed"] as VoidCallback? ?? null;

          return CustomTransitionPage(
            key: state.pageKey,
            child: DisplayItemScreen(type: type, onPressed: onPressed),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: customerScreen,
        path: '/customers',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const CustomerScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: addCustomerScreen,
        path: '/customers/add',
        pageBuilder: (context, state) {
          final Map<String, dynamic>? data =
              state.extra as Map<String, dynamic>?;

          final String? initialName = data?["name"];

          final String? initialPhone = data?["phone"];

          return CustomTransitionPage(
            key: state.pageKey,
            child: AddCustomerScreen(
              initialName: initialName,
              initialPhone: initialPhone,
            ),
            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: editCustomerScreen,
        path: '/customers/edit/:id',
        pageBuilder: (context, state) {
          final customerId = state.pathParameters["id"];
          return CustomTransitionPage(
            key: state.pageKey,
            child: EditCustomerScreen(customerId: customerId!),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: customerAddressesScreen,
        path: '/customers/addresses',
        pageBuilder: (context, state) {
          final List<CustomerAddress> addresses =
              state.extra as List<CustomerAddress>;

          return CustomTransitionPage(
            key: state.pageKey,
            child: CustomerAddressesScreen(addresses: addresses),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: mapCustomerAddressScreen,
        path: '/customers/address/map',
        pageBuilder: (context, state) {
          final address = state.extra as CustomerAddress;
          return CustomTransitionPage(
            key: state.pageKey,
            child: MapCustomerAddressScreen(address: address),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: customerActivitesScreen,
        path: '/customers/activities',
        pageBuilder: (context, state) {
          final data = state.extra as Map<String, dynamic>;

          final bool isOnlineCustomer = data["is_online_customer"];

          final List<CustomerActivities> activites = data["activities"];

          return CustomTransitionPage(
            key: state.pageKey,
            child: CustomerActivitiesScreen(
              isOnlineCustomer: isOnlineCustomer,
              activities: activites,
            ),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: supplierScreen,
        path: '/suppliers',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const SupplierScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: addSupplierScreen,
        path: '/suppliers/add',
        pageBuilder: (context, state) {
          final Map<String, dynamic>? data =
              state.extra as Map<String, dynamic>?;

          final String? initialName = data?["name"];

          final String? initialPhone = data?["phone"];

          return CustomTransitionPage(
            key: state.pageKey,
            child: AddSupplierScreen(
              initialName: initialName,
              initialPhone: initialPhone,
            ),
            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: editSupplierScreen,
        path: '/suppliers/edit/:id',
        pageBuilder: (context, state) {
          final supplierId = state.pathParameters["id"];
          return CustomTransitionPage(
            key: state.pageKey,
            child: EditSupplierScreen(supplierId: supplierId!),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: supplierActivityScreen,
        path: '/suppliers/activities',
        pageBuilder: (context, state) {
          final data = state.extra as Map<String, dynamic>;

          final List<SupplierActivities> activites = data["activities"];

          return CustomTransitionPage(
            key: state.pageKey,
            child: SupplierActivitesScreen(activities: activites),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: onlineStoreScreen,
        path: '/online-store',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const OnlineStoreScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: configureStoreOnlineScreen,
        path: '/online-store/configure',
        pageBuilder: (context, state) {
          final configure = state.extra as ConfigureOnlineStore;

          return CustomTransitionPage(
            key: state.pageKey,
            child: ConfigureOnlineStoreScreen(configure: configure),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: onlineStoreProductScreen,
        path: '/online-store/products',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const OnlineStoreProductScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: onlineStoreOrderScreen,
        path: '/online-store/orders',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const OnlineStoreOrdersScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: onlineStoreOrderDetilScreen,
        path: '/online-store/orders/detail',
        pageBuilder: (context, state) {
          final detail = state.extra as OnlineOrderDetail;

          return CustomTransitionPage(
            key: state.pageKey,
            child: OnlineStoreOrderDetailScreen(detail: detail),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: shippingConfigurationScreen,
        path: '/shipping-configuration',
        pageBuilder: (context, state) {
          final configuration = state.extra as ShippingConfiguration;

          return CustomTransitionPage(
            key: state.pageKey,
            child: ShippingConfigurationScreen(configuration: configuration),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: paymentMethodScreen,
        path: '/payment-method',
        pageBuilder: (context, state) {
          final configures = state.extra as List<ConfigurePaymentMethod>;

          return CustomTransitionPage(
            key: state.pageKey,
            child: PaymentMethodsScreen(configures: configures),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: productReviewScreen,
        path: '/product-reviews',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const ProductReviewScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: detailProductReviewScreen,
        path: '/product-reviews/detail/:id',
        pageBuilder: (context, state) {
          final productId = state.pathParameters["id"]!;
          return CustomTransitionPage(
            key: state.pageKey,
            child: DetailProductReviewScreen(productId: productId),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: fullProductReviewScreen,
        path: '/product-reviews/detail/:id/full-reviews',
        pageBuilder: (context, state) {
          final productId = state.pathParameters["id"]!;
          return CustomTransitionPage(
            key: state.pageKey,
            child: FullProductReviewScreen(productId: productId),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: ratingConfigurationScreen,
        path: '/rating-configuration',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const RatingConfigurationScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: campaignScreen,
        path: '/campaigns',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const CampaignScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: addCampaignScreen,
        path: '/campaigns/add',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const AddCampaignScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: editCampaignScreen,
        path: '/campaigns/edit/:id',
        pageBuilder: (context, state) {
          final campaignId = state.pathParameters["id"]!;

          return CustomTransitionPage(
            key: state.pageKey,
            child: EditCampaignScreen(campaignId: campaignId),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: linkCampaignScreen,
        path: '/link-campaign',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const LinkCampaignScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: targetOutletScreen,
        path: '/target-outlet',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const TargetOutletScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: outletScreen,
        path: '/outlets',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const OutletScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: addOutletScreen,
        path: '/outlets/add',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const AddOutletScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: editOutletScreen,
        path: '/outlets/edit/:id',
        pageBuilder: (context, state) {
          final outletId = state.pathParameters["id"];
          return CustomTransitionPage(
            key: state.pageKey,
            child: EditOutletScreen(outletId: outletId!),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: editStaffAdminScreen,
        path: '/outlets/staff-admin',
        pageBuilder: (context, state) {
          final Map<String, dynamic> data = state.extra as Map<String, dynamic>;

          final String outletId = data["outlet_id"];

          final List<StaffAdminDetail> admins = data["admins"];

          return CustomTransitionPage(
            key: state.pageKey,
            child: EditStaffAdminScreen(outletId: outletId, admins: admins),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: mapOutletAdressScreen,
        path: '/outlets/adress/map',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const MapOutletAddressScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: addProductScreen,
        path: '/products/add',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const AddProductScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: productChoiceScreen,
        path: '/products/choices',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const GoodChoiceScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: editProductScreen,
        path: '/products/edit/:id',
        pageBuilder: (context, state) {
          final productId = state.pathParameters["id"];

          final data = state.extra as Map<String, dynamic>;

          final isMainOutlet = data["is_main_outlet"] ?? false;

          final isEditing = data["is_editing"] ?? true;

          final hasNewVariant = data["has_new_variant"] ?? false;

          final newVariantCount = data["new_variant_count"] ?? 0;

          return CustomTransitionPage(
            key: state.pageKey,
            child: EditProductScreen(
              productId: productId!,
              isMainOutlet: isMainOutlet,
              isEditing: isEditing,
              hasNewVariant: hasNewVariant,
              newVariantCount: newVariantCount,
            ),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: addVariantProductScreen,
        path: '/products/variant/add',
        pageBuilder: (context, state) {
          final data = state.extra as Map<String, bool>;

          final isMainOutlet = data["is_main_outlet"] ?? false;

          final isStockFixed = data["is_stock_fixed"] ?? false;

          return CustomTransitionPage(
            key: state.pageKey,
            child: AddProductVariantScreen(
              isMainOutlet: isMainOutlet,
              isStockFixed: isStockFixed,
            ),
            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: editVariantProductScreen,
        path: '/products/variant/edit/:id',
        pageBuilder: (context, state) {
          final String? productId = state.pathParameters["id"];

          final data = state.extra as Map<String, bool>;

          final bool isMainOutlet = data["is_main_outlet"]!;

          final bool isEditing = data["is_editing"]!;

          final bool hasNewVariant = data["has_new_variant"]!;

          final bool isStockFixed = data["is_stock_fixed"]!;

          return CustomTransitionPage(
            key: state.pageKey,
            child: EditProductVariantScreen(
              productId: productId!,
              isMainOutlet: isMainOutlet,
              isEditing: isEditing,
              hasNewVariant: hasNewVariant,
              isStockFixed: isStockFixed,
            ),
            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: addRawMaterialScreen,
        path: '/raw-materials/add',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const AddRawMaterialScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: rawMaterialChoiceScreen,
        path: '/raw-materials/choices',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const GoodChoiceScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: editRawMaterialScreen,
        path: '/raw-materials/edit/:id',
        pageBuilder: (context, state) {
          final rawMaterialId = state.pathParameters["id"];

          final data = state.extra as Map<String, bool>;

          final isMainOutlet = data["is_main_outlet"] ?? false;

          final isEditing = data["is_editing"] ?? true;

          return CustomTransitionPage(
            key: state.pageKey,
            child: EditRawMaterialScreen(
              rawMaterialId: rawMaterialId!,
              isMainOutlet: isMainOutlet,
              isEditing: isEditing,
            ),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: productUsageRawMaterialScreen,
        path: '/raw-materials/product/usage',
        pageBuilder: (context, state) {
          final Map<String, dynamic> data = state.extra as Map<String, dynamic>;

          final String? rawMaterialId = data["raw-material-id"];

          final String unitName = data["unit-name"];

          final bool isMainOutlet = data["is_main_outlet"];

          final bool isEditing = data["is_editing"] ?? true;

          return CustomTransitionPage(
            key: state.pageKey,
            child: ProductUsageRawMaterialScreen(
              rawMaterialId: rawMaterialId,
              unitName: unitName,
              isMainOutlet: isMainOutlet,
              isEditing: isEditing,
            ),
            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: alreadyCustomerScreen,
        path: '/already-customer',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const AlreadyCustomerScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: transactionReportOrderDetailScreen,
        path: '/transaction-report-order-detail',
        pageBuilder: (context, state) {
          final OrderDetail orderDetail = state.extra as OrderDetail;

          return CustomTransitionPage(
            key: state.pageKey,
            child: TransactionReportOrderDetailScreen(orderDetail: orderDetail),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: transactionReportPurchaseDetailScreen,
        path: '/transaction-report-purchase-detail',
        pageBuilder: (context, state) {
          final PurchaseDetail purchaseDetail = state.extra as PurchaseDetail;

          return CustomTransitionPage(
            key: state.pageKey,
            child: TransactionReportPurchaseDetailScreen(
              purchaseDetail: purchaseDetail,
            ),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: stockReportDetailScreen,
        path: '/stok-report-detail-screen',
        pageBuilder: (context, state) {
          final StockReportDetail stockReportDetail =
              state.extra as StockReportDetail;

          return CustomTransitionPage(
            key: state.pageKey,
            child: StockReportDetailScreen(
              stockReportDetail: stockReportDetail,
            ),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: profileInfoScreen,
        path: '/profile-info',
        pageBuilder: (context, state) {
          final profileInfo = state.extra as ProfileInfo;

          return CustomTransitionPage(
            key: state.pageKey,
            child: ProfileInfoScreen(profileInfo: profileInfo),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: businessInfoScreen,
        path: '/business-info',
        pageBuilder: (context, state) {
          final businessInfo = state.extra as BusinessInfo;

          return CustomTransitionPage(
            key: state.pageKey,
            child: BusinessInfoScreen(businessInfo: businessInfo),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: outletInfoScreen,
        path: '/outlet-info',
        pageBuilder: (context, state) {
          final outletInfo = state.extra as OutletInfo;
          return CustomTransitionPage(
            key: state.pageKey,
            child: OutletInfoScreen(outletInfo: outletInfo),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
      GoRoute(
        parentNavigatorKey: _rootNavigatorKey,
        name: changePasswordScreen,
        path: '/change-password',
        pageBuilder: (context, state) {
          return CustomTransitionPage(
            key: state.pageKey,
            child: const ChangePasswordScreen(),

            transitionsBuilder:
                (context, animation, secondaryAnimation, child) =>
                    FadeTransition(
                      opacity: CurveTween(
                        curve: Curves.easeIn,
                      ).animate(animation),
                      child: child,
                    ),
          );
        },
      ),
    ],
  );
}
