import { useState, useEffect } from "react";
import { GetUserInfo, Logout } from "@/api";
import { message } from "antd";

export type UserInfo = {
  account: string;
  cellPhone: string;
  id: string;
  isActive: boolean;
  langName: string;
  language: string;
  partnerInfoId: string;
};
export default function userModel(){
  const [userInfo, setUserInfo] = useState<UserInfo>();

  const checkUserInfo = () => {
    GetUserInfo().then((res) => {
      setUserInfo(res?.result);
    });
  }

  const handleLogout = () => {
    Logout().then((res) => {
      message.success("退出成功");
      setUserInfo(undefined);
    });
  };

  return {
    userInfo,
    handleLogout,
    checkUserInfo
  };
};