import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

import '../features/cart/cart_screen.dart';
import '../features/discover/cafe_detail_screen.dart';
import '../features/discover/discover_screen.dart';
import '../features/hr/attendance_screen.dart';
import '../features/menu/menu_screen.dart';
import '../features/qr/qr_scan_screen.dart';
import '../features/reserve/reserve_screen.dart';
import '../features/track/track_screen.dart';

final appRouter = GoRouter(
  initialLocation: '/discover',
  routes: [
    GoRoute(path: '/discover', builder: (_, __) => const DiscoverScreen()),
    GoRoute(
      path: '/cafe/:slug',
      builder: (_, state) => CafeDetailScreen(slug: state.pathParameters['slug']!),
    ),
    GoRoute(path: '/qr', builder: (_, __) => const QrScanScreen()),
    GoRoute(path: '/hr/attendance', builder: (_, __) => const AttendanceScreen()),
    GoRoute(
      path: '/cafe/:slug/menu',
      builder: (context, state) {
        final slug = state.pathParameters['slug']!;
        final tableId = state.uri.queryParameters['tableId'];
        final tableNumber = state.uri.queryParameters['tableNumber'];
        return MenuScreen(slug: slug, tableId: tableId, tableNumber: tableNumber);
      },
    ),
    GoRoute(
      path: '/cafe/:slug/cart',
      builder: (_, state) => CartScreen(slug: state.pathParameters['slug']!),
    ),
    GoRoute(
      path: '/cafe/:slug/reserve',
      builder: (_, state) => ReserveScreen(slug: state.pathParameters['slug']!),
    ),
    GoRoute(
      path: '/order/:orderId/track',
      builder: (_, state) => TrackScreen(orderId: state.pathParameters['orderId']!),
    ),
  ],
);
