Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
fix: product upload img issue
Browse files Browse the repository at this point in the history
  • Loading branch information
foxminchan committed Jun 6, 2024
1 parent e39fab0 commit c7e2ad5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/RookieShop.ApiService/Endpoints/Products/Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public sealed class Update(ISender sender) : IEndpoint<Ok<UpdateProductResponse>
[FromForm] CategoryId? categoryId = null)
=> await HandleAsync(new(id, name, description, quantity, price, priceSale, status, productImages,
isDeletedOldImage, categoryId)))
.DisableAntiforgery()
.Produces<Ok<UpdateProductResponse>>()
.Produces<NotFound<string>>(StatusCodes.Status404NotFound)
.Produces<BadRequest<IEnumerable<ValidationError>>>(StatusCodes.Status400BadRequest)
Expand Down
5 changes: 4 additions & 1 deletion ui/backoffice/components/tables/product/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export const columns: ColumnDef<Product>[] = [
return description.length > 50 ? (
<Tooltip>
<TooltipTrigger asChild>
<span>{`${parse(description.slice(0, 50))}...`}</span>
<span>
{parse(description.substring(0, 120))}
<span className="text-blue-500">...</span>
</span>
</TooltipTrigger>
<TooltipContent>
<div className="p-4 text-sm w-80">{parse(description)}</div>
Expand Down
8 changes: 2 additions & 6 deletions ui/backoffice/features/product/product.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ class ProductService extends HttpService {
formData.append("priceSale", data.priceSale.toString())
formData.append("quantity", data.quantity.toString())
formData.append("categoryId", data.categoryId?.toString() ?? "")
if (data.productImages) {
formData.append("image", data.productImages)
}
formData.append("productImages", data.productImages ?? "")
return this.post(`/products`, formData, {
headers: { "Content-Type": "multipart/form-data" },
})
Expand All @@ -48,9 +46,7 @@ class ProductService extends HttpService {
formData.append("priceSale", data.priceSale.toString())
formData.append("quantity", data.quantity.toString())
formData.append("categoryId", data.categoryId?.toString() ?? "")
if (data.productImages) {
formData.append("image", data.productImages)
}
formData.append("productImages", data.productImages ?? "")
formData.append("status", data.status)
formData.append(
"isDeletedOldImage",
Expand Down

0 comments on commit c7e2ad5

Please sign in to comment.