Fix some lint error + change error handling

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-21 11:06:54 +04:00
parent d3333fd137
commit 937a0079fc
3 changed files with 5 additions and 7 deletions

View File

@@ -154,8 +154,8 @@ export function CategorySection({ categoryKey, onDelete }: CategorySectionProps)
const [updateCategory, isUpdating]
= useMutation<CategorySectionUpdateMutation>(updateCategoryMutation);
const [moveCookie] =
useMutation<CategorySectionMoveCookieMutation>(moveCookieMutation);
const [moveCookie]
= useMutation<CategorySectionMoveCookieMutation>(moveCookieMutation);
const [isEditingCategory, setIsEditingCategory] = useState(false);
const [editingCookieIndex, setEditingCookieIndex] = useState<number | null>(null);

View File

@@ -920,13 +920,14 @@ type MoveCookieToCategoryResult struct {
func (s *Service) MoveCookieToCategory(
ctx context.Context,
scope coredata.Scoper,
req MoveCookieToCategoryRequest,
) (*MoveCookieToCategoryResult, error) {
if err := req.Validate(); err != nil {
return nil, fmt.Errorf("invalid request: %w", err)
}
scope := coredata.NewScopeFromObjectID(req.SourceCookieCategoryID)
var result MoveCookieToCategoryResult
err := s.pg.WithTx(

View File

@@ -522,11 +522,8 @@ func (r *mutationResolver) MoveCookieToCategory(ctx context.Context, input types
return nil, err
}
scope := coredata.NewScopeFromObjectID(input.SourceCookieCategoryID)
result, err := r.cookieBanner.MoveCookieToCategory(
ctx,
scope,
cookiebanner.MoveCookieToCategoryRequest{
SourceCookieCategoryID: input.SourceCookieCategoryID,
TargetCookieCategoryID: input.TargetCookieCategoryID,
@@ -540,7 +537,7 @@ func (r *mutationResolver) MoveCookieToCategory(ctx context.Context, input types
case errors.Is(err, cookiebanner.ErrCookieNotFound):
return nil, gqlutils.NotFound(ctx, err)
case errors.Is(err, cookiebanner.ErrCategoriesBannerMismatch):
return nil, gqlutils.Invalidf(ctx, "source and target categories must belong to the same banner")
return nil, gqlutils.NotFoundf(ctx, "source or target category not found")
default:
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)