"use client";
import useAxios from "@/hooks/useAxios";
import { IProfileData } from "@/types/types";
import React, { useEffect, useState } from "react";

function AuthUserDetails() {
  const [userDetail, setUserDetail] = useState<IProfileData | null>(null);
  const { request } = useAxios();
  // Fetch user data
  const fetchData = async () => {
    try {
      const response = await request<{ user: IProfileData }>("GET", "/profile");
      setUserDetail(response?.user || null);
    } catch (err) {
      console.log(err);
    }
  };
  useEffect(() => {
    fetchData();
  }, []);

  return (
    <>
      <span className="text-lg font-bold">
        {userDetail?.first_name} {userDetail?.last_name}
      </span>
      <p className="text-sm text-gray-500">{userDetail?.user_name}</p>
    </>
  );
}

export default AuthUserDetails;
