@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.
- package/dist/client/index.cjs +73 -0
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +71 -1
- package/dist/client/index.js.map +1 -1
- package/dist/hooks/index.cjs +73 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +11 -2
- package/dist/hooks/index.d.ts +11 -2
- package/dist/hooks/index.js +71 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +34 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +34 -0
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +33 -1
- package/dist/server/index.js.map +1 -1
- package/dist/{types-Dxb6tuW_.d.cts → types-WcyioRuq.d.cts} +33 -1
- package/dist/{types-Dxb6tuW_.d.ts → types-WcyioRuq.d.ts} +33 -1
- package/package.json +1 -1
package/dist/client/index.js
CHANGED
|
@@ -1343,6 +1343,76 @@ function useGQLPostBySlug(config, slug, swrOptions) {
|
|
|
1343
1343
|
);
|
|
1344
1344
|
}
|
|
1345
1345
|
|
|
1346
|
-
|
|
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
|