import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:secure_string_operations/secure_string_operations.dart';
import 'package:siro_admin/constant/box_name.dart';

import '../../../constant/info.dart';
import '../../../constant/char_map.dart';

import '../../../controller/drivers/driver_not_active_controller.dart';
import '../../../controller/functions/encrypt_decrypt.dart';
import '../../../main.dart';
import '../../../print.dart';
import 'driver_details_not_active_page.dart';

class DriversPendingPage extends StatelessWidget {
  final DriverController controller = Get.put(DriverController());

  DriversPendingPage({super.key});

  @override
  Widget build(BuildContext context) {
    controller.getDriversPending();
    Log.print(
        ': ${X.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs).toString().split(AppInformation.addd)[0]}');

    return Scaffold(
      appBar: AppBar(title: const Text("Drivers Pending")),
      body: GetBuilder<DriverController>(
        id: 'drivers',
        builder: (c) {
          if (c.drivers.isEmpty) {
            return Center(
              child: const Text('no drivers found yet',
                  style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
            );
          }
          return ListView.builder(
            itemCount: c.drivers.length,
            itemBuilder: (ctx, i) {
              final d = c.drivers[i];
              return ListTile(
                title: Text(d["first_name"] + d['last_name'] ?? ""),
                subtitle: Text(d["phone"] ?? ""),
                onTap: () {
                  Get.to(() => DriverDetailsPage(driverId: d["id"].toString()));
                },
              );
            },
          );
        },
      ),
    );
  }
}
