// src/api/account/uploadAvatar.ts
import instance from "../axiosInstance"

export async function uploadAvatar(file: File) {
  try {
    const formData = new FormData()
    formData.append("file", file)

    const { data } = await instance.post("/account/avatar", formData, {
      headers: {
        "Content-Type": "multipart/form-data",
      },
    })

    return data
  } catch (error: any) {
    const message = error.response?.data?.error || "Avatar yükleme hatası"
    console.error("Avatar yükleme hatası:", message)
    throw new Error(message)
  }
}
