@nextclaw/ui 0.5.16 → 0.5.17
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/api/marketplace.ts +11 -5
- package/src/api/types.ts +1 -0
- package/src/hooks/useMarketplace.ts +3 -3
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/api/marketplace.ts
CHANGED
|
@@ -68,11 +68,15 @@ export async function fetchMarketplaceItem(slug: string, type: MarketplaceItemTy
|
|
|
68
68
|
return response.data;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export async function fetchMarketplaceRecommendations(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
export async function fetchMarketplaceRecommendations(
|
|
72
|
+
type: MarketplaceItemType,
|
|
73
|
+
params: {
|
|
74
|
+
scene?: string;
|
|
75
|
+
limit?: number;
|
|
76
|
+
} = {}
|
|
77
|
+
): Promise<MarketplaceRecommendationView> {
|
|
75
78
|
const query = new URLSearchParams();
|
|
79
|
+
const segment = toMarketplaceTypeSegment(type);
|
|
76
80
|
if (params.scene?.trim()) {
|
|
77
81
|
query.set('scene', params.scene.trim());
|
|
78
82
|
}
|
|
@@ -82,7 +86,9 @@ export async function fetchMarketplaceRecommendations(params: {
|
|
|
82
86
|
|
|
83
87
|
const suffix = query.toString();
|
|
84
88
|
const response = await api.get<MarketplaceRecommendationView>(
|
|
85
|
-
suffix
|
|
89
|
+
suffix
|
|
90
|
+
? `/api/marketplace/${segment}/recommendations?${suffix}`
|
|
91
|
+
: `/api/marketplace/${segment}/recommendations`
|
|
86
92
|
);
|
|
87
93
|
if (!response.ok) {
|
|
88
94
|
throw new Error(response.error.message);
|
package/src/api/types.ts
CHANGED
|
@@ -20,10 +20,10 @@ export function useMarketplaceItems(params: MarketplaceListParams) {
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export function useMarketplaceRecommendations(params: { scene?: string; limit?: number }) {
|
|
23
|
+
export function useMarketplaceRecommendations(type: MarketplaceItemType, params: { scene?: string; limit?: number }) {
|
|
24
24
|
return useQuery({
|
|
25
|
-
queryKey: ['marketplace-recommendations', params],
|
|
26
|
-
queryFn: () => fetchMarketplaceRecommendations(params),
|
|
25
|
+
queryKey: ['marketplace-recommendations', type, params],
|
|
26
|
+
queryFn: () => fetchMarketplaceRecommendations(type, params),
|
|
27
27
|
staleTime: 30_000
|
|
28
28
|
});
|
|
29
29
|
}
|