Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/major-turtles-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@godaddy/localizations": patch
"@godaddy/react": patch
---

- Add filtering by `productIds` and `categoryIds` to ProductGrid
- Add `productId` prop to ProductCard for single product rendering
- Add pagination support to ProductGrid with `enablePagination` prop
- Add translations for pagination controls
6 changes: 5 additions & 1 deletion examples/nextjs/app/store/products.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
'use client';

import { ProductGrid } from '@godaddy/react';
import { ProductGrid, ProductSearch } from '@godaddy/react';
import { useCart } from './layout';

export default function ProductsPage() {
const { openCart } = useCart();

return (
<div className='container mx-auto'>
<div className='mb-6 max-w-md'>
<ProductSearch />
</div>
<ProductGrid
enablePagination
getProductHref={sku => `/store/product/${sku}`}
onAddToCartSuccess={openCart}
/>
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@tanstack/react-query": "^5.66.0",
"@tanstack/react-query-devtools": "^5.76.1",
"lucide-react": "^0.475.0",
"next": "16.0.1",
"next": "16.0.7",
"react": "19.2.0",
"react-dom": "19.2.0",
"zod": "^3.24.1"
Expand Down
3 changes: 3 additions & 0 deletions packages/localizations/src/deDe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,5 +384,8 @@ export const deDe = {
remove: 'Entfernen',
removing: 'Wird entfernt...',
checkout: 'Zur Kasse',
itemsPerPage: 'Artikel pro Seite:',
search: 'Suchen',
searchPlaceholder: 'Produkte suchen...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/enIe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,5 +361,8 @@ export const enIe = {
remove: 'Remove',
removing: 'Removing...',
checkout: 'Checkout',
itemsPerPage: 'Items per page:',
search: 'Search',
searchPlaceholder: 'Search products...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/enUs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,5 +361,8 @@ export const enUs = {
remove: 'Remove',
removing: 'Removing...',
checkout: 'Checkout',
itemsPerPage: 'Items per page:',
search: 'Search',
searchPlaceholder: 'Search products...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/esAr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,5 +367,8 @@ export const esAr = {
remove: 'Eliminar',
removing: 'Eliminando...',
checkout: 'Pagar',
itemsPerPage: 'Artículos por página:',
search: 'Buscar',
searchPlaceholder: 'Buscar productos...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/esCl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,5 +369,8 @@ export const esCl = {
remove: 'Eliminar',
removing: 'Eliminando...',
checkout: 'Pagar',
itemsPerPage: 'Artículos por página:',
search: 'Buscar',
searchPlaceholder: 'Buscar productos...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/esCo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,5 +367,8 @@ export const esCo = {
remove: 'Eliminar',
removing: 'Eliminando...',
checkout: 'Pagar',
itemsPerPage: 'Artículos por página:',
search: 'Buscar',
searchPlaceholder: 'Buscar productos...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/esEs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,5 +372,8 @@ export const esEs = {
remove: 'Eliminar',
removing: 'Eliminando...',
checkout: 'Pagar',
itemsPerPage: 'Artículos por página:',
search: 'Buscar',
searchPlaceholder: 'Buscar productos...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/esMx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,5 +368,8 @@ export const esMx = {
remove: 'Eliminar',
removing: 'Eliminando...',
checkout: 'Pagar',
itemsPerPage: 'Artículos por página:',
search: 'Buscar',
searchPlaceholder: 'Buscar productos...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/esPe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,5 +367,8 @@ export const esPe = {
remove: 'Eliminar',
removing: 'Eliminando...',
checkout: 'Pagar',
itemsPerPage: 'Artículos por página:',
search: 'Buscar',
searchPlaceholder: 'Buscar productos...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/esUs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,5 +367,8 @@ export const esUs = {
remove: 'Eliminar',
removing: 'Eliminando...',
checkout: 'Pagar',
itemsPerPage: 'Artículos por página:',
search: 'Buscar',
searchPlaceholder: 'Buscar productos...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/frCa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,5 +384,8 @@ export const frCa = {
remove: 'Supprimer',
removing: 'Suppression...',
checkout: 'Commander',
itemsPerPage: 'Articles par page :',
search: 'Rechercher',
searchPlaceholder: 'Rechercher des produits...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/frFr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,5 +385,8 @@ export const frFr = {
remove: 'Supprimer',
removing: 'Suppression...',
checkout: 'Commander',
itemsPerPage: 'Articles par page :',
search: 'Rechercher',
searchPlaceholder: 'Rechercher des produits...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/idId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,8 @@ export const idId = {
remove: 'Hapus',
removing: 'Menghapus...',
checkout: 'Checkout',
itemsPerPage: 'Item per halaman:',
search: 'Cari',
searchPlaceholder: 'Cari produk...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/itIt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,5 +384,8 @@ export const itIt = {
remove: 'Rimuovi',
removing: 'Rimozione...',
checkout: 'Acquista',
itemsPerPage: 'Articoli per pagina:',
search: 'Cerca',
searchPlaceholder: 'Cerca prodotti...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/ptBr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,5 +365,8 @@ export const ptBr = {
remove: 'Remover',
removing: 'Removendo...',
checkout: 'Finalizar compra',
itemsPerPage: 'Itens por página:',
search: 'Pesquisar',
searchPlaceholder: 'Pesquisar produtos...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/qaPs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,5 +369,8 @@ export const qaPs = {
remove: '[Remove]',
removing: '[Removing...]',
checkout: '[Checkout]',
itemsPerPage: '[Items per page:]',
search: '[Search]',
searchPlaceholder: '[Search products...]',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/trTr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,8 @@ export const trTr = {
remove: 'Kaldır',
removing: 'Kaldırılıyor...',
checkout: 'Ödeme yap',
itemsPerPage: 'Sayfa başına öğe:',
search: 'Ara',
searchPlaceholder: 'Ürün ara...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/viVn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,5 +361,8 @@ export const viVn = {
remove: 'Xóa',
removing: 'Đang xóa...',
checkout: 'Thanh toán',
itemsPerPage: 'Mục trên mỗi trang:',
search: 'Tìm kiếm',
searchPlaceholder: 'Tìm kiếm sản phẩm...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/zhCn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,5 +348,8 @@ export const zhCn = {
remove: '删除',
removing: '正在删除...',
checkout: '结账',
itemsPerPage: '每页项目数:',
search: '搜索',
searchPlaceholder: '搜索产品...',
},
};
3 changes: 3 additions & 0 deletions packages/localizations/src/zhSg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,5 +348,8 @@ export const zhSg = {
remove: '删除',
removing: '正在删除...',
checkout: '结账',
itemsPerPage: '每页项目数:',
search: '搜索',
searchPlaceholder: '搜索产品...',
},
};
6 changes: 5 additions & 1 deletion packages/react/biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"$schema": "https://biomejs.dev/schemas/2.3.2/schema.json",
"extends": ["biome-config-godaddy/biome.json"],
"files": {
"includes": ["**/*", "!!**/src/globals.css"]
"includes": [
"**/*",
"!!**/src/globals.css",
"!!**/src/globals-tailwind.css"
]
},
"linter": {
"rules": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"@radix-ui/react-scroll-area": "^1.2.3",
"@radix-ui/react-select": "^2.1.6",
"@radix-ui/react-separator": "^1.1.2",
"@radix-ui/react-slot": "^1.1.2",
"@radix-ui/react-slot": "^1.2.3",
"@radix-ui/react-switch": "^1.1.3",
"@radix-ui/react-toast": "^1.2.6",
"@radix-ui/react-toggle": "^1.1.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-expect-error
const matcher = /(?<month>\d{0,2})(?<separator>\s?\/?\s?)(?<year>\d{0,2})/;
export function monthYearMask({ value }: { value?: string }) {
if (typeof value !== 'string') {
Expand Down
11 changes: 4 additions & 7 deletions packages/react/src/components/storefront/cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { Loader2, ShoppingCart } from 'lucide-react';
import { useEffect, useState } from 'react';
import type { Product } from '@/components/checkout/line-items/line-items';
import { CartLineItems } from '@/components/storefront/cart-line-items';
import { CartTotals } from '@/components/storefront/cart-totals';
Expand Down Expand Up @@ -33,11 +32,8 @@ export function Cart({
}: CartProps) {
const context = useGoDaddyContext();
const queryClient = useQueryClient();
const [cartOrderId, setCartOrderId] = useState<string | null>(null);

useEffect(() => {
setCartOrderId(getCartOrderId());
}, []);
// Read cart order ID fresh on every render
const cartOrderId = getCartOrderId();

// Fetch cart order
const {
Expand Down Expand Up @@ -147,7 +143,8 @@ export function Cart({
{!isLoading && error && (
<div className='flex flex-col items-center justify-center py-12 text-center'>
<p className='text-destructive mb-2'>
{t.storefront.failedToLoadCart} {(error as Error).message}
{t.storefront.failedToLoadCart}{' '}
{error instanceof Error ? error.message : String(error)}
</p>
<Button
variant='outline'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ export function useAddToCart(options?: UseAddToCartOptions) {
context?.apiHost
),
onSuccess: () => {
// Invalidate cart query to refresh
const cartOrderId = getCartOrderId();
queryClient.invalidateQueries({ queryKey: ['cart-order', cartOrderId] });
// Invalidate all cart queries to refresh (queryKey prefix match)
queryClient.invalidateQueries({ queryKey: ['cart-order'] });

// Call success callback
options?.onSuccess?.();
Expand All @@ -91,7 +90,7 @@ export function useAddToCart(options?: UseAddToCartOptions) {
if (!context.storeId || !context.clientId) {
const error = new Error('Store ID and Client ID are required');
options?.onError?.(error);
throw error;
return;
}
let cartOrderId = getCartOrderId();

Expand All @@ -103,7 +102,7 @@ export function useAddToCart(options?: UseAddToCartOptions) {
if (!cartOrderId) {
const error = new Error('Failed to create cart');
options?.onError?.(error);
throw error;
return;
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/storefront/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './cart-totals.tsx';
export * from './product-card';
export * from './product-details.tsx';
export * from './product-grid';
export * from './product-search';
Loading