@szymonpiatek/nextwordpress 0.0.11 → 0.0.12

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.
@@ -1343,6 +1343,76 @@ function useGQLPostBySlug(config, slug, swrOptions) {
1343
1343
  );
1344
1344
  }
1345
1345
 
1346
- export { AuthProvider, CartProvider, WooCommerceCustomerProvider, cartReducer, useAuth, useCart, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useWPGraphQL };
1346
+ // src/integrations/restApi/wpulike/queries.ts
1347
+ function createWPULikeQueries(fetcher) {
1348
+ const { wpFetch, wpMutate } = fetcher;
1349
+ async function getLikeStats(params, tags) {
1350
+ return wpFetch(
1351
+ "/wp-json/wp-ulike/v1/stats",
1352
+ params,
1353
+ tags ?? ["wpulike", `wpulike-${params.id}`]
1354
+ );
1355
+ }
1356
+ async function checkLikeStatus(params, tags) {
1357
+ return wpFetch(
1358
+ "/wp-json/wp-ulike/v1/check",
1359
+ params,
1360
+ tags ?? ["wpulike", `wpulike-${params.id}`]
1361
+ );
1362
+ }
1363
+ async function vote(params, authToken) {
1364
+ return wpMutate(
1365
+ "/wp-json/wp-ulike/v1/vote",
1366
+ params,
1367
+ "POST",
1368
+ authToken
1369
+ );
1370
+ }
1371
+ return { getLikeStats, checkLikeStatus, vote };
1372
+ }
1373
+
1374
+ // src/hooks/wpulike/useWPULike.ts
1375
+ function useWPULikeStats(config, params, swrOptions) {
1376
+ const key = params ? ["wpulike-stats", config.clientURL, params.id, params.type ?? "post"] : null;
1377
+ return useSWR2(
1378
+ key,
1379
+ () => {
1380
+ const fetcher = createFetcher(config);
1381
+ return createWPULikeQueries(fetcher).getLikeStats(params);
1382
+ },
1383
+ swrOptions
1384
+ );
1385
+ }
1386
+ function useWPULikeCheck(config, params, swrOptions) {
1387
+ const key = params ? ["wpulike-check", config.clientURL, params.id, params.type ?? "post"] : null;
1388
+ return useSWR2(
1389
+ key,
1390
+ () => {
1391
+ const fetcher = createFetcher(config);
1392
+ return createWPULikeQueries(fetcher).checkLikeStatus(params);
1393
+ },
1394
+ swrOptions
1395
+ );
1396
+ }
1397
+ function useWPULike(config, params, swrOptions) {
1398
+ const key = params ? ["wpulike-stats", config.clientURL, params.id, params.type ?? "post"] : null;
1399
+ const { data, error, isLoading, mutate } = useSWR2(
1400
+ key,
1401
+ () => {
1402
+ const fetcher = createFetcher(config);
1403
+ return createWPULikeQueries(fetcher).getLikeStats(params);
1404
+ },
1405
+ swrOptions
1406
+ );
1407
+ async function vote(status, authToken) {
1408
+ const fetcher = createFetcher(config);
1409
+ const result = await createWPULikeQueries(fetcher).vote({ ...params, status }, authToken);
1410
+ await mutate();
1411
+ return result;
1412
+ }
1413
+ return { data, error, isLoading, vote };
1414
+ }
1415
+
1416
+ export { AuthProvider, CartProvider, WooCommerceCustomerProvider, cartReducer, useAuth, useCart, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats };
1347
1417
  //# sourceMappingURL=index.js.map
1348
1418
  //# sourceMappingURL=index.js.map