import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:test_sa/common_widgets/lookup_autocomplete_field.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/modules/asset_delivery_module/models/cost_center_model.dart';
import 'package:test_sa/modules/asset_inventory_module/models/asset_inventory_model.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';

class EndUserCostCenterCardView extends StatelessWidget {
  CostCenterModel costModel;
  VoidCallback? editPress;
  bool isViewOnly;

  EndUserCostCenterCardView({
    super.key,
    required this.costModel,
    this.editPress,
    required this.isViewOnly,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        //need to check this @waseem.
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Flexible(
              child: Text(
                'Cost Center Name: ${costModel.costCenterName ?? '-'}',
                overflow: TextOverflow.ellipsis,
                style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
              ),
            ),
            8.width,
            if (!isViewOnly)
              'edit_icon'.toSvgAsset(height: 18, width: 18).onPress(() {
                if (editPress != null) {
                  editPress!();
                }
              }),
          ],
        ),
        Text(
          'Accepted By: ${costModel.acceptedBy ?? '-'}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),Text(
          'Accepted By Email: ${costModel.acceptedByEmail ?? '-'}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),Text(
        'Acceptance Date: ${costModel.acceptanceDate!=null? costModel.acceptanceDate.toString().toAssetDetailsFormat: '-'}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
      ],
    ).toShadowContainer(context, borderRadius: 20, padding: 12);
  }
}
