import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:vitalapp/architecture/types/kv.dart';
import 'package:vitalapp/components/cell.dart';
import 'package:vitalapp/components/dialog_select.dart';
import 'package:vitalapp/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;
                    }
                  },
                );
              },
            ),
          ],
        ),
      ],
    );
  }
}
