@szymonpiatek/nextwordpress 0.0.17 → 0.0.18

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.
@@ -366,44 +366,6 @@ function useResetUserPassword(config) {
366
366
  }
367
367
  );
368
368
  }
369
- function readConsentFromDocument(cookieName) {
370
- if (typeof document === "undefined") return null;
371
- const match = document.cookie.match(new RegExp(`(?:^|;\\s*)${cookieName}=([^;]*)`));
372
- if (!match) return null;
373
- if (match[1] === "1") return { necessary: true, analytics: true, marketing: true };
374
- try {
375
- const parsed = JSON.parse(decodeURIComponent(match[1]));
376
- if (typeof parsed !== "object" || parsed === null) return null;
377
- return parsed;
378
- } catch {
379
- return null;
380
- }
381
- }
382
- function useCookieConsent(consentPath = "/api/cookie-consent", cookieName = "cookie_notice_accepted") {
383
- const [consent, setConsentState] = react.useState(null);
384
- const [isLoaded, setIsLoaded] = react.useState(false);
385
- react.useEffect(() => {
386
- setConsentState(readConsentFromDocument(cookieName));
387
- setIsLoaded(true);
388
- }, [cookieName]);
389
- const setConsent = react.useCallback(
390
- async (categories) => {
391
- const res = await fetch(consentPath, {
392
- method: "POST",
393
- headers: { "Content-Type": "application/json" },
394
- body: JSON.stringify(categories)
395
- });
396
- const data = await res.json();
397
- setConsentState(data);
398
- },
399
- [consentPath]
400
- );
401
- const clearConsent = react.useCallback(async () => {
402
- await fetch(consentPath, { method: "DELETE" });
403
- setConsentState(null);
404
- }, [consentPath]);
405
- return { consent, isLoaded, setConsent, clearConsent };
406
- }
407
369
 
408
370
  // src/integrations/restApi/core/client/types.ts
409
371
  var WordPressAPIError = class extends Error {
@@ -528,6 +490,88 @@ function createFetcher(config) {
528
490
  return { wpFetch, wpFetchGraceful, wpFetchPaginated, wpFetchPaginatedGraceful, wpMutate, wpUpload };
529
491
  }
530
492
 
493
+ // src/integrations/restApi/core/mutations/passwordReset/mutations.ts
494
+ function createPasswordResetMutations2(fetcher) {
495
+ const { wpMutate } = fetcher;
496
+ async function sendPasswordResetEmail(input) {
497
+ return wpMutate(
498
+ "/wp-json/wp/v2/users/lost-password",
499
+ input,
500
+ "POST"
501
+ );
502
+ }
503
+ async function resetUserPassword(input) {
504
+ return wpMutate(
505
+ "/wp-json/wp/v2/users/reset-password",
506
+ input,
507
+ "POST"
508
+ );
509
+ }
510
+ return { sendPasswordResetEmail, resetUserPassword };
511
+ }
512
+
513
+ // src/hooks/auth/useSendPasswordResetEmailRest.ts
514
+ function useSendPasswordResetEmailRest(config) {
515
+ return useSWRMutation__default.default(
516
+ `send-password-reset-rest:${config.serverURL}`,
517
+ async (_, { arg }) => {
518
+ return createPasswordResetMutations2(createFetcher(config)).sendPasswordResetEmail({
519
+ username: arg.username
520
+ });
521
+ }
522
+ );
523
+ }
524
+ function useResetUserPasswordRest(config) {
525
+ return useSWRMutation__default.default(
526
+ `reset-user-password-rest:${config.serverURL}`,
527
+ async (_, { arg }) => {
528
+ return createPasswordResetMutations2(createFetcher(config)).resetUserPassword({
529
+ key: arg.key,
530
+ login: arg.login,
531
+ password: arg.password
532
+ });
533
+ }
534
+ );
535
+ }
536
+ function readConsentFromDocument(cookieName) {
537
+ if (typeof document === "undefined") return null;
538
+ const match = document.cookie.match(new RegExp(`(?:^|;\\s*)${cookieName}=([^;]*)`));
539
+ if (!match) return null;
540
+ if (match[1] === "1") return { necessary: true, analytics: true, marketing: true };
541
+ try {
542
+ const parsed = JSON.parse(decodeURIComponent(match[1]));
543
+ if (typeof parsed !== "object" || parsed === null) return null;
544
+ return parsed;
545
+ } catch {
546
+ return null;
547
+ }
548
+ }
549
+ function useCookieConsent(consentPath = "/api/cookie-consent", cookieName = "cookie_notice_accepted") {
550
+ const [consent, setConsentState] = react.useState(null);
551
+ const [isLoaded, setIsLoaded] = react.useState(false);
552
+ react.useEffect(() => {
553
+ setConsentState(readConsentFromDocument(cookieName));
554
+ setIsLoaded(true);
555
+ }, [cookieName]);
556
+ const setConsent = react.useCallback(
557
+ async (categories) => {
558
+ const res = await fetch(consentPath, {
559
+ method: "POST",
560
+ headers: { "Content-Type": "application/json" },
561
+ body: JSON.stringify(categories)
562
+ });
563
+ const data = await res.json();
564
+ setConsentState(data);
565
+ },
566
+ [consentPath]
567
+ );
568
+ const clearConsent = react.useCallback(async () => {
569
+ await fetch(consentPath, { method: "DELETE" });
570
+ setConsentState(null);
571
+ }, [consentPath]);
572
+ return { consent, isLoaded, setConsent, clearConsent };
573
+ }
574
+
531
575
  // src/integrations/restApi/core/posts/queries.ts
532
576
  function createPostsQueries(fetcher) {
533
577
  const { wpFetch, wpFetchGraceful, wpFetchPaginated, wpFetchPaginatedGraceful } = fetcher;
@@ -1605,7 +1649,9 @@ exports.useProductBySlug = useProductBySlug;
1605
1649
  exports.useProducts = useProducts;
1606
1650
  exports.useProductsPaginated = useProductsPaginated;
1607
1651
  exports.useResetUserPassword = useResetUserPassword;
1652
+ exports.useResetUserPasswordRest = useResetUserPasswordRest;
1608
1653
  exports.useSendPasswordResetEmail = useSendPasswordResetEmail;
1654
+ exports.useSendPasswordResetEmailRest = useSendPasswordResetEmailRest;
1609
1655
  exports.useWPGraphQL = useWPGraphQL;
1610
1656
  exports.useWPULike = useWPULike;
1611
1657
  exports.useWPULikeCheck = useWPULikeCheck;