@sentecacommerce-theme/lib 0.12.70 → 0.12.71
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/cjs/hooks/useContactForm/index.js +9 -4
- package/dist/cjs/hooks/useContactForm/index.js.map +1 -1
- package/dist/esm/hooks/useContactForm/index.js +9 -4
- package/dist/esm/hooks/useContactForm/index.js.map +1 -1
- package/dist/types/hooks/useContactForm/index.d.ts +2 -1
- package/package.json +3 -3
@@ -10,13 +10,18 @@ var useContactForm = function useContactForm(_ref) {
|
|
10
10
|
onError = _ref.onError,
|
11
11
|
_ref$endpoint = _ref.endpoint,
|
12
12
|
endpoint = _ref$endpoint === void 0 ? 'email/contact' : _ref$endpoint,
|
13
|
-
integrationDomain = _ref.integrationDomain
|
13
|
+
integrationDomain = _ref.integrationDomain,
|
14
|
+
interfaceKey = _ref.interfaceKey;
|
15
|
+
var headers = interfaceKey ? {
|
16
|
+
InterfaceKey: interfaceKey,
|
17
|
+
'Content-Type': 'application/json'
|
18
|
+
} : {
|
19
|
+
'Content-Type': 'application/json'
|
20
|
+
};
|
14
21
|
return (0, _reactQuery.useMutation)(function (body) {
|
15
22
|
return fetch(integrationDomain + "/" + endpoint, {
|
16
23
|
method: 'POST',
|
17
|
-
headers:
|
18
|
-
'Content-Type': 'application/json'
|
19
|
-
},
|
24
|
+
headers: headers,
|
20
25
|
body: JSON.stringify(body)
|
21
26
|
}).then(function (res) {
|
22
27
|
return res.json();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/useContactForm/index.tsx"],"names":["useContactForm","onSuccess","onError","endpoint","integrationDomain","body","fetch","method","
|
1
|
+
{"version":3,"sources":["../../../../src/hooks/useContactForm/index.tsx"],"names":["useContactForm","onSuccess","onError","endpoint","integrationDomain","interfaceKey","headers","InterfaceKey","body","fetch","method","JSON","stringify","then","res","json"],"mappings":";;;;;AAAA;;AAUO,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,OAYxB;AAAA,MAXJC,SAWI,QAXJA,SAWI;AAAA,MAVJC,OAUI,QAVJA,OAUI;AAAA,2BATJC,QASI;AAAA,MATJA,QASI,8BATO,eASP;AAAA,MARJC,iBAQI,QARJA,iBAQI;AAAA,MAPJC,YAOI,QAPJA,YAOI;AACJ,MAAMC,OAAgC,GAAGD,YAAY,GACjD;AACEE,IAAAA,YAAY,EAAEF,YADhB;AAEE,oBAAgB;AAFlB,GADiD,GAKjD;AACE,oBAAgB;AADlB,GALJ;AASA,SAAO,6BACL,UAACG,IAAD;AAAA,WACEC,KAAK,CAAIL,iBAAJ,SAAyBD,QAAzB,EAAqC;AACxCO,MAAAA,MAAM,EAAE,MADgC;AAExCJ,MAAAA,OAAO,EAAPA,OAFwC;AAGxCE,MAAAA,IAAI,EAAEG,IAAI,CAACC,SAAL,CAAeJ,IAAf;AAHkC,KAArC,CAAL,CAIGK,IAJH,CAIQ,UAACC,GAAD;AAAA,aAASA,GAAG,CAACC,IAAJ,EAAT;AAAA,KAJR,CADF;AAAA,GADK,EAOL;AACEd,IAAAA,SAAS,EAATA,SADF;AAEEC,IAAAA,OAAO,EAAPA;AAFF,GAPK,CAAP;AAYD,CAlCM","sourcesContent":["import { useMutation } from 'react-query'\n\ntype EmailBodyType = {\n name: string\n email: string\n phone: string\n subject: string\n message: string\n}\n\nexport const useContactForm = ({\n onSuccess,\n onError,\n endpoint = 'email/contact',\n integrationDomain,\n interfaceKey,\n}: {\n onSuccess: (data: any) => void\n onError: (error: any) => void\n endpoint?: string\n integrationDomain: string\n interfaceKey?: string\n}) => {\n const headers: HeadersInit | undefined = interfaceKey\n ? {\n InterfaceKey: interfaceKey,\n 'Content-Type': 'application/json',\n }\n : {\n 'Content-Type': 'application/json',\n }\n\n return useMutation(\n (body: EmailBodyType) =>\n fetch(`${integrationDomain}/${endpoint}`, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n }).then((res) => res.json()),\n {\n onSuccess,\n onError,\n }\n )\n}\n"],"file":"index.js"}
|
@@ -4,13 +4,18 @@ export var useContactForm = (_ref) => {
|
|
4
4
|
onSuccess,
|
5
5
|
onError,
|
6
6
|
endpoint = 'email/contact',
|
7
|
-
integrationDomain
|
7
|
+
integrationDomain,
|
8
|
+
interfaceKey
|
8
9
|
} = _ref;
|
10
|
+
var headers = interfaceKey ? {
|
11
|
+
InterfaceKey: interfaceKey,
|
12
|
+
'Content-Type': 'application/json'
|
13
|
+
} : {
|
14
|
+
'Content-Type': 'application/json'
|
15
|
+
};
|
9
16
|
return useMutation(body => fetch(integrationDomain + "/" + endpoint, {
|
10
17
|
method: 'POST',
|
11
|
-
headers
|
12
|
-
'Content-Type': 'application/json'
|
13
|
-
},
|
18
|
+
headers,
|
14
19
|
body: JSON.stringify(body)
|
15
20
|
}).then(res => res.json()), {
|
16
21
|
onSuccess,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/useContactForm/index.tsx"],"names":["useMutation","useContactForm","onSuccess","onError","endpoint","integrationDomain","body","fetch","method","
|
1
|
+
{"version":3,"sources":["../../../../src/hooks/useContactForm/index.tsx"],"names":["useMutation","useContactForm","onSuccess","onError","endpoint","integrationDomain","interfaceKey","headers","InterfaceKey","body","fetch","method","JSON","stringify","then","res","json"],"mappings":"AAAA,SAASA,WAAT,QAA4B,aAA5B;AAUA,OAAO,IAAMC,cAAc,GAAG,UAYxB;AAAA,MAZyB;AAC7BC,IAAAA,SAD6B;AAE7BC,IAAAA,OAF6B;AAG7BC,IAAAA,QAAQ,GAAG,eAHkB;AAI7BC,IAAAA,iBAJ6B;AAK7BC,IAAAA;AAL6B,GAYzB;AACJ,MAAMC,OAAgC,GAAGD,YAAY,GACjD;AACEE,IAAAA,YAAY,EAAEF,YADhB;AAEE,oBAAgB;AAFlB,GADiD,GAKjD;AACE,oBAAgB;AADlB,GALJ;AASA,SAAON,WAAW,CACfS,IAAD,IACEC,KAAK,CAAIL,iBAAJ,SAAyBD,QAAzB,EAAqC;AACxCO,IAAAA,MAAM,EAAE,MADgC;AAExCJ,IAAAA,OAFwC;AAGxCE,IAAAA,IAAI,EAAEG,IAAI,CAACC,SAAL,CAAeJ,IAAf;AAHkC,GAArC,CAAL,CAIGK,IAJH,CAISC,GAAD,IAASA,GAAG,CAACC,IAAJ,EAJjB,CAFc,EAOhB;AACEd,IAAAA,SADF;AAEEC,IAAAA;AAFF,GAPgB,CAAlB;AAYD,CAlCM","sourcesContent":["import { useMutation } from 'react-query'\n\ntype EmailBodyType = {\n name: string\n email: string\n phone: string\n subject: string\n message: string\n}\n\nexport const useContactForm = ({\n onSuccess,\n onError,\n endpoint = 'email/contact',\n integrationDomain,\n interfaceKey,\n}: {\n onSuccess: (data: any) => void\n onError: (error: any) => void\n endpoint?: string\n integrationDomain: string\n interfaceKey?: string\n}) => {\n const headers: HeadersInit | undefined = interfaceKey\n ? {\n InterfaceKey: interfaceKey,\n 'Content-Type': 'application/json',\n }\n : {\n 'Content-Type': 'application/json',\n }\n\n return useMutation(\n (body: EmailBodyType) =>\n fetch(`${integrationDomain}/${endpoint}`, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n }).then((res) => res.json()),\n {\n onSuccess,\n onError,\n }\n )\n}\n"],"file":"index.js"}
|
@@ -5,10 +5,11 @@ declare type EmailBodyType = {
|
|
5
5
|
subject: string;
|
6
6
|
message: string;
|
7
7
|
};
|
8
|
-
export declare const useContactForm: ({ onSuccess, onError, endpoint, integrationDomain, }: {
|
8
|
+
export declare const useContactForm: ({ onSuccess, onError, endpoint, integrationDomain, interfaceKey, }: {
|
9
9
|
onSuccess: (data: any) => void;
|
10
10
|
onError: (error: any) => void;
|
11
11
|
endpoint?: string | undefined;
|
12
12
|
integrationDomain: string;
|
13
|
+
interfaceKey?: string | undefined;
|
13
14
|
}) => import("react-query").MutationResultPair<any, any, EmailBodyType, unknown>;
|
14
15
|
export {};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentecacommerce-theme/lib",
|
3
3
|
"sideEffects": false,
|
4
|
-
"version": "0.12.
|
4
|
+
"version": "0.12.71",
|
5
5
|
"main": "dist/cjs/index.js",
|
6
6
|
"module": "dist/esm/index.js",
|
7
7
|
"types": "dist/types/index.d.ts",
|
@@ -28,9 +28,9 @@
|
|
28
28
|
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
|
29
29
|
"dev": "yarn build:esm --watch"
|
30
30
|
},
|
31
|
-
"gitHead": "
|
31
|
+
"gitHead": "014d976e6862433a10251e76339c95f11b69a73f",
|
32
32
|
"dependencies": {
|
33
|
-
"@sentecacommerce-theme/base": "^0.12.
|
33
|
+
"@sentecacommerce-theme/base": "^0.12.71",
|
34
34
|
"@sentecacommerce/sdk": "2.0.142",
|
35
35
|
"body-scroll-lock": "^3.1.5",
|
36
36
|
"copy-to-clipboard": "^3.3.1",
|