chore: fix

This commit is contained in:
2026-03-14 15:28:40 +01:00
parent 9d52f3193a
commit 0043646cff
10 changed files with 156 additions and 77 deletions
+20
View File
@@ -50,6 +50,15 @@ func GetMyCompletedOrders(c *gin.Context) {
// ✅ Récupérer les infos client pour statistiques
client, err := database.GetClientByUsername(usernameStr)
// ✅ Récupérer les noms des pools de points
poolNames := []string{"Pool 1", "Pool 2"}
if settings, sErr := database.GetSettings(); sErr == nil && len(settings.PointsPools) > 0 {
poolNames = make([]string, len(settings.PointsPools))
for i, p := range settings.PointsPools {
poolNames[i] = p.Name
}
}
response := gin.H{
"success": true,
"commands": commands,
@@ -57,10 +66,21 @@ func GetMyCompletedOrders(c *gin.Context) {
}
if err == nil && client != nil {
// Construire le tableau générique des valeurs par pool
poolPoints := make([]int, len(poolNames))
if len(poolPoints) > 0 {
poolPoints[0] = client.Point
}
if len(poolPoints) > 1 {
poolPoints[1] = client.PointZipette
}
response["client_stats"] = gin.H{
"username": client.Username,
"total_commands": client.Command,
"points": client.Point,
"pool_points": poolPoints,
"pool_names": poolNames,
"penalties": client.Amende,
}
}
+12 -5
View File
@@ -952,16 +952,23 @@ func ResetClientPointAdmin(c *gin.Context) {
return
}
var req struct {
ResetCancellationsPoints bool `json:"reset_cancellations_points"`
Pool int `json:"pool"` // 0=pool principal, 1=pool secondaire, -1=tous (défaut)
}
if err := c.ShouldBindJSON(&req); err != nil {
req.ResetCancellationsPoints = false
req.Pool = -1 // défaut : reset total
if err := c.ShouldBindJSON(&req); err == nil {
// valeur reçue correctement
}
database := c.MustGet("database").(*db.Database)
err := database.ResetClientPoint(username, req.ResetCancellationsPoints)
extraPoolKey := ""
if req.Pool >= 2 {
if settings, err := database.GetSettings(); err == nil && req.Pool < len(settings.PointsPools) {
extraPoolKey = settings.PointsPools[req.Pool].Key
}
}
err := database.ResetClientPoint(username, req.Pool, extraPoolKey)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"error": "Erreur lors de la réinitialisation",
+9
View File
@@ -19,12 +19,21 @@ func GetPublicSettings(c *gin.Context) {
settings = db.DefaultSettings()
}
poolNames := make([]string, len(settings.PointsPools))
poolKeys := make([]string, len(settings.PointsPools))
for i, p := range settings.PointsPools {
poolNames[i] = p.Name
poolKeys[i] = p.Key
}
c.JSON(http.StatusOK, gin.H{
"success": true,
"penalties_enabled": settings.PenaltiesEnabled,
"show_amende_score": settings.ShowAmendeScore,
"points_enabled": settings.PointsEnabled,
"points_separated": len(settings.PointsPools) > 1,
"pool_names": poolNames,
"pool_keys": poolKeys,
"referral_enabled": settings.ReferralEnabled,
"delivery_schedule": settings.DeliverySchedule,
})