import 'package:diplomaticquarterapp/core/viewModels/medical/patient_sick_leave_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';

class PatientSickLeavePage extends StatefulWidget {
  @override
  _PatientSickLeavePageState createState() => _PatientSickLeavePageState();
}

class _PatientSickLeavePageState extends State<PatientSickLeavePage> {
  @override
  Widget build(BuildContext context) {
    return BaseView<PatientSickLeaveViewMode>(
      onModelReady: (model) => model.getSickLeave(),
      builder: (_, model, w) => AppScaffold(
        isShowAppBar: true,
        appBarTitle: 'Sick Leave',
        baseViewModel: model,
        body: Container(
          margin: EdgeInsets.all(12),
          child: ListView.builder(
            itemCount: model.sickLeaveList.length,
            itemBuilder: (context, index) => DoctorCard(
              name: model.sickLeaveList[index].doctorName,
              date: DateUtil.getMonthDayYearDateFormatted(
                  model.sickLeaveList[index].requestDate),
              profileUrl: model.sickLeaveList[index].doctorImageURL,
              rat: model.sickLeaveList[index].actualDoctorRate.toDouble(),
              subName: model.sickLeaveList[index].projectName,
              isInOutPatientDescription:
                  model.sickLeaveList[index].isInOutPatientDescription,
              onEmailTap: () {
                model.sendSickLeaveEmail(
                    message: TranslationBase.of(context).emailSentSuccessfully,
                    requestNo: model.sickLeaveList[index].requestNo,
                    doctorName: model.sickLeaveList[index].doctorName,
                    projectName: model.sickLeaveList[index].projectName,
                    setupID: model.sickLeaveList[index].setupID,
                    projectID: model.sickLeaveList[index].projectID);
              },
            ),
          ),
        ),
      ),
    );
  }
}
