@shopify/shop-minis-react 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/dist/components/MinisContainer.js +11 -10
  2. package/dist/components/MinisContainer.js.map +1 -1
  3. package/dist/components/atoms/content-wrapper.js.map +1 -1
  4. package/dist/components/atoms/video-player.js +28 -26
  5. package/dist/components/atoms/video-player.js.map +1 -1
  6. package/dist/components/commerce/product-card.js +106 -79
  7. package/dist/components/commerce/product-card.js.map +1 -1
  8. package/dist/components/commerce/product-link.js +124 -137
  9. package/dist/components/commerce/product-link.js.map +1 -1
  10. package/dist/components/commerce/search.js +20 -20
  11. package/dist/components/commerce/search.js.map +1 -1
  12. package/dist/components/ui/sonner.js +3 -1
  13. package/dist/components/ui/sonner.js.map +1 -1
  14. package/dist/hooks/content/useContent.js +12 -18
  15. package/dist/hooks/content/useContent.js.map +1 -1
  16. package/dist/hooks/navigation/useNavigateWithTransition.js +10 -11
  17. package/dist/hooks/navigation/useNavigateWithTransition.js.map +1 -1
  18. package/dist/hooks/product/useCuratedProducts.js +9 -11
  19. package/dist/hooks/product/useCuratedProducts.js.map +1 -1
  20. package/dist/hooks/product/usePopularProducts.js +9 -11
  21. package/dist/hooks/product/usePopularProducts.js.map +1 -1
  22. package/dist/hooks/product/useProduct.js +11 -17
  23. package/dist/hooks/product/useProduct.js.map +1 -1
  24. package/dist/hooks/product/useProductList.js +10 -21
  25. package/dist/hooks/product/useProductList.js.map +1 -1
  26. package/dist/hooks/product/useProductLists.js +11 -13
  27. package/dist/hooks/product/useProductLists.js.map +1 -1
  28. package/dist/hooks/product/useProductMedia.js +12 -18
  29. package/dist/hooks/product/useProductMedia.js.map +1 -1
  30. package/dist/hooks/product/useProductSearch.js +34 -27
  31. package/dist/hooks/product/useProductSearch.js.map +1 -1
  32. package/dist/hooks/product/useProductVariants.js +11 -14
  33. package/dist/hooks/product/useProductVariants.js.map +1 -1
  34. package/dist/hooks/product/useProducts.js +12 -11
  35. package/dist/hooks/product/useProducts.js.map +1 -1
  36. package/dist/hooks/product/useRecommendedProducts.js +11 -13
  37. package/dist/hooks/product/useRecommendedProducts.js.map +1 -1
  38. package/dist/hooks/shop/useRecommendedShops.js +11 -13
  39. package/dist/hooks/shop/useRecommendedShops.js.map +1 -1
  40. package/dist/hooks/shop/useShop.js +12 -11
  41. package/dist/hooks/shop/useShop.js.map +1 -1
  42. package/dist/hooks/user/useBuyerAttributes.js +8 -10
  43. package/dist/hooks/user/useBuyerAttributes.js.map +1 -1
  44. package/dist/hooks/user/useCurrentUser.js +7 -9
  45. package/dist/hooks/user/useCurrentUser.js.map +1 -1
  46. package/dist/hooks/user/useFollowedShops.js +11 -14
  47. package/dist/hooks/user/useFollowedShops.js.map +1 -1
  48. package/dist/hooks/user/useOrders.js +7 -9
  49. package/dist/hooks/user/useOrders.js.map +1 -1
  50. package/dist/hooks/user/useRecentProducts.js +11 -13
  51. package/dist/hooks/user/useRecentProducts.js.map +1 -1
  52. package/dist/hooks/user/useRecentShops.js +10 -13
  53. package/dist/hooks/user/useRecentShops.js.map +1 -1
  54. package/dist/hooks/user/useSavedProducts.js +10 -13
  55. package/dist/hooks/user/useSavedProducts.js.map +1 -1
  56. package/dist/index.js +269 -264
  57. package/dist/index.js.map +1 -1
  58. package/dist/internal/components/product-review-stars.js +78 -0
  59. package/dist/internal/components/product-review-stars.js.map +1 -0
  60. package/dist/internal/reactQuery/MinisQueryProvider.js +11 -0
  61. package/dist/internal/reactQuery/MinisQueryProvider.js.map +1 -0
  62. package/dist/internal/reactQuery/queryClient.js +33 -0
  63. package/dist/internal/reactQuery/queryClient.js.map +1 -0
  64. package/dist/internal/reactQuery/useShopActionInfiniteQuery.js +52 -0
  65. package/dist/internal/reactQuery/useShopActionInfiniteQuery.js.map +1 -0
  66. package/dist/internal/reactQuery/useShopActionQuery.js +37 -0
  67. package/dist/internal/reactQuery/useShopActionQuery.js.map +1 -0
  68. package/dist/mocks.js +178 -107
  69. package/dist/mocks.js.map +1 -1
  70. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/focusManager.js +45 -0
  71. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/focusManager.js.map +1 -0
  72. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js +89 -0
  73. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js.map +1 -0
  74. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js +55 -0
  75. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js.map +1 -0
  76. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutation.js +198 -0
  77. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutation.js.map +1 -0
  78. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js +99 -0
  79. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js.map +1 -0
  80. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js +67 -0
  81. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js.map +1 -0
  82. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js +39 -0
  83. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js.map +1 -0
  84. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/query.js +299 -0
  85. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/query.js.map +1 -0
  86. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryCache.js +80 -0
  87. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryCache.js.map +1 -0
  88. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryClient.js +215 -0
  89. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryClient.js.map +1 -0
  90. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js +300 -0
  91. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js.map +1 -0
  92. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/removable.js +25 -0
  93. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/removable.js.map +1 -0
  94. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/retryer.js +76 -0
  95. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/retryer.js.map +1 -0
  96. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/subscribable.js +21 -0
  97. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/subscribable.js.map +1 -0
  98. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/thenable.js +26 -0
  99. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/thenable.js.map +1 -0
  100. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/utils.js +176 -0
  101. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/utils.js.map +1 -0
  102. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js +7 -0
  103. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js.map +1 -0
  104. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js +17 -0
  105. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js.map +1 -0
  106. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js +19 -0
  107. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js.map +1 -0
  108. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js +21 -0
  109. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js.map +1 -0
  110. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/suspense.js +18 -0
  111. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/suspense.js.map +1 -0
  112. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +64 -0
  113. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -0
  114. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js +13 -0
  115. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js.map +1 -0
  116. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useQuery.js +9 -0
  117. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useQuery.js.map +1 -0
  118. package/dist/shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/star-half.js +21 -0
  119. package/dist/shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/star-half.js.map +1 -0
  120. package/dist/shop-minis-react/node_modules/.pnpm/sonner@2.0.5_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/sonner/dist/index.js +4 -4
  121. package/dist/shop-minis-react/node_modules/.pnpm/sonner@2.0.5_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/sonner/dist/index.js.map +1 -1
  122. package/package.json +2 -7
  123. package/src/components/MinisContainer.tsx +6 -3
  124. package/src/components/atoms/content-wrapper.tsx +1 -1
  125. package/src/components/atoms/video-player.tsx +7 -0
  126. package/src/components/commerce/product-card.test.tsx +135 -0
  127. package/src/components/commerce/product-card.tsx +39 -5
  128. package/src/components/commerce/product-link.test.tsx +15 -3
  129. package/src/components/commerce/product-link.tsx +9 -25
  130. package/src/components/commerce/search.tsx +2 -2
  131. package/src/components/index.ts +1 -0
  132. package/src/components/ui/sonner.tsx +2 -2
  133. package/src/hooks/content/useContent.ts +6 -17
  134. package/src/hooks/navigation/useNavigateWithTransition.test.ts +46 -7
  135. package/src/hooks/navigation/useNavigateWithTransition.ts +4 -1
  136. package/src/hooks/product/useCuratedProducts.ts +4 -6
  137. package/src/hooks/product/usePopularProducts.ts +4 -6
  138. package/src/hooks/product/useProduct.ts +6 -17
  139. package/src/hooks/product/useProductList.ts +4 -19
  140. package/src/hooks/product/useProductLists.ts +4 -6
  141. package/src/hooks/product/useProductMedia.ts +6 -17
  142. package/src/hooks/product/useProductSearch.ts +19 -15
  143. package/src/hooks/product/useProductVariants.ts +5 -13
  144. package/src/hooks/product/useProducts.ts +8 -12
  145. package/src/hooks/product/useRecommendedProducts.ts +4 -6
  146. package/src/hooks/shop/useRecommendedShops.ts +4 -6
  147. package/src/hooks/shop/useShop.ts +8 -12
  148. package/src/hooks/user/useBuyerAttributes.ts +4 -6
  149. package/src/hooks/user/useCurrentUser.ts +4 -6
  150. package/src/hooks/user/useFollowedShops.ts +5 -13
  151. package/src/hooks/user/useOrders.ts +4 -6
  152. package/src/hooks/user/useRecentProducts.ts +4 -6
  153. package/src/hooks/user/useRecentShops.ts +5 -13
  154. package/src/hooks/user/useSavedProducts.ts +5 -13
  155. package/src/internal/components/product-review-stars.test.tsx +90 -0
  156. package/src/internal/components/product-review-stars.tsx +113 -0
  157. package/src/internal/reactQuery/MinisQueryProvider.test.tsx +38 -0
  158. package/src/internal/reactQuery/MinisQueryProvider.tsx +16 -0
  159. package/src/internal/reactQuery/index.ts +8 -0
  160. package/src/internal/reactQuery/queryClient.test.tsx +91 -0
  161. package/src/internal/reactQuery/queryClient.ts +43 -0
  162. package/src/internal/reactQuery/useShopActionInfiniteQuery.test.tsx +357 -0
  163. package/src/internal/reactQuery/useShopActionInfiniteQuery.ts +129 -0
  164. package/src/internal/reactQuery/useShopActionQuery.test.tsx +184 -0
  165. package/src/internal/reactQuery/useShopActionQuery.ts +74 -0
  166. package/src/mocks.ts +10 -2
  167. package/src/providers/ImagePickerProvider.test.tsx +3 -9
  168. package/dist/internal/useShopActionsDataFetching.js +0 -79
  169. package/dist/internal/useShopActionsDataFetching.js.map +0 -1
  170. package/dist/internal/useShopActionsPaginatedDataFetching.js +0 -96
  171. package/dist/internal/useShopActionsPaginatedDataFetching.js.map +0 -1
  172. package/src/hooks/product/useProductSearch.test.ts +0 -470
  173. package/src/internal/useShopActionsDataFetching.test.ts +0 -465
  174. package/src/internal/useShopActionsDataFetching.ts +0 -150
  175. package/src/internal/useShopActionsPaginatedDataFetching.ts +0 -188
  176. package/src/stories/Accordion.stories.tsx +0 -124
  177. package/src/stories/AddToCart.stories.tsx +0 -251
  178. package/src/stories/Alert.stories.tsx +0 -38
  179. package/src/stories/AlertDialog.stories.tsx +0 -48
  180. package/src/stories/Avatar.stories.tsx +0 -29
  181. package/src/stories/Badge.stories.tsx +0 -46
  182. package/src/stories/Button.stories.tsx +0 -81
  183. package/src/stories/Card.stories.tsx +0 -40
  184. package/src/stories/Checkbox.stories.tsx +0 -44
  185. package/src/stories/FavoriteButton.stories.tsx +0 -58
  186. package/src/stories/IconButton.stories.tsx +0 -68
  187. package/src/stories/ImageContentWrapper.stories.tsx +0 -65
  188. package/src/stories/Input.stories.tsx +0 -44
  189. package/src/stories/Label.stories.tsx +0 -19
  190. package/src/stories/List.stories.tsx +0 -64
  191. package/src/stories/MerchantCard.stories.tsx +0 -127
  192. package/src/stories/ProductCard.stories.tsx +0 -92
  193. package/src/stories/ProductLink.stories.tsx +0 -46
  194. package/src/stories/ProductVariantPrice.stories.tsx +0 -70
  195. package/src/stories/Progress.stories.tsx +0 -30
  196. package/src/stories/PullToRefreshList.stories.tsx +0 -122
  197. package/src/stories/QuantitySelector.stories.tsx +0 -78
  198. package/src/stories/RadioGroup.stories.tsx +0 -51
  199. package/src/stories/Search.stories.tsx +0 -37
  200. package/src/stories/Select.stories.tsx +0 -85
  201. package/src/stories/Skeleton.stories.tsx +0 -19
  202. package/src/stories/TextInput.stories.tsx +0 -26
  203. package/src/stories/Toaster.stories.tsx +0 -46
  204. package/src/stories/Touchable.stories.tsx +0 -40
  205. package/src/stories/VideoPlayer.stories.tsx +0 -129
@@ -1,7 +1,5 @@
1
- import {useMemo} from 'react'
2
-
1
+ import {useShopActionQuery} from '../../internal/reactQuery'
3
2
  import {useShopActions} from '../../internal/useShopActions'
4
- import {useShopActionsDataFetching} from '../../internal/useShopActionsDataFetching'
5
3
  import {DataHookOptionsBase, DataHookReturnsBase, Product} from '../../types'
6
4
 
7
5
  export interface UseProductParams extends DataHookOptionsBase {
@@ -22,24 +20,15 @@ export const useProduct = (params: UseProductParams): UseProductReturns => {
22
20
  const {getProduct} = useShopActions()
23
21
  const {id, skip = false, ...restParams} = params
24
22
 
25
- const {data, ...rest} = useShopActionsDataFetching(
23
+ const {data, ...rest} = useShopActionQuery(
24
+ ['product', id, restParams],
26
25
  getProduct,
27
- {
28
- id,
29
- ...restParams,
30
- },
31
- {
32
- skip,
33
- hook: 'useProduct',
34
- }
26
+ {id, ...restParams},
27
+ {skip}
35
28
  )
36
29
 
37
- const product = useMemo(() => {
38
- return data ?? null
39
- }, [data])
40
-
41
30
  return {
42
31
  ...rest,
43
- product,
32
+ product: data,
44
33
  }
45
34
  }
@@ -1,13 +1,10 @@
1
- import {useCallback} from 'react'
2
-
1
+ import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
3
2
  import {useShopActions} from '../../internal/useShopActions'
4
- import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
5
3
  import {
6
4
  ProductList,
7
5
  PaginatedDataHookOptionsBase,
8
6
  PaginatedDataHookReturnsBase,
9
7
  } from '../../types'
10
- import {MiniEntityNotFoundError} from '../../utils/errors'
11
8
 
12
9
  interface UseProductListParams extends PaginatedDataHookOptionsBase {
13
10
  /**
@@ -30,23 +27,11 @@ export const useProductList = (
30
27
  const {getProductList} = useShopActions()
31
28
  const {skip, ...shopActionParams} = params ?? {}
32
29
 
33
- const validator = useCallback((data: ProductList | null) => {
34
- if (data === null) {
35
- throw new MiniEntityNotFoundError({
36
- hook: 'useProductList',
37
- message: 'Product list not found',
38
- })
39
- }
40
- }, [])
41
-
42
- const {data, ...rest} = useShopActionsPaginatedDataFetching(
30
+ const {data, ...rest} = useShopActionInfiniteQuery(
31
+ ['productList', shopActionParams],
43
32
  getProductList,
44
33
  shopActionParams,
45
- {
46
- skip,
47
- hook: 'useProductList',
48
- validator,
49
- }
34
+ {skip}
50
35
  )
51
36
 
52
37
  return {
@@ -1,5 +1,5 @@
1
+ import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
1
2
  import {useShopActions} from '../../internal/useShopActions'
2
- import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
3
3
  import {
4
4
  PaginatedDataHookOptionsBase,
5
5
  PaginatedDataHookReturnsBase,
@@ -23,13 +23,11 @@ export const useProductLists = (
23
23
  const {getProductLists} = useShopActions()
24
24
  const {skip, ...shopActionParams} = params ?? {}
25
25
 
26
- const {data, ...rest} = useShopActionsPaginatedDataFetching(
26
+ const {data, ...rest} = useShopActionInfiniteQuery(
27
+ ['productLists', shopActionParams],
27
28
  getProductLists,
28
29
  shopActionParams,
29
- {
30
- skip,
31
- hook: 'useProductLists',
32
- }
30
+ {skip}
33
31
  )
34
32
 
35
33
  return {
@@ -1,7 +1,5 @@
1
- import {useMemo} from 'react'
2
-
1
+ import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
3
2
  import {useShopActions} from '../../internal/useShopActions'
4
- import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
5
3
  import {
6
4
  PaginatedDataHookOptionsBase,
7
5
  PaginatedDataHookReturnsBase,
@@ -28,24 +26,15 @@ export const useProductMedia = (
28
26
  const {getProductMedia} = useShopActions()
29
27
  const {id, skip = false, ...restParams} = params
30
28
 
31
- const {data, ...rest} = useShopActionsPaginatedDataFetching(
29
+ const {data, ...rest} = useShopActionInfiniteQuery(
30
+ ['productMedia', id, restParams],
32
31
  getProductMedia,
33
- {
34
- id,
35
- ...restParams,
36
- },
37
- {
38
- skip,
39
- hook: 'useProductMedia',
40
- }
32
+ {id, ...restParams},
33
+ {skip}
41
34
  )
42
35
 
43
- const media = useMemo(() => {
44
- return data ?? null
45
- }, [data])
46
-
47
36
  return {
48
37
  ...rest,
49
- media,
38
+ media: data,
50
39
  }
51
40
  }
@@ -1,9 +1,9 @@
1
- import {useCallback, useEffect, useMemo, useState} from 'react'
1
+ import {useCallback, useEffect, useState} from 'react'
2
2
 
3
3
  import debounce from 'lodash/debounce'
4
4
 
5
+ import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
5
6
  import {useShopActions} from '../../internal/useShopActions'
6
- import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
7
7
  import {
8
8
  PaginatedDataHookOptionsBase,
9
9
  PaginatedDataHookReturnsBase,
@@ -60,7 +60,11 @@ export const useProductSearch = (
60
60
  // eslint-disable-next-line react-hooks/exhaustive-deps
61
61
  const debouncedSetQuery = useCallback(
62
62
  debounce((newQuery: string) => {
63
- setDebouncedQuery(newQuery)
63
+ setDebouncedQuery(prev => {
64
+ // Only update if the query actually changed
65
+ if (prev === newQuery) return prev
66
+ return newQuery
67
+ })
64
68
  }, 300),
65
69
  []
66
70
  )
@@ -73,7 +77,16 @@ export const useProductSearch = (
73
77
  }
74
78
  }, [query, debouncedSetQuery])
75
79
 
76
- const {data, ...rest} = useShopActionsPaginatedDataFetching(
80
+ // Use our Shop Action infinite query helper
81
+ const {data, ...rest} = useShopActionInfiniteQuery(
82
+ [
83
+ 'productSearch',
84
+ debouncedQuery,
85
+ filters,
86
+ sortBy,
87
+ includeSensitive,
88
+ restParams,
89
+ ],
77
90
  getProductSearch,
78
91
  {
79
92
  query: debouncedQuery,
@@ -83,22 +96,13 @@ export const useProductSearch = (
83
96
  ...restParams,
84
97
  },
85
98
  {
86
- skip,
87
- hook: 'useProductSearch',
99
+ skip: skip || debouncedQuery.trim().length === 0,
88
100
  }
89
101
  )
90
102
 
91
- const products = useMemo(() => {
92
- if (debouncedQuery.trim().length === 0) {
93
- return null
94
- }
95
-
96
- return data ?? null
97
- }, [data, debouncedQuery])
98
-
99
103
  return {
100
104
  ...rest,
101
- products,
105
+ products: data,
102
106
  isTyping: debouncedQuery !== query,
103
107
  }
104
108
  }
@@ -1,7 +1,5 @@
1
- import {useMemo} from 'react'
2
-
1
+ import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
3
2
  import {useShopActions} from '../../internal/useShopActions'
4
- import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
5
3
  import {
6
4
  PaginatedDataHookOptionsBase,
7
5
  PaginatedDataHookReturnsBase,
@@ -28,21 +26,15 @@ export const useProductVariants = (
28
26
  const {getProductVariants} = useShopActions()
29
27
  const {skip = false, ...restParams} = params
30
28
 
31
- const {data, ...rest} = useShopActionsPaginatedDataFetching(
29
+ const {data, ...rest} = useShopActionInfiniteQuery(
30
+ ['productVariants', restParams],
32
31
  getProductVariants,
33
32
  restParams,
34
- {
35
- skip,
36
- hook: 'useProductVariants',
37
- }
33
+ {skip}
38
34
  )
39
35
 
40
- const variants = useMemo(() => {
41
- return data ?? null
42
- }, [data])
43
-
44
36
  return {
45
37
  ...rest,
46
- variants,
38
+ variants: data,
47
39
  }
48
40
  }
@@ -1,7 +1,5 @@
1
- import {useMemo} from 'react'
2
-
1
+ import {useShopActionQuery} from '../../internal/reactQuery'
3
2
  import {useShopActions} from '../../internal/useShopActions'
4
- import {useShopActionsDataFetching} from '../../internal/useShopActionsDataFetching'
5
3
  import {DataHookOptionsBase, DataHookReturnsBase, Product} from '../../types'
6
4
 
7
5
  export interface UseProductsParams extends DataHookOptionsBase {
@@ -22,17 +20,15 @@ export const useProducts = (params: UseProductsParams): UseProductsReturns => {
22
20
  const {getProducts} = useShopActions()
23
21
  const {skip = false, ...restParams} = params
24
22
 
25
- const {data, ...rest} = useShopActionsDataFetching(getProducts, restParams, {
26
- skip,
27
- hook: 'useProducts',
28
- })
29
-
30
- const products = useMemo(() => {
31
- return data ?? null
32
- }, [data])
23
+ const {data, ...rest} = useShopActionQuery(
24
+ ['products', restParams],
25
+ getProducts,
26
+ restParams,
27
+ {skip}
28
+ )
33
29
 
34
30
  return {
35
31
  ...rest,
36
- products,
32
+ products: data,
37
33
  }
38
34
  }
@@ -1,5 +1,5 @@
1
+ import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
1
2
  import {useShopActions} from '../../internal/useShopActions'
2
- import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
3
3
  import {
4
4
  Product,
5
5
  PaginatedDataHookOptionsBase,
@@ -21,13 +21,11 @@ export const useRecommendedProducts = (
21
21
  const {getRecommendedProducts} = useShopActions()
22
22
  const {skip, ...shopActionParams} = params ?? {}
23
23
 
24
- const {data, ...rest} = useShopActionsPaginatedDataFetching(
24
+ const {data, ...rest} = useShopActionInfiniteQuery(
25
+ ['recommendedProducts', shopActionParams],
25
26
  getRecommendedProducts,
26
27
  shopActionParams,
27
- {
28
- skip,
29
- hook: 'useRecommendedProducts',
30
- }
28
+ {skip}
31
29
  )
32
30
 
33
31
  return {
@@ -1,7 +1,7 @@
1
1
  import {useMemo} from 'react'
2
2
 
3
+ import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
3
4
  import {useShopActions} from '../../internal/useShopActions'
4
- import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
5
5
  import {
6
6
  Shop,
7
7
  PaginatedDataHookOptionsBase,
@@ -21,13 +21,11 @@ export const useRecommendedShops = (
21
21
 
22
22
  const {skip, ...shopActionParamsToPass} = params || {}
23
23
 
24
- const {data, ...rest} = useShopActionsPaginatedDataFetching(
24
+ const {data, ...rest} = useShopActionInfiniteQuery(
25
+ ['recommendedShops', shopActionParamsToPass],
25
26
  getRecommendedShops,
26
27
  shopActionParamsToPass,
27
- {
28
- skip,
29
- hook: 'useRecommendedShops',
30
- }
28
+ {skip}
31
29
  )
32
30
 
33
31
  const shops = useMemo(() => {
@@ -1,7 +1,5 @@
1
- import {useMemo} from 'react'
2
-
1
+ import {useShopActionQuery} from '../../internal/reactQuery'
3
2
  import {useShopActions} from '../../internal/useShopActions'
4
- import {useShopActionsDataFetching} from '../../internal/useShopActionsDataFetching'
5
3
  import {DataHookOptionsBase, DataHookReturnsBase, Shop} from '../../types'
6
4
 
7
5
  export interface UseShopParams extends DataHookOptionsBase {
@@ -22,17 +20,15 @@ export const useShop = (params: UseShopParams): UseShopReturns => {
22
20
  const {getShop} = useShopActions()
23
21
  const {skip = false, ...restParams} = params
24
22
 
25
- const {data, ...rest} = useShopActionsDataFetching(getShop, restParams, {
26
- skip,
27
- hook: 'useShop',
28
- })
29
-
30
- const shop = useMemo(() => {
31
- return data ?? null
32
- }, [data])
23
+ const {data, ...rest} = useShopActionQuery(
24
+ ['shop', restParams],
25
+ getShop,
26
+ restParams,
27
+ {skip}
28
+ )
33
29
 
34
30
  return {
35
31
  ...rest,
36
- shop,
32
+ shop: data,
37
33
  }
38
34
  }
@@ -1,5 +1,5 @@
1
+ import {useShopActionQuery} from '../../internal/reactQuery'
1
2
  import {useShopActions} from '../../internal/useShopActions'
2
- import {useShopActionsDataFetching} from '../../internal/useShopActionsDataFetching'
3
3
  import {
4
4
  DataHookOptionsBase,
5
5
  DataHookReturnsBase,
@@ -18,13 +18,11 @@ export const useBuyerAttributes = (
18
18
  const {skip, ...shopActionParams} = params || {}
19
19
  const {getBuyerAttributes} = useShopActions()
20
20
 
21
- const {data, ...rest} = useShopActionsDataFetching(
21
+ const {data, ...rest} = useShopActionQuery(
22
+ ['buyerAttributes', shopActionParams],
22
23
  getBuyerAttributes,
23
24
  shopActionParams,
24
- {
25
- skip,
26
- hook: 'useBuyerAttributes',
27
- }
25
+ {skip}
28
26
  )
29
27
 
30
28
  return {
@@ -1,5 +1,5 @@
1
+ import {useShopActionQuery} from '../../internal/reactQuery'
1
2
  import {useShopActions} from '../../internal/useShopActions'
2
- import {useShopActionsDataFetching} from '../../internal/useShopActionsDataFetching'
3
3
  import {
4
4
  DataHookOptionsBase,
5
5
  DataHookReturnsBase,
@@ -24,13 +24,11 @@ export const useCurrentUser = (
24
24
  const {skip, ...shopActionParams} = params || {}
25
25
  const {getCurrentUser} = useShopActions()
26
26
 
27
- const {data, ...rest} = useShopActionsDataFetching(
27
+ const {data, ...rest} = useShopActionQuery(
28
+ ['currentUser', shopActionParams],
28
29
  getCurrentUser,
29
30
  shopActionParams,
30
- {
31
- skip,
32
- hook: 'useCurrentUser',
33
- }
31
+ {skip}
34
32
  )
35
33
 
36
34
  return {
@@ -1,7 +1,5 @@
1
- import {useMemo} from 'react'
2
-
1
+ import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
3
2
  import {useShopActions} from '../../internal/useShopActions'
4
- import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
5
3
  import {
6
4
  PaginatedDataHookOptionsBase,
7
5
  PaginatedDataHookReturnsBase,
@@ -23,21 +21,15 @@ export const useFollowedShops = (
23
21
  const {getFollowedShops} = useShopActions()
24
22
  const {skip = false, ...restParams} = params ?? {}
25
23
 
26
- const {data, ...rest} = useShopActionsPaginatedDataFetching(
24
+ const {data, ...rest} = useShopActionInfiniteQuery(
25
+ ['followedShops', restParams],
27
26
  getFollowedShops,
28
27
  restParams,
29
- {
30
- skip,
31
- hook: 'useFollowedShops',
32
- }
28
+ {skip}
33
29
  )
34
30
 
35
- const shops = useMemo(() => {
36
- return data ?? null
37
- }, [data])
38
-
39
31
  return {
40
32
  ...rest,
41
- shops,
33
+ shops: data,
42
34
  }
43
35
  }
@@ -1,5 +1,5 @@
1
+ import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
1
2
  import {useShopActions} from '../../internal/useShopActions'
2
- import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
3
3
  import {
4
4
  PaginatedDataHookOptionsBase,
5
5
  PaginatedDataHookReturnsBase,
@@ -16,13 +16,11 @@ export const useOrders = (params?: UseOrdersParams): UseOrdersReturns => {
16
16
  const {skip, ...shopActionParams} = params || {}
17
17
  const {getOrders} = useShopActions()
18
18
 
19
- const {data, ...rest} = useShopActionsPaginatedDataFetching(
19
+ const {data, ...rest} = useShopActionInfiniteQuery(
20
+ ['orders', shopActionParams],
20
21
  getOrders,
21
22
  shopActionParams,
22
- {
23
- skip,
24
- hook: 'useOrders',
25
- }
23
+ {skip}
26
24
  )
27
25
 
28
26
  return {
@@ -1,7 +1,7 @@
1
1
  import {useMemo} from 'react'
2
2
 
3
+ import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
3
4
  import {useShopActions} from '../../internal/useShopActions'
4
- import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
5
5
  import {
6
6
  PaginatedDataHookOptionsBase,
7
7
  PaginatedDataHookReturnsBase,
@@ -26,13 +26,11 @@ export const useRecentProducts = (
26
26
  const {getRecentProducts} = useShopActions()
27
27
  const {skip, ...shopActionParams} = params ?? {}
28
28
 
29
- const {data, ...rest} = useShopActionsPaginatedDataFetching(
29
+ const {data, ...rest} = useShopActionInfiniteQuery(
30
+ ['recentProducts', shopActionParams],
30
31
  getRecentProducts,
31
32
  shopActionParams,
32
- {
33
- skip,
34
- hook: 'useRecentProducts',
35
- }
33
+ {skip}
36
34
  )
37
35
 
38
36
  const products = useMemo(() => {
@@ -1,7 +1,5 @@
1
- import {useMemo} from 'react'
2
-
1
+ import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
3
2
  import {useShopActions} from '../../internal/useShopActions'
4
- import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
5
3
  import {
6
4
  PaginatedDataHookOptionsBase,
7
5
  PaginatedDataHookReturnsBase,
@@ -23,21 +21,15 @@ export const useRecentShops = (
23
21
  const {getRecentShops} = useShopActions()
24
22
  const {skip = false, ...restParams} = params ?? {}
25
23
 
26
- const {data, ...rest} = useShopActionsPaginatedDataFetching(
24
+ const {data, ...rest} = useShopActionInfiniteQuery(
25
+ ['recentShops', restParams],
27
26
  getRecentShops,
28
27
  restParams,
29
- {
30
- skip,
31
- hook: 'useRecentShops',
32
- }
28
+ {skip}
33
29
  )
34
30
 
35
- const shops = useMemo(() => {
36
- return data ?? null
37
- }, [data])
38
-
39
31
  return {
40
32
  ...rest,
41
- shops,
33
+ shops: data,
42
34
  }
43
35
  }
@@ -1,7 +1,5 @@
1
- import {useMemo} from 'react'
2
-
1
+ import {useShopActionInfiniteQuery} from '../../internal/reactQuery'
3
2
  import {useShopActions} from '../../internal/useShopActions'
4
- import {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'
5
3
  import {
6
4
  PaginatedDataHookOptionsBase,
7
5
  PaginatedDataHookReturnsBase,
@@ -26,21 +24,15 @@ export const useSavedProducts = (
26
24
  const {getSavedProducts} = useShopActions()
27
25
  const {skip, ...shopActionParams} = params ?? {}
28
26
 
29
- const {data, ...rest} = useShopActionsPaginatedDataFetching(
27
+ const {data, ...rest} = useShopActionInfiniteQuery(
28
+ ['savedProducts', shopActionParams],
30
29
  getSavedProducts,
31
30
  shopActionParams,
32
- {
33
- skip,
34
- hook: 'useSavedProducts',
35
- }
31
+ {skip}
36
32
  )
37
33
 
38
- const products = useMemo(() => {
39
- return data ?? null
40
- }, [data])
41
-
42
34
  return {
43
35
  ...rest,
44
- products,
36
+ products: data,
45
37
  }
46
38
  }
@@ -0,0 +1,90 @@
1
+ import {createRef} from 'react'
2
+
3
+ import {describe, expect, it} from 'vitest'
4
+
5
+ import {render, screen} from '../../test-utils'
6
+
7
+ import {ProductReviewStars} from './product-review-stars'
8
+
9
+ describe('ProductReviewStars', () => {
10
+ it('renders without crashing', () => {
11
+ const {container} = render(
12
+ <ProductReviewStars averageRating={3.5} reviewCount={100} />
13
+ )
14
+
15
+ // Component should render something
16
+ expect(container.firstChild).toBeInTheDocument()
17
+ })
18
+
19
+ describe('review count display', () => {
20
+ it('displays review count', () => {
21
+ render(<ProductReviewStars averageRating={4} reviewCount={42} />)
22
+ expect(screen.getByText('(42)')).toBeInTheDocument()
23
+ })
24
+
25
+ it('formats large numbers as K', () => {
26
+ render(<ProductReviewStars averageRating={4} reviewCount={1500} />)
27
+ expect(screen.getByText('(1K)')).toBeInTheDocument()
28
+ })
29
+
30
+ it('formats millions as M', () => {
31
+ render(<ProductReviewStars averageRating={4} reviewCount={1500000} />)
32
+ expect(screen.getByText('(1.5M)')).toBeInTheDocument()
33
+ })
34
+
35
+ it('does not display review count when zero', () => {
36
+ render(<ProductReviewStars averageRating={4} reviewCount={0} />)
37
+ expect(screen.queryByText('(0)')).not.toBeInTheDocument()
38
+ })
39
+
40
+ it('does not display review count when null', () => {
41
+ render(<ProductReviewStars averageRating={4} reviewCount={null} />)
42
+ expect(screen.queryByText(/\(\d+\)/)).not.toBeInTheDocument()
43
+ })
44
+ })
45
+
46
+ describe('accessibility', () => {
47
+ it('forwards ref to container element', () => {
48
+ const ref = createRef<HTMLDivElement>()
49
+ render(
50
+ <ProductReviewStars ref={ref} averageRating={4} reviewCount={100} />
51
+ )
52
+ expect(ref.current).toBeInstanceOf(HTMLDivElement)
53
+ })
54
+
55
+ it('accepts aria-label for accessibility', () => {
56
+ render(
57
+ <ProductReviewStars
58
+ averageRating={4.5}
59
+ reviewCount={100}
60
+ aria-label="4.5 out of 5 stars, 100 reviews"
61
+ data-testid="rating-stars"
62
+ />
63
+ )
64
+
65
+ const element = screen.getByTestId('rating-stars')
66
+ expect(element).toHaveAttribute(
67
+ 'aria-label',
68
+ '4.5 out of 5 stars, 100 reviews'
69
+ )
70
+ })
71
+ })
72
+
73
+ describe('edge cases', () => {
74
+ it('handles negative ratings gracefully', () => {
75
+ // Should not crash with invalid input
76
+ const {container} = render(
77
+ <ProductReviewStars averageRating={-1} reviewCount={10} />
78
+ )
79
+ expect(container.firstChild).toBeInTheDocument()
80
+ })
81
+
82
+ it('handles very large ratings gracefully', () => {
83
+ // Should not crash with invalid input
84
+ const {container} = render(
85
+ <ProductReviewStars averageRating={10} reviewCount={10} />
86
+ )
87
+ expect(container.firstChild).toBeInTheDocument()
88
+ })
89
+ })
90
+ })