fix: watchlist 500 from missing UUID and toast classList error
This commit is contained in:
@@ -30,15 +30,16 @@ func (h *WatchlistHandler) HandleUpdateWatchlist(c *gin.Context) {
|
|||||||
userID = u.ID
|
userID = u.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
animeID, _ := strconv.ParseInt(c.PostForm("anime_id"), 10, 64)
|
var body struct {
|
||||||
status := c.PostForm("status")
|
AnimeID int64 `json:"animeId"`
|
||||||
|
Status string `json:"status"`
|
||||||
if animeID <= 0 || status == "" {
|
}
|
||||||
|
if err := c.ShouldBindJSON(&body); err != nil || body.AnimeID <= 0 || body.Status == "" {
|
||||||
c.Status(http.StatusBadRequest)
|
c.Status(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := h.svc.UpdateEntry(c.Request.Context(), userID, animeID, status)
|
err := h.svc.UpdateEntry(c.Request.Context(), userID, body.AnimeID, body.Status)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Status(http.StatusInternalServerError)
|
c.Status(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import (
|
|||||||
"mal/integrations/jikan"
|
"mal/integrations/jikan"
|
||||||
"mal/internal/db"
|
"mal/internal/db"
|
||||||
"mal/internal/domain"
|
"mal/internal/domain"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type watchlistService struct {
|
type watchlistService struct {
|
||||||
@@ -34,6 +36,7 @@ func (s *watchlistService) UpdateEntry(ctx context.Context, userID string, anime
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, err = s.repo.UpsertWatchListEntry(ctx, db.UpsertWatchListEntryParams{
|
_, err = s.repo.UpsertWatchListEntry(ctx, db.UpsertWatchListEntryParams{
|
||||||
|
ID: uuid.New().String(),
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
AnimeID: animeID,
|
AnimeID: animeID,
|
||||||
Status: status,
|
Status: status,
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ const showToast = ({ message, duration = 3000 }: ToastOptions): void => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const toast = template.content.cloneNode(true) as HTMLElement;
|
const toast = template.content.cloneNode(true).firstElementChild as HTMLElement;
|
||||||
|
if (!toast) return;
|
||||||
const messageEl = toast.querySelector('.toast-message');
|
const messageEl = toast.querySelector('.toast-message');
|
||||||
const closeBtn = toast.querySelector('.toast-close');
|
const closeBtn = toast.querySelector('.toast-close');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user