// src/api/auth/register.ts
import instance from "../axiosInstance"
import { endpoints } from "@shared/contracts"

const { auth } = endpoints

export async function register(username: string, email: string, password: string) {
  try {
    const { data } = await instance.post("/auth/register", {
      username,
      email,
      password,
    })
    return auth.authResponseSchema.parse(data)
  } catch (error: any) {
    const message = error.response?.data?.message || "Kayıt başarısız"
    console.error("Register hatası:", message)
    throw new Error(message)
  }
}
