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

import PageCustom from "@/components/page-custom/index";
import NavBarNormal from "@/components/NavBarNormal/index";
import ButtonMain from "@/components/buttons/ButtonMain";
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('position', agentContactCard?.position)
  
  

  return (
    <PageCustom>
      <NavBarNormal>职位</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={40}
          />
        </View>
        <BottomBar>
          <ButtonMain className="flex-1" disabled={!value.length} onClick={handleSubmit}>保存</ButtonMain>
        </BottomBar>
      </View>
    </PageCustom>
  );
}
