import 'package:enaklo_pos/core/components/buttons.dart';
import 'package:enaklo_pos/core/constants/colors.dart';
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
import 'package:enaklo_pos/data/models/response/table_model.dart';
import 'package:enaklo_pos/presentation/home/dialog/type_dialog.dart';
import 'package:enaklo_pos/presentation/home/pages/dashboard_page.dart';
import 'package:enaklo_pos/presentation/sales/pages/sales_page.dart';
import 'package:flutter/material.dart';

class HomeRightTitle extends StatelessWidget {
  final TableModel? table;
  const HomeRightTitle({super.key, this.table});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: context.deviceHeight * 0.1,
      decoration: BoxDecoration(
        color: AppColors.primary,
        border: Border(
          left: BorderSide(
            color: Colors.white,
            width: 1.0,
          ),
        ),
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Row(
            children: [
              Expanded(
                child: Button.filled(
                  width: 180.0,
                  height: 40,
                  elevation: 0,
                  onPressed: () => context.push(SalesPage()),
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  icon: Icon(
                    Icons.list,
                    color: Colors.white,
                    size: 24,
                  ),
                  label: 'Daftar Pesanan',
                ),
              ),
              Expanded(
                child: Button.filled(
                  width: 180.0,
                  height: 40,
                  elevation: 0,
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  icon: Icon(
                    Icons.person_outline,
                    color: Colors.white,
                    size: 24,
                  ),
                  onPressed: () {
                    if (table == null) {
                      context.push(DashboardPage(
                        index: 1,
                      ));
                    }
                  },
                  label: 'Pelanggan',
                ),
              ),
            ],
          ),
          Row(
            children: [
              Expanded(
                child: Button.filled(
                  width: 180.0,
                  height: 40,
                  elevation: 0,
                  onPressed: () {
                    showDialog(
                        context: context,
                        builder: (context) {
                          return TypeDialog();
                        });
                  },
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  icon: Icon(
                    Icons.dinner_dining_outlined,
                    color: Colors.white,
                    size: 24,
                  ),
                  label: 'Dine In',
                ),
              ),
              Expanded(
                child: Button.filled(
                  width: 180.0,
                  height: 40,
                  elevation: 0,
                  icon: Icon(
                    Icons.table_restaurant_outlined,
                    color: Colors.white,
                    size: 24,
                  ),
                  onPressed: () {
                    if (table == null) {
                      context.push(DashboardPage(
                        index: 1,
                      ));
                    }
                  },
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  label: table == null ? 'Pilih Meja' : '${table!.id}',
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
