import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/model/pharmacy-intervention-model/intervention_history.dart';
import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart';
import 'package:flutter/material.dart';

class InterventionHistoryItem extends StatelessWidget {
  final InterventionHistory interventionHistory;
  final Function(InterventionHistory, String) onAcceptClick;

  final Function(InterventionHistory, String) onRejectClick;
  final TextEditingController remarksController;


  InterventionHistoryItem({
    super.key,
    required this.interventionHistory,
    required this.onAcceptClick,
    required this.onRejectClick,
    required this.remarksController,

  });

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          AppText(
            interventionHistory.interventionDesc ?? '',
            fontWeight: FontWeight.w600,
            fontSize: 12,
            color: Color(0xFF2B353E),
          ),
          SizedBox(
            height: 4,
          ),
          AppText(
            "${TranslationBase
                .of(context)
                .commentedBy}: ${interventionHistory.commentedByName}",
            fontWeight: FontWeight.w600,
            fontSize: 12,
            color: Color(0xFF2B353E),
          ),
          AppText(
            "${TranslationBase
                .of(context)
                .remarks}: ${interventionHistory.remark?.isNotEmpty == true
                ? interventionHistory.remark
                : TranslationBase
                .of(context)
                .noRemarks}",
            fontWeight: FontWeight.w600,
            fontSize: 12,
            color: Color(0xFF2B353E),
          ),
          SizedBox(height: 8,),

          AppTextFieldCustom(
            hintText: TranslationBase.of(context).addDoctorRemarks,
            controller: remarksController,
            maxLines: 48,
            minLines: 2,
            hasBorder: true,
            inputType: TextInputType.multiline,
            onClick: () {},
            onChanged: (value) {},
            onFieldSubmitted: () {},
          ),
          SizedBox(height: 16,),
          Row(children: [
            Expanded(
              child: SizedBox(
                height: 48,
                child: AppButton(
                  title: TranslationBase
                      .of(context)
                      .reject,
                  hasBorder: true,
                  borderColor: Color(0xFFB8382B),
                  color: AppGlobal.appRedColor,
                  fontColor: Colors.white,
                  onPressed: () async {
                    if(remarksController.text.isEmpty == true) {
                      DrAppToastMsg.showErrorToast(TranslationBase.of(context).remarksNotAdded);
                      return;
                    }
                    onRejectClick(interventionHistory, remarksController.text);
                  },
                ),
              ),
            ),
            SizedBox(
              width: 6,
            ),
            Expanded(
              child: SizedBox(
                height: 48,
                child: AppButton(
                  title: TranslationBase
                      .of(context)
                      .accept,
                  hasBorder: true,
                  borderColor: AppGlobal.appGreenColor,
                  color: AppGlobal.appGreenColor,
                  fontColor: Colors.white,
                  onPressed: () async {
                    if(remarksController.text.isEmpty == true) {
                      DrAppToastMsg.showErrorToast(TranslationBase.of(context).remarksNotAdded);
                      return;
                    }
                    onAcceptClick(interventionHistory,remarksController.text);
                  },
                ),
              ),
            ),
          ]),
          SizedBox(height: 4,),

        ],
      ),
    );
  }

}
