@shopify/shop-minis-react 0.3.4 → 0.4.1
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.
- package/dist/_virtual/index3.js +2 -5
- package/dist/_virtual/index3.js.map +1 -1
- package/dist/_virtual/index4.js +5 -2
- package/dist/_virtual/index4.js.map +1 -1
- package/dist/components/MinisContainer.js +11 -10
- package/dist/components/MinisContainer.js.map +1 -1
- package/dist/hooks/content/useContent.js +12 -18
- package/dist/hooks/content/useContent.js.map +1 -1
- package/dist/hooks/product/useCuratedProducts.js +9 -11
- package/dist/hooks/product/useCuratedProducts.js.map +1 -1
- package/dist/hooks/product/usePopularProducts.js +9 -11
- package/dist/hooks/product/usePopularProducts.js.map +1 -1
- package/dist/hooks/product/useProduct.js +11 -17
- package/dist/hooks/product/useProduct.js.map +1 -1
- package/dist/hooks/product/useProductList.js +10 -21
- package/dist/hooks/product/useProductList.js.map +1 -1
- package/dist/hooks/product/useProductLists.js +11 -13
- package/dist/hooks/product/useProductLists.js.map +1 -1
- package/dist/hooks/product/useProductMedia.js +12 -18
- package/dist/hooks/product/useProductMedia.js.map +1 -1
- package/dist/hooks/product/useProductSearch.js +34 -27
- package/dist/hooks/product/useProductSearch.js.map +1 -1
- package/dist/hooks/product/useProductVariants.js +11 -14
- package/dist/hooks/product/useProductVariants.js.map +1 -1
- package/dist/hooks/product/useProducts.js +12 -11
- package/dist/hooks/product/useProducts.js.map +1 -1
- package/dist/hooks/product/useRecommendedProducts.js +11 -13
- package/dist/hooks/product/useRecommendedProducts.js.map +1 -1
- package/dist/hooks/shop/useRecommendedShops.js +11 -13
- package/dist/hooks/shop/useRecommendedShops.js.map +1 -1
- package/dist/hooks/shop/useShop.js +12 -11
- package/dist/hooks/shop/useShop.js.map +1 -1
- package/dist/hooks/user/useBuyerAttributes.js +8 -10
- package/dist/hooks/user/useBuyerAttributes.js.map +1 -1
- package/dist/hooks/user/useCurrentUser.js +7 -9
- package/dist/hooks/user/useCurrentUser.js.map +1 -1
- package/dist/hooks/user/useFollowedShops.js +11 -14
- package/dist/hooks/user/useFollowedShops.js.map +1 -1
- package/dist/hooks/user/useOrders.js +7 -9
- package/dist/hooks/user/useOrders.js.map +1 -1
- package/dist/hooks/user/useRecentProducts.js +11 -13
- package/dist/hooks/user/useRecentProducts.js.map +1 -1
- package/dist/hooks/user/useRecentShops.js +10 -13
- package/dist/hooks/user/useRecentShops.js.map +1 -1
- package/dist/hooks/user/useSavedProducts.js +10 -13
- package/dist/hooks/user/useSavedProducts.js.map +1 -1
- package/dist/hooks/util/useImagePicker.js +13 -6
- package/dist/hooks/util/useImagePicker.js.map +1 -1
- package/dist/internal/reactQuery/MinisQueryProvider.js +11 -0
- package/dist/internal/reactQuery/MinisQueryProvider.js.map +1 -0
- package/dist/internal/reactQuery/queryClient.js +33 -0
- package/dist/internal/reactQuery/queryClient.js.map +1 -0
- package/dist/internal/reactQuery/useShopActionInfiniteQuery.js +52 -0
- package/dist/internal/reactQuery/useShopActionInfiniteQuery.js.map +1 -0
- package/dist/internal/reactQuery/useShopActionQuery.js +37 -0
- package/dist/internal/reactQuery/useShopActionQuery.js.map +1 -0
- package/dist/internal/utils/resizeImage.js +61 -0
- package/dist/internal/utils/resizeImage.js.map +1 -0
- package/dist/providers/ImagePickerProvider.js +123 -102
- package/dist/providers/ImagePickerProvider.js.map +1 -1
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/dist/shop-minis-react/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/video.js@8.23.3/node_modules/video.js/dist/video.es.js +1 -1
- package/package.json +2 -7
- package/src/components/MinisContainer.tsx +6 -3
- package/src/hooks/content/useContent.ts +6 -17
- package/src/hooks/product/useCuratedProducts.ts +4 -6
- package/src/hooks/product/usePopularProducts.ts +4 -6
- package/src/hooks/product/useProduct.ts +6 -17
- package/src/hooks/product/useProductList.ts +4 -19
- package/src/hooks/product/useProductLists.ts +4 -6
- package/src/hooks/product/useProductMedia.ts +6 -17
- package/src/hooks/product/useProductSearch.ts +19 -15
- package/src/hooks/product/useProductVariants.ts +5 -13
- package/src/hooks/product/useProducts.ts +8 -12
- package/src/hooks/product/useRecommendedProducts.ts +4 -6
- package/src/hooks/shop/useRecommendedShops.ts +4 -6
- package/src/hooks/shop/useShop.ts +8 -12
- package/src/hooks/user/useBuyerAttributes.ts +4 -6
- package/src/hooks/user/useCurrentUser.ts +4 -6
- package/src/hooks/user/useFollowedShops.ts +5 -13
- package/src/hooks/user/useOrders.ts +4 -6
- package/src/hooks/user/useRecentProducts.ts +4 -6
- package/src/hooks/user/useRecentShops.ts +5 -13
- package/src/hooks/user/useSavedProducts.ts +5 -13
- package/src/hooks/util/useImagePicker.test.tsx +193 -0
- package/src/hooks/util/useImagePicker.ts +24 -5
- package/src/internal/reactQuery/MinisQueryProvider.test.tsx +38 -0
- package/src/internal/reactQuery/MinisQueryProvider.tsx +16 -0
- package/src/internal/reactQuery/index.ts +8 -0
- package/src/internal/reactQuery/queryClient.test.tsx +91 -0
- package/src/internal/reactQuery/queryClient.ts +43 -0
- package/src/internal/reactQuery/useShopActionInfiniteQuery.test.tsx +357 -0
- package/src/internal/reactQuery/useShopActionInfiniteQuery.ts +129 -0
- package/src/internal/reactQuery/useShopActionQuery.test.tsx +184 -0
- package/src/internal/reactQuery/useShopActionQuery.ts +74 -0
- package/src/internal/utils/resizeImage.test.ts +314 -0
- package/src/internal/utils/resizeImage.ts +108 -0
- package/src/providers/ImagePickerProvider.test.tsx +32 -1
- package/src/providers/ImagePickerProvider.tsx +108 -65
- package/dist/internal/useShopActionsDataFetching.js +0 -79
- package/dist/internal/useShopActionsDataFetching.js.map +0 -1
- package/dist/internal/useShopActionsPaginatedDataFetching.js +0 -96
- package/dist/internal/useShopActionsPaginatedDataFetching.js.map +0 -1
- package/src/hooks/product/useProductSearch.test.ts +0 -470
- package/src/internal/useShopActionsDataFetching.test.ts +0 -465
- package/src/internal/useShopActionsDataFetching.ts +0 -150
- package/src/internal/useShopActionsPaginatedDataFetching.ts +0 -188
- package/src/stories/Accordion.stories.tsx +0 -124
- package/src/stories/AddToCart.stories.tsx +0 -251
- package/src/stories/Alert.stories.tsx +0 -38
- package/src/stories/AlertDialog.stories.tsx +0 -48
- package/src/stories/Avatar.stories.tsx +0 -29
- package/src/stories/Badge.stories.tsx +0 -46
- package/src/stories/Button.stories.tsx +0 -81
- package/src/stories/Card.stories.tsx +0 -40
- package/src/stories/Checkbox.stories.tsx +0 -44
- package/src/stories/FavoriteButton.stories.tsx +0 -58
- package/src/stories/IconButton.stories.tsx +0 -68
- package/src/stories/ImageContentWrapper.stories.tsx +0 -65
- package/src/stories/Input.stories.tsx +0 -44
- package/src/stories/Label.stories.tsx +0 -19
- package/src/stories/List.stories.tsx +0 -64
- package/src/stories/MerchantCard.stories.tsx +0 -127
- package/src/stories/ProductCard.stories.tsx +0 -92
- package/src/stories/ProductLink.stories.tsx +0 -46
- package/src/stories/ProductVariantPrice.stories.tsx +0 -70
- package/src/stories/Progress.stories.tsx +0 -30
- package/src/stories/PullToRefreshList.stories.tsx +0 -122
- package/src/stories/QuantitySelector.stories.tsx +0 -78
- package/src/stories/RadioGroup.stories.tsx +0 -51
- package/src/stories/Search.stories.tsx +0 -37
- package/src/stories/Select.stories.tsx +0 -85
- package/src/stories/Skeleton.stories.tsx +0 -19
- package/src/stories/TextInput.stories.tsx +0 -26
- package/src/stories/Toaster.stories.tsx +0 -46
- package/src/stories/Touchable.stories.tsx +0 -40
- package/src/stories/VideoPlayer.stories.tsx +0 -129
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
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} =
|
|
23
|
+
const {data, ...rest} = useShopActionQuery(
|
|
24
|
+
['product', id, restParams],
|
|
26
25
|
getProduct,
|
|
27
|
-
{
|
|
28
|
-
|
|
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 {
|
|
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
|
|
34
|
-
|
|
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} =
|
|
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 {
|
|
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} =
|
|
29
|
+
const {data, ...rest} = useShopActionInfiniteQuery(
|
|
30
|
+
['productMedia', id, restParams],
|
|
32
31
|
getProductMedia,
|
|
33
|
-
{
|
|
34
|
-
|
|
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,
|
|
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(
|
|
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
|
-
|
|
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 {
|
|
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} =
|
|
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 {
|
|
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} =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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} =
|
|
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} =
|
|
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 {
|
|
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} =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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} =
|
|
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} =
|
|
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 {
|
|
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} =
|
|
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} =
|
|
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} =
|
|
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 {
|
|
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} =
|
|
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 {
|
|
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} =
|
|
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
|
}
|