"use server"

import { fetchClient } from "./fetchClient"

export const pingServer = async (): Promise<boolean> => {
	try {
		await fetchClient.GET("/api/ping/")
		return true
	} catch (error) {
		console.error("Ping server error:", error)
		return false
	}
}

export const verifyToken = async (token: string): Promise<boolean> => {
	console.log("Verifying token:", token)
	try {
		const resp = await fetchClient.GET("/api/users/me/", {
			headers: {
				Authorization: `Bearer ${token}`,
			},
		})
		console.log("Verify token response:", resp)
		if (resp.error) return false
		return true
	} catch (error) {
		console.error("Verify token error:", error)
		return false
	}
}
