import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:marco/view/employees/employee_detail_screen.dart';
import 'package:marco/view/document/user_document_screen.dart';
import 'package:marco/helpers/widgets/custom_app_bar.dart';

class EmployeeProfilePage extends StatefulWidget {
  final String employeeId;

  const EmployeeProfilePage({super.key, required this.employeeId});

  @override
  State<EmployeeProfilePage> createState() => _EmployeeProfilePageState();
}

class _EmployeeProfilePageState extends State<EmployeeProfilePage>
    with SingleTickerProviderStateMixin {
  late TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 2, vsync: this);
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFFF1F1F1),
      appBar: CustomAppBar(
        title: "Employee Profile",
        onBackPressed: () => Get.back(),
      ),
      body: Column(
        children: [
          // ---------------- TabBar outside AppBar ----------------
          Container(
            color: Colors.white,
            child: TabBar(
              controller: _tabController,
              labelColor: Colors.black,
              unselectedLabelColor: Colors.grey,
              indicatorColor: Colors.red,
              tabs: const [
                Tab(text: "Details"),
                Tab(text: "Documents"),
              ],
            ),
          ),

          // ---------------- TabBarView ----------------
          Expanded(
            child: TabBarView(
              controller: _tabController,
              children: [
                // Details Tab
                EmployeeDetailPage(
                  employeeId: widget.employeeId,
                  fromProfile: true,
                ),

                // Documents Tab
                UserDocumentsPage(
                  entityId: widget.employeeId,
                  isEmployee: true,
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
