@szymonpiatek/nextwordpress 0.0.14 → 0.0.15
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 +30 -11
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +30 -11
- package/dist/client/index.js.map +1 -1
- package/dist/hooks/index.cjs +30 -11
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +30 -11
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +30 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -2
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +30 -1
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +30 -2
- package/dist/server/index.js.map +1 -1
- package/dist/{types-COJWPg77.d.cts → types-D6rih4G8.d.cts} +7 -1
- package/dist/{types-COJWPg77.d.ts → types-D6rih4G8.d.ts} +7 -1
- package/package.json +1 -1
package/dist/client/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AuthContextValue, AuthProvider, AuthUser, CartAction, CartContextValue, CartItem, CartProvider, CheckoutOptions, CustomerContextValue, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats } from '../hooks/index.cjs';
|
|
2
2
|
import 'react';
|
|
3
|
-
import '../types-
|
|
3
|
+
import '../types-D6rih4G8.cjs';
|
|
4
4
|
import 'swr';
|
|
5
5
|
import 'swr/mutation';
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AuthContextValue, AuthProvider, AuthUser, CartAction, CartContextValue, CartItem, CartProvider, CheckoutOptions, CustomerContextValue, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats } from '../hooks/index.js';
|
|
2
2
|
import 'react';
|
|
3
|
-
import '../types-
|
|
3
|
+
import '../types-D6rih4G8.js';
|
|
4
4
|
import 'swr';
|
|
5
5
|
import 'swr/mutation';
|
package/dist/client/index.js
CHANGED
|
@@ -1463,7 +1463,25 @@ function useWPULike(config, params, swrOptions) {
|
|
|
1463
1463
|
return { data, error, isLoading, vote };
|
|
1464
1464
|
}
|
|
1465
1465
|
|
|
1466
|
+
// src/integrations/restApi/contactForm7/types.ts
|
|
1467
|
+
var CF7Error = class extends Error {
|
|
1468
|
+
constructor(code, status, endpoint, message) {
|
|
1469
|
+
super(message);
|
|
1470
|
+
__publicField(this, "code", code);
|
|
1471
|
+
__publicField(this, "status", status);
|
|
1472
|
+
__publicField(this, "endpoint", endpoint);
|
|
1473
|
+
this.name = "CF7Error";
|
|
1474
|
+
}
|
|
1475
|
+
};
|
|
1476
|
+
|
|
1466
1477
|
// src/integrations/restApi/contactForm7/queries.ts
|
|
1478
|
+
var statusToCode = {
|
|
1479
|
+
mail_sent: ErrorCode.CF7_MAIL_SENT,
|
|
1480
|
+
mail_failed: ErrorCode.CF7_MAIL_FAILED,
|
|
1481
|
+
validation_failed: ErrorCode.CF7_VALIDATION_FAILED,
|
|
1482
|
+
spam: ErrorCode.CF7_SPAM,
|
|
1483
|
+
aborted: ErrorCode.CF7_ABORTED
|
|
1484
|
+
};
|
|
1467
1485
|
function createCF7Queries(config) {
|
|
1468
1486
|
async function submitForm(formId, data) {
|
|
1469
1487
|
const url = buildUrl(config, `/wp-json/contact-form-7/v1/contact-forms/${formId}/feedback`);
|
|
@@ -1472,26 +1490,27 @@ function createCF7Queries(config) {
|
|
|
1472
1490
|
body.append(key, value);
|
|
1473
1491
|
}
|
|
1474
1492
|
const res = await fetch(url, { method: "POST", body, cache: "no-store" });
|
|
1475
|
-
|
|
1493
|
+
if (!res.ok) {
|
|
1494
|
+
throw new CF7Error(
|
|
1495
|
+
ErrorCode.CF7_MAIL_FAILED,
|
|
1496
|
+
res.status,
|
|
1497
|
+
url,
|
|
1498
|
+
resolveMessage(ErrorCode.CF7_MAIL_FAILED, config.errorMessages)
|
|
1499
|
+
);
|
|
1500
|
+
}
|
|
1501
|
+
const result = await res.json();
|
|
1502
|
+
const code = statusToCode[result.status];
|
|
1503
|
+
return { ...result, message: resolveMessage(code, config.errorMessages) };
|
|
1476
1504
|
}
|
|
1477
1505
|
return { submitForm };
|
|
1478
1506
|
}
|
|
1479
1507
|
|
|
1480
1508
|
// src/hooks/contactForm7/useCF7Submit.ts
|
|
1481
|
-
var statusToCode = {
|
|
1482
|
-
mail_sent: ErrorCode.CF7_MAIL_SENT,
|
|
1483
|
-
mail_failed: ErrorCode.CF7_MAIL_FAILED,
|
|
1484
|
-
validation_failed: ErrorCode.CF7_VALIDATION_FAILED,
|
|
1485
|
-
spam: ErrorCode.CF7_SPAM,
|
|
1486
|
-
aborted: ErrorCode.CF7_ABORTED
|
|
1487
|
-
};
|
|
1488
1509
|
function useCF7Submit(config) {
|
|
1489
1510
|
return useSWRMutation(
|
|
1490
1511
|
`cf7-submit:${config.serverURL}`,
|
|
1491
1512
|
async (_, { arg }) => {
|
|
1492
|
-
|
|
1493
|
-
const override = config.errorMessages?.[statusToCode[result.status]];
|
|
1494
|
-
return override ? { ...result, message: override } : result;
|
|
1513
|
+
return createCF7Queries(config).submitForm(arg.formId, arg.fields);
|
|
1495
1514
|
}
|
|
1496
1515
|
);
|
|
1497
1516
|
}
|