@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/hooks/index.cjs
CHANGED
|
@@ -1349,6 +1349,76 @@ function useGQLPostBySlug(config, slug, swrOptions) {
|
|
|
1349
1349
|
);
|
|
1350
1350
|
}
|
|
1351
1351
|
|
|
1352
|
+
// src/integrations/restApi/wpulike/queries.ts
|
|
1353
|
+
function createWPULikeQueries(fetcher) {
|
|
1354
|
+
const { wpFetch, wpMutate } = fetcher;
|
|
1355
|
+
async function getLikeStats(params, tags) {
|
|
1356
|
+
return wpFetch(
|
|
1357
|
+
"/wp-json/wp-ulike/v1/stats",
|
|
1358
|
+
params,
|
|
1359
|
+
tags ?? ["wpulike", `wpulike-${params.id}`]
|
|
1360
|
+
);
|
|
1361
|
+
}
|
|
1362
|
+
async function checkLikeStatus(params, tags) {
|
|
1363
|
+
return wpFetch(
|
|
1364
|
+
"/wp-json/wp-ulike/v1/check",
|
|
1365
|
+
params,
|
|
1366
|
+
tags ?? ["wpulike", `wpulike-${params.id}`]
|
|
1367
|
+
);
|
|
1368
|
+
}
|
|
1369
|
+
async function vote(params, authToken) {
|
|
1370
|
+
return wpMutate(
|
|
1371
|
+
"/wp-json/wp-ulike/v1/vote",
|
|
1372
|
+
params,
|
|
1373
|
+
"POST",
|
|
1374
|
+
authToken
|
|
1375
|
+
);
|
|
1376
|
+
}
|
|
1377
|
+
return { getLikeStats, checkLikeStatus, vote };
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
// src/hooks/wpulike/useWPULike.ts
|
|
1381
|
+
function useWPULikeStats(config, params, swrOptions) {
|
|
1382
|
+
const key = params ? ["wpulike-stats", config.clientURL, params.id, params.type ?? "post"] : null;
|
|
1383
|
+
return useSWR2__default.default(
|
|
1384
|
+
key,
|
|
1385
|
+
() => {
|
|
1386
|
+
const fetcher = createFetcher(config);
|
|
1387
|
+
return createWPULikeQueries(fetcher).getLikeStats(params);
|
|
1388
|
+
},
|
|
1389
|
+
swrOptions
|
|
1390
|
+
);
|
|
1391
|
+
}
|
|
1392
|
+
function useWPULikeCheck(config, params, swrOptions) {
|
|
1393
|
+
const key = params ? ["wpulike-check", config.clientURL, params.id, params.type ?? "post"] : null;
|
|
1394
|
+
return useSWR2__default.default(
|
|
1395
|
+
key,
|
|
1396
|
+
() => {
|
|
1397
|
+
const fetcher = createFetcher(config);
|
|
1398
|
+
return createWPULikeQueries(fetcher).checkLikeStatus(params);
|
|
1399
|
+
},
|
|
1400
|
+
swrOptions
|
|
1401
|
+
);
|
|
1402
|
+
}
|
|
1403
|
+
function useWPULike(config, params, swrOptions) {
|
|
1404
|
+
const key = params ? ["wpulike-stats", config.clientURL, params.id, params.type ?? "post"] : null;
|
|
1405
|
+
const { data, error, isLoading, mutate } = useSWR2__default.default(
|
|
1406
|
+
key,
|
|
1407
|
+
() => {
|
|
1408
|
+
const fetcher = createFetcher(config);
|
|
1409
|
+
return createWPULikeQueries(fetcher).getLikeStats(params);
|
|
1410
|
+
},
|
|
1411
|
+
swrOptions
|
|
1412
|
+
);
|
|
1413
|
+
async function vote(status, authToken) {
|
|
1414
|
+
const fetcher = createFetcher(config);
|
|
1415
|
+
const result = await createWPULikeQueries(fetcher).vote({ ...params, status }, authToken);
|
|
1416
|
+
await mutate();
|
|
1417
|
+
return result;
|
|
1418
|
+
}
|
|
1419
|
+
return { data, error, isLoading, vote };
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1352
1422
|
exports.AuthProvider = AuthProvider;
|
|
1353
1423
|
exports.CartProvider = CartProvider;
|
|
1354
1424
|
exports.WooCommerceCustomerProvider = WooCommerceCustomerProvider;
|
|
@@ -1368,5 +1438,8 @@ exports.useProductBySlug = useProductBySlug;
|
|
|
1368
1438
|
exports.useProducts = useProducts;
|
|
1369
1439
|
exports.useProductsPaginated = useProductsPaginated;
|
|
1370
1440
|
exports.useWPGraphQL = useWPGraphQL;
|
|
1441
|
+
exports.useWPULike = useWPULike;
|
|
1442
|
+
exports.useWPULikeCheck = useWPULikeCheck;
|
|
1443
|
+
exports.useWPULikeStats = useWPULikeStats;
|
|
1371
1444
|
//# sourceMappingURL=index.cjs.map
|
|
1372
1445
|
//# sourceMappingURL=index.cjs.map
|