eddev 0.2.49 → 0.2.51
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.
|
@@ -185,7 +185,7 @@ function createNextApp(opts) {
|
|
|
185
185
|
// Remove pages/api/trpc directory if no _rpc is found
|
|
186
186
|
if (!(0, fs_1.existsSync)((0, path_1.join)(opts.baseDirectory, "apis/_rpc/index.ts")) &&
|
|
187
187
|
!(0, fs_1.existsSync)((0, path_1.join)(opts.baseDirectory, "apis/_rpc.ts"))) {
|
|
188
|
-
|
|
188
|
+
(0, fs_extra_1.removeSync)((0, path_1.join)(serverlessDirectory, "pages/api/trpc"));
|
|
189
189
|
}
|
|
190
190
|
_b.label = 19;
|
|
191
191
|
case 19:
|
|
@@ -55,7 +55,8 @@ function BrowserRouter(props) {
|
|
|
55
55
|
}, []);
|
|
56
56
|
(0, react_1.useEffect)(function () {
|
|
57
57
|
var handle = function (e) {
|
|
58
|
-
|
|
58
|
+
var _a;
|
|
59
|
+
setPendingUrl({ popped: true, url: document.location.href, scrollPosition: (_a = e.state) === null || _a === void 0 ? void 0 : _a.scrollPosition });
|
|
59
60
|
};
|
|
60
61
|
window.addEventListener("popstate", handle);
|
|
61
62
|
return function () {
|
|
@@ -130,38 +130,45 @@ function prepareValuesPayload(form, state, data) {
|
|
|
130
130
|
}
|
|
131
131
|
if (field.type === "checkbox") {
|
|
132
132
|
field.choices.forEach(function (choice, i) {
|
|
133
|
-
data
|
|
133
|
+
data.append("".concat(key, ".").concat(i + 1), (value === null || value === void 0 ? void 0 : value.includes(choice.value)) ? choice.value : "");
|
|
134
|
+
// data[`${key}.${i + 1}`] =
|
|
134
135
|
});
|
|
135
136
|
}
|
|
136
137
|
else {
|
|
137
|
-
|
|
138
|
+
if (value === undefined || value === null) {
|
|
139
|
+
data.append(key, "");
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
console.log("Setting value", field.label, value);
|
|
143
|
+
data.append(key, value);
|
|
144
|
+
}
|
|
145
|
+
// data[key] = value
|
|
138
146
|
}
|
|
139
147
|
};
|
|
140
148
|
for (var _i = 0, _a = form.fields; _i < _a.length; _i++) {
|
|
141
149
|
var field = _a[_i];
|
|
142
150
|
_loop_1(field);
|
|
143
151
|
}
|
|
144
|
-
return data
|
|
152
|
+
// return data
|
|
145
153
|
}
|
|
146
154
|
function submit(form, state) {
|
|
147
155
|
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
-
var url,
|
|
156
|
+
var url, data, result, payload, err_1;
|
|
149
157
|
return __generator(this, function (_a) {
|
|
150
158
|
switch (_a.label) {
|
|
151
159
|
case 0:
|
|
152
160
|
_a.trys.push([0, 3, , 4]);
|
|
153
|
-
url = process.serverless ? "/api/rest/form-submit" : "/wp-json/ed/v1/gf/submit";
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
};
|
|
161
|
+
url = process.serverless ? "/api/rest/form-submit" : "/wp-json/ed/v1/gf/submit-with-uploads";
|
|
162
|
+
data = new FormData();
|
|
163
|
+
data.append("formID", String(form.id));
|
|
164
|
+
prepareValuesPayload(form, state, data);
|
|
158
165
|
return [4 /*yield*/, fetch(url, {
|
|
159
166
|
method: "POST",
|
|
160
167
|
headers: {
|
|
161
|
-
|
|
168
|
+
// "Content-type": "application/json",
|
|
162
169
|
},
|
|
163
170
|
credentials: "include",
|
|
164
|
-
body:
|
|
171
|
+
body: data,
|
|
165
172
|
})];
|
|
166
173
|
case 1:
|
|
167
174
|
result = _a.sent();
|