package controllers
import (
"net/http"
"github.com/danielrhuynh/busybar/internal/auth"
"github.com/danielrhuynh/busybar/internal/services"
"github.com/labstack/echo/v4"
)
func GetUserAchievements(c echo.Context) error {
userSession, err := auth.GetUser(c)
if err != nil {
return c.JSON(http.StatusUnauthorized, envelope{
"error": "Unauthorized",
})
}
achievements, err := services.GetUserAchievements(userSession.ID)
if err != nil {
return c.JSON(http.StatusInternalServerError, envelope{
"error": "Failed to retrieve achievements",
})
}
return c.JSON(http.StatusOK, envelope{
"achievements": achievements,
})
}