"use client"

import { userLogin } from "@/components/label/api/label"
import { usePermissionStore } from "@/components/label/store/auth"
import { Button } from "@mantine/core"

export default function ComponentLabelLoginPage() {
  const { setUserInfo, setUserPassword } = usePermissionStore()
  const user_id = usePermissionStore.getState().user_id

  // 用户登录
  const handleUserLoginBtnClick = async () => {
    try {
      const res = await userLogin({
        name: "admin",
        password: "123456",
      })
      const { uid, name, token, refresh_token } = res
      setUserInfo({
        user_id: uid,
        user_name: name,
        token,
        refresh_token,
        detailInfo: res,
      })
      setUserPassword("123456")
    } catch (error) {
      console.log(error)
    }
  }
  return (
    <>
      <Button onClick={handleUserLoginBtnClick}>Login</Button>
      user_id:{user_id}
    </>
  )
}
