fix: cart delete mutation and console warnings
Some checks failed
Build and Deploy / build (push) Has been cancelled

- Fix checkoutLinesDelete mutation: use 'id' param and 'linesIds' instead of 'lineIds'
- Fix viewport metadata warning: move to separate viewport export in layout.tsx
- Add sizes prop to checkout Image with fill
- Fix CartDrawer init checkout useEffect to prevent re-render loops
- Various product detail improvements
This commit is contained in:
Unchained
2026-03-23 13:49:14 +02:00
parent 7f603c83e9
commit ace1ac104e
8 changed files with 95 additions and 20 deletions

View File

@@ -28,6 +28,7 @@ export {
getProducts,
getProductBySlug,
getProductPrice,
getProductPriceAmount,
getProductImage,
isProductAvailable,
formatPrice,

View File

@@ -50,8 +50,8 @@ export const CHECKOUT_LINES_UPDATE = gql`
`;
export const CHECKOUT_LINES_DELETE = gql`
mutation CheckoutLinesDelete($checkoutId: ID!, $lineIds: [ID!]!) {
checkoutLinesDelete(checkoutId: $checkoutId, lineIds: $lineIds) {
mutation CheckoutLinesDelete($id: ID!, $linesIds: [ID!]!) {
checkoutLinesDelete(id: $id, linesIds: $linesIds) {
checkout {
...CheckoutFragment
}

View File

@@ -68,6 +68,11 @@ export function getProductPrice(product: Product): string {
);
}
export function getProductPriceAmount(product: Product): number {
const variant = product.variants?.[0];
return variant?.pricing?.price?.gross?.amount || 0;
}
export function getProductImage(product: Product): string {
if (product.media && product.media.length > 0) {
return product.media[0].url;
@@ -88,7 +93,8 @@ export function formatPrice(amount: number, currency: string = "RSD"): string {
return new Intl.NumberFormat("sr-RS", {
style: "currency",
currency: currency,
minimumFractionDigits: 0,
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}).format(amount);
}