import { useState } from "react";
import { View } from "@tarojs/components";

import PageCustom from "@/components/page-custom/index";
import NavBarNormal from "@/components/NavBarNormal/index";
import WemetaButton from "@/components/buttons/WemetaButton";
import BottomBar from "@/components/BottomBar";

import WemetaTextarea from "@/components/wemeta-textarea/index";
import { useAgentStore } from "@/store/agentStore";
import useEditContactCard from "@/hooks/useEditContactCard";
export default function Index() {
  const agentContactCard = useAgentStore((state)=> state.agentContactCard)
  const {value, onChange, handleSubmit} = useEditContactCard('entName', agentContactCard?.entName)



  return (
    <PageCustom>
      <NavBarNormal backText="企业名称"></NavBarNormal>
      <View className="flex flex-col items-center w-full">
        <View
          className="w-full p-16"
        >
          <WemetaTextarea
            value={value}
            onBlur={(value: string) => onChange(value)}
            onInput={(value: string) => onChange(value)}
            placeholder="填写企业名称"
            autoFocus
            maxlength={20}
          />
        </View>
        <BottomBar>
          <WemetaButton className="flex-1" disabled={!value.length} onClick={handleSubmit}>保存</WemetaButton>
        </BottomBar>
      </View>
    </PageCustom>
  );
}
