Skip to content

Conversation

@gustaavik
Copy link
Member

This pull request introduces several updates to enhance the handling of product variants across the backend and frontend. The changes include the addition of a new UpdateVariantRequest structure, updates to request parameter handling, and improvements to error handling for variant-related operations.

Backend Changes

Data Structures:

  • Added UpdateVariantRequest struct to represent the data needed to update an existing product variant in internal/dto/product.go. This includes fields for SKU, Price, Stock, Attributes, Images, and IsDefault.

API Endpoint Logic:

  • Updated UpdateVariant and DeleteVariant methods in internal/interfaces/api/handler/product_handler.go to use productId and variantId instead of id and variant_id for URL parameters. [1] [2] [3] [4]
  • Replaced the use of CreateVariantRequest with UpdateVariantRequest in the UpdateVariant method and added conditional checks to handle optional fields (Price, Stock, IsDefault). [1] [2]
  • Improved error handling in AddVariant, UpdateVariant, and DeleteVariant methods by removing seller-specific authorization checks and refining error messages for better clarity. [1] [2] [3]

Frontend Changes

Type Definitions:

  • Added UpdateVariantRequest interface in web/types/api.ts to mirror the backend structure for updating product variants. This includes fields for sku, price, stock, attributes, images, and is_default.

…s; update handler methods to utilize new structure
@gustaavik gustaavik merged commit 2ce785a into main Jun 14, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants