import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:vnoteapp/architecture/types/kv.dart';
import 'package:vnoteapp/components/cell.dart';
import 'package:vnoteapp/components/dialog_select.dart';
import 'package:vnoteapp/pages/patient/create/controller.dart';

class Area extends GetView<CreatePatientController> {
  const Area({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        VListFormCellGroup(
          children: [
            VListFormCell(
              label: "签约机构",
              content: controller.state.organizationName,
            ),
            Obx(
              () {
                return VListFormCell(
                  label: "签约区域",
                  content: controller.state.villageName,
                  onTap: () async {
                    final result = await VDialogSelect<StringKVModel, String>(
                      title: "选择签约区域",
                      source: controller.state.villageOptions,
                      valueGetter: (data) => data.key,
                      labelGetter: (data) => data.value,
                      initialValue: controller.state.villageCode,
                    ).show();
                    if (result != null) {
                      controller.state.villageCode = result;
                    }
                  },
                );
              },
            ),
          ],
        ),
      ],
    );
  }
}
