authscape 1.0.150 → 1.0.154
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/index.js +98 -188
- package/package.json +1 -1
- package/src/components/EditableDatagrid.js +37 -3
- package/src/components/FileUploader.js +1 -1
- package/src/components/GoogleMapsAutoComplete.js +31 -207
package/index.js
CHANGED
|
@@ -201,7 +201,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
201
201
|
Object.defineProperty(exports, "__esModule", {
|
|
202
202
|
value: true
|
|
203
203
|
});
|
|
204
|
-
exports
|
|
204
|
+
exports["default"] = void 0;
|
|
205
205
|
var _react = _interopRequireWildcard(require("react"));
|
|
206
206
|
var _xDataGrid = require("@mui/x-data-grid");
|
|
207
207
|
var _material = require("@mui/material");
|
|
@@ -210,11 +210,22 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
210
210
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
211
211
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
212
212
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
213
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
214
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
215
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
216
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
217
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
218
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
213
219
|
var EditableDatagrid = function EditableDatagrid(_ref) {
|
|
214
|
-
var
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
220
|
+
var loadedUser = _ref.loadedUser,
|
|
221
|
+
url = _ref.url,
|
|
222
|
+
columns = _ref.columns,
|
|
223
|
+
_ref$isCellEditable = _ref.isCellEditable,
|
|
224
|
+
_isCellEditable = _ref$isCellEditable === void 0 ? null : _ref$isCellEditable,
|
|
225
|
+
_ref$onCellEdited = _ref.onCellEdited,
|
|
226
|
+
onCellEdited = _ref$onCellEdited === void 0 ? null : _ref$onCellEdited,
|
|
227
|
+
_ref$sx = _ref.sx,
|
|
228
|
+
sx = _ref$sx === void 0 ? {} : _ref$sx,
|
|
218
229
|
_ref$height = _ref.height,
|
|
219
230
|
height = _ref$height === void 0 ? "50vh" : _ref$height,
|
|
220
231
|
_ref$pageSize = _ref.pageSize,
|
|
@@ -223,12 +234,56 @@ var EditableDatagrid = function EditableDatagrid(_ref) {
|
|
|
223
234
|
rowsPerPage = _ref$rowsPerPage === void 0 ? [25, 50, 100] : _ref$rowsPerPage,
|
|
224
235
|
_ref$rowHeight = _ref.rowHeight,
|
|
225
236
|
rowHeight = _ref$rowHeight === void 0 ? 70 : _ref$rowHeight;
|
|
237
|
+
var _useState = (0, _react.useState)([]),
|
|
238
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
239
|
+
rows = _useState2[0],
|
|
240
|
+
setRows = _useState2[1];
|
|
241
|
+
var _useState3 = (0, _react.useState)(0),
|
|
242
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
243
|
+
totalRows = _useState4[0],
|
|
244
|
+
setTotalRows = _useState4[1];
|
|
245
|
+
var _useState5 = (0, _react.useState)(1),
|
|
246
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
247
|
+
offset = _useState6[0],
|
|
248
|
+
setOffset = _useState6[1];
|
|
249
|
+
(0, _react.useEffect)(function () {
|
|
250
|
+
if (loadedUser) {
|
|
251
|
+
reloadDataGrid();
|
|
252
|
+
}
|
|
253
|
+
}, [loadedUser]);
|
|
254
|
+
var reloadDataGrid = /*#__PURE__*/function () {
|
|
255
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
256
|
+
var response;
|
|
257
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
258
|
+
while (1) switch (_context.prev = _context.next) {
|
|
259
|
+
case 0:
|
|
260
|
+
_context.next = 2;
|
|
261
|
+
return apiService().post(url, {
|
|
262
|
+
offset: offset,
|
|
263
|
+
length: pageSize
|
|
264
|
+
});
|
|
265
|
+
case 2:
|
|
266
|
+
response = _context.sent;
|
|
267
|
+
if (response != null && response.status == 200) {
|
|
268
|
+
setTotalRows(response.data.recordsTotal);
|
|
269
|
+
setRows(response.data.data);
|
|
270
|
+
}
|
|
271
|
+
case 4:
|
|
272
|
+
case "end":
|
|
273
|
+
return _context.stop();
|
|
274
|
+
}
|
|
275
|
+
}, _callee);
|
|
276
|
+
}));
|
|
277
|
+
return function reloadDataGrid() {
|
|
278
|
+
return _ref2.apply(this, arguments);
|
|
279
|
+
};
|
|
280
|
+
}();
|
|
226
281
|
var handleCellEditCommit = _react["default"].useCallback(function () {
|
|
227
282
|
return /*#__PURE__*/function () {
|
|
228
|
-
var
|
|
283
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
229
284
|
var id, field, value, editedRow;
|
|
230
|
-
return _regeneratorRuntime().wrap(function
|
|
231
|
-
while (1) switch (
|
|
285
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
286
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
232
287
|
case 0:
|
|
233
288
|
id = params.id, field = params.field, value = params.value;
|
|
234
289
|
editedRow = {
|
|
@@ -239,12 +294,12 @@ var EditableDatagrid = function EditableDatagrid(_ref) {
|
|
|
239
294
|
onCellEdited(editedRow);
|
|
240
295
|
case 3:
|
|
241
296
|
case "end":
|
|
242
|
-
return
|
|
297
|
+
return _context2.stop();
|
|
243
298
|
}
|
|
244
|
-
},
|
|
299
|
+
}, _callee2);
|
|
245
300
|
}));
|
|
246
|
-
return function (
|
|
247
|
-
return
|
|
301
|
+
return function (_x2) {
|
|
302
|
+
return _ref3.apply(this, arguments);
|
|
248
303
|
};
|
|
249
304
|
}();
|
|
250
305
|
}, []);
|
|
@@ -254,11 +309,17 @@ var EditableDatagrid = function EditableDatagrid(_ref) {
|
|
|
254
309
|
}
|
|
255
310
|
}, /*#__PURE__*/_react["default"].createElement(_xDataGrid.DataGrid, {
|
|
256
311
|
rows: rows,
|
|
312
|
+
sx: sx,
|
|
257
313
|
columns: columns,
|
|
314
|
+
rowCount: totalRows,
|
|
315
|
+
paginationMode: "server",
|
|
258
316
|
getRowHeight: function getRowHeight() {
|
|
259
317
|
return rowHeight;
|
|
260
318
|
},
|
|
261
319
|
pageSize: pageSize,
|
|
320
|
+
onPageChange: function onPageChange(newPage) {
|
|
321
|
+
return setOffset(newPage);
|
|
322
|
+
},
|
|
262
323
|
rowsPerPageOptions: rowsPerPage,
|
|
263
324
|
disableSelectionOnClick: true,
|
|
264
325
|
onCellEditCommit: handleCellEditCommit(),
|
|
@@ -270,7 +331,8 @@ var EditableDatagrid = function EditableDatagrid(_ref) {
|
|
|
270
331
|
}
|
|
271
332
|
}));
|
|
272
333
|
};
|
|
273
|
-
|
|
334
|
+
var _default = EditableDatagrid;
|
|
335
|
+
exports["default"] = _default;
|
|
274
336
|
"use strict";
|
|
275
337
|
|
|
276
338
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
@@ -513,7 +575,6 @@ var FileUploader = function FileUploader(_ref) {
|
|
|
513
575
|
}, [fileLoaderUri]);
|
|
514
576
|
return /*#__PURE__*/_react["default"].createElement(_system.Box, {
|
|
515
577
|
sx: {
|
|
516
|
-
marginTop: 1,
|
|
517
578
|
display: isHidden ? "none" : "block"
|
|
518
579
|
}
|
|
519
580
|
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
@@ -741,13 +802,10 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
741
802
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
742
803
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
743
804
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
744
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
745
805
|
var AutoCompleteDialog = function AutoCompleteDialog(_ref) {
|
|
746
806
|
var placeholder = _ref.placeholder,
|
|
747
807
|
onSelected = _ref.onSelected,
|
|
748
808
|
defaultValue = _ref.defaultValue,
|
|
749
|
-
react_hook_form_Control = _ref.react_hook_form_Control,
|
|
750
|
-
react_hook_form_errors = _ref.react_hook_form_errors,
|
|
751
809
|
onChange = _ref.onChange;
|
|
752
810
|
var txtAddressField = (0, _react.useRef)(null);
|
|
753
811
|
var dismissSuggestions = function dismissSuggestions() {
|
|
@@ -774,9 +832,13 @@ var AutoCompleteDialog = function AutoCompleteDialog(_ref) {
|
|
|
774
832
|
setValue(e.target.value);
|
|
775
833
|
onChange(e.target.value);
|
|
776
834
|
};
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
835
|
+
|
|
836
|
+
// useEffect(() => {
|
|
837
|
+
|
|
838
|
+
// setValue(defaultValue) // test this!!!!
|
|
839
|
+
|
|
840
|
+
// }, [defaultValue])
|
|
841
|
+
|
|
780
842
|
var determineComponentType = function determineComponentType(component) {
|
|
781
843
|
var returnVal = {};
|
|
782
844
|
for (var index = 0; index < component.types.length; index++) {
|
|
@@ -916,52 +978,8 @@ var AutoCompleteDialog = function AutoCompleteDialog(_ref) {
|
|
|
916
978
|
})["catch"](function (error) {
|
|
917
979
|
alert(error);
|
|
918
980
|
});
|
|
919
|
-
|
|
920
|
-
// When user selects a place, we can replace the keyword without request data from API
|
|
921
|
-
// by setting the second parameter to "false"
|
|
922
|
-
//setValue(description, false);
|
|
923
|
-
// clearSuggestions();
|
|
924
|
-
|
|
925
|
-
// var parseUSAddress = parser.parseLocation(description);
|
|
926
|
-
|
|
927
|
-
// // Get latitude and longitude via utility functions
|
|
928
|
-
// getGeocode({ address: description }).then((results) => {
|
|
929
|
-
// const { lat, lng } = getLatLng(results[0]);
|
|
930
|
-
// //console.log("📍 Coordinates: ", { lat, lng });
|
|
931
|
-
|
|
932
|
-
// const zipCode = getZipCode(results[0], false);
|
|
933
|
-
|
|
934
|
-
// let address = "";
|
|
935
|
-
// if (parseUSAddress.number != null)
|
|
936
|
-
// {
|
|
937
|
-
// address += parseUSAddress.number + " ";
|
|
938
|
-
// }
|
|
939
|
-
|
|
940
|
-
// if (parseUSAddress.street != null)
|
|
941
|
-
// {
|
|
942
|
-
// address += parseUSAddress.street + " ";
|
|
943
|
-
// }
|
|
944
|
-
|
|
945
|
-
// if (parseUSAddress.type != null)
|
|
946
|
-
// {
|
|
947
|
-
// address += parseUSAddress.type;
|
|
948
|
-
// }
|
|
949
|
-
|
|
950
|
-
// onSelected({
|
|
951
|
-
// address: address,
|
|
952
|
-
// city: parseUSAddress.city,
|
|
953
|
-
// state: parseUSAddress.state,
|
|
954
|
-
// zip: zipCode,
|
|
955
|
-
// lat: lat,
|
|
956
|
-
// lng: lng
|
|
957
|
-
// });
|
|
958
|
-
|
|
959
|
-
// setValue(address, false);
|
|
960
|
-
|
|
961
|
-
// });
|
|
962
981
|
};
|
|
963
982
|
};
|
|
964
|
-
|
|
965
983
|
var renderSuggestions = function renderSuggestions() {
|
|
966
984
|
return data.map(function (suggestion) {
|
|
967
985
|
var place_id = suggestion.place_id,
|
|
@@ -979,8 +997,9 @@ var AutoCompleteDialog = function AutoCompleteDialog(_ref) {
|
|
|
979
997
|
})), /*#__PURE__*/_react["default"].createElement(_ListItemText["default"], null, /*#__PURE__*/_react["default"].createElement("strong", null, main_text), " ", /*#__PURE__*/_react["default"].createElement("small", null, secondary_text)));
|
|
980
998
|
});
|
|
981
999
|
};
|
|
982
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null,
|
|
1000
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Stack["default"], null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
|
983
1001
|
ref: txtAddressField,
|
|
1002
|
+
defaultValue: defaultValue,
|
|
984
1003
|
name: "address",
|
|
985
1004
|
autoComplete: "new-password",
|
|
986
1005
|
label: placeholder,
|
|
@@ -988,35 +1007,7 @@ var AutoCompleteDialog = function AutoCompleteDialog(_ref) {
|
|
|
988
1007
|
fullWidth: true,
|
|
989
1008
|
value: value,
|
|
990
1009
|
onChange: handleInput
|
|
991
|
-
}),
|
|
992
|
-
sx: {
|
|
993
|
-
color: "red"
|
|
994
|
-
}
|
|
995
|
-
}, "Address is required.")), react_hook_form_Control != null && /*#__PURE__*/_react["default"].createElement(_reactHookForm.Controller, {
|
|
996
|
-
control: react_hook_form_Control,
|
|
997
|
-
rules: {
|
|
998
|
-
required: true
|
|
999
|
-
},
|
|
1000
|
-
name: "address",
|
|
1001
|
-
render: function render(_ref3) {
|
|
1002
|
-
var field = _ref3.field;
|
|
1003
|
-
return /*#__PURE__*/_react["default"].createElement(_Stack["default"], null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], _extends({
|
|
1004
|
-
ref: txtAddressField,
|
|
1005
|
-
name: "address"
|
|
1006
|
-
}, field, {
|
|
1007
|
-
autoComplete: "new-password",
|
|
1008
|
-
label: placeholder,
|
|
1009
|
-
variant: "outlined",
|
|
1010
|
-
fullWidth: true,
|
|
1011
|
-
value: value,
|
|
1012
|
-
onChange: handleInput
|
|
1013
|
-
})), react_hook_form_errors != null && react_hook_form_errors.address && react_hook_form_errors.address.type === 'required' && /*#__PURE__*/_react["default"].createElement(Typography, {
|
|
1014
|
-
sx: {
|
|
1015
|
-
color: "red"
|
|
1016
|
-
}
|
|
1017
|
-
}, "Address is required."));
|
|
1018
|
-
}
|
|
1019
|
-
}), status == "OK" && /*#__PURE__*/_react["default"].createElement(_material.MenuList, {
|
|
1010
|
+
})), status == "OK" && /*#__PURE__*/_react["default"].createElement(_material.MenuList, {
|
|
1020
1011
|
ref: ref,
|
|
1021
1012
|
sx: {
|
|
1022
1013
|
position: "absolute",
|
|
@@ -1026,20 +1017,16 @@ var AutoCompleteDialog = function AutoCompleteDialog(_ref) {
|
|
|
1026
1017
|
}
|
|
1027
1018
|
}, renderSuggestions()));
|
|
1028
1019
|
};
|
|
1029
|
-
var GooglePlacesModal = function GooglePlacesModal(
|
|
1030
|
-
var onAddressSelected =
|
|
1031
|
-
|
|
1032
|
-
_address =
|
|
1033
|
-
|
|
1034
|
-
_city =
|
|
1035
|
-
|
|
1036
|
-
_state =
|
|
1037
|
-
|
|
1038
|
-
_postalCode =
|
|
1039
|
-
_ref4$react_hook_form = _ref4.react_hook_form_Control,
|
|
1040
|
-
react_hook_form_Control = _ref4$react_hook_form === void 0 ? null : _ref4$react_hook_form,
|
|
1041
|
-
_ref4$react_hook_form2 = _ref4.react_hook_form_errors,
|
|
1042
|
-
react_hook_form_errors = _ref4$react_hook_form2 === void 0 ? null : _ref4$react_hook_form2;
|
|
1020
|
+
var GooglePlacesModal = function GooglePlacesModal(_ref3) {
|
|
1021
|
+
var onAddressSelected = _ref3.onAddressSelected,
|
|
1022
|
+
_ref3$_address = _ref3._address,
|
|
1023
|
+
_address = _ref3$_address === void 0 ? "" : _ref3$_address,
|
|
1024
|
+
_ref3$_city = _ref3._city,
|
|
1025
|
+
_city = _ref3$_city === void 0 ? "" : _ref3$_city,
|
|
1026
|
+
_ref3$_state = _ref3._state,
|
|
1027
|
+
_state = _ref3$_state === void 0 ? "" : _ref3$_state,
|
|
1028
|
+
_ref3$_postalCode = _ref3._postalCode,
|
|
1029
|
+
_postalCode = _ref3$_postalCode === void 0 ? "" : _ref3$_postalCode;
|
|
1043
1030
|
var _useState = (0, _react.useState)(_address),
|
|
1044
1031
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1045
1032
|
address = _useState2[0],
|
|
@@ -1066,8 +1053,6 @@ var GooglePlacesModal = function GooglePlacesModal(_ref4) {
|
|
|
1066
1053
|
setLng = _useState12[1];
|
|
1067
1054
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_system.Box, null, /*#__PURE__*/_react["default"].createElement(AutoCompleteDialog, {
|
|
1068
1055
|
placeholder: "Address",
|
|
1069
|
-
react_hook_form_Control: react_hook_form_Control,
|
|
1070
|
-
react_hook_form_errors: react_hook_form_errors,
|
|
1071
1056
|
defaultValue: address,
|
|
1072
1057
|
onSelected: function onSelected(data) {
|
|
1073
1058
|
setAddress(data.address);
|
|
@@ -1090,7 +1075,7 @@ var GooglePlacesModal = function GooglePlacesModal(_ref4) {
|
|
|
1090
1075
|
}, /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
|
|
1091
1076
|
item: true,
|
|
1092
1077
|
xs: 6
|
|
1093
|
-
}, /*#__PURE__*/_react["default"].createElement(_system.Box, null,
|
|
1078
|
+
}, /*#__PURE__*/_react["default"].createElement(_system.Box, null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
|
1094
1079
|
id: "outlined-basic",
|
|
1095
1080
|
label: "City",
|
|
1096
1081
|
name: "city",
|
|
@@ -1100,35 +1085,10 @@ var GooglePlacesModal = function GooglePlacesModal(_ref4) {
|
|
|
1100
1085
|
onChange: function onChange(val) {
|
|
1101
1086
|
setCity(val.currentTarget.value);
|
|
1102
1087
|
}
|
|
1103
|
-
}), react_hook_form_Control != null && /*#__PURE__*/_react["default"].createElement(_reactHookForm.Controller, {
|
|
1104
|
-
control: react_hook_form_Control,
|
|
1105
|
-
rules: {
|
|
1106
|
-
required: true
|
|
1107
|
-
},
|
|
1108
|
-
name: "city",
|
|
1109
|
-
render: function render(_ref5) {
|
|
1110
|
-
var field = _ref5.field;
|
|
1111
|
-
return /*#__PURE__*/_react["default"].createElement(_Stack["default"], null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], _extends({
|
|
1112
|
-
id: "outlined-basic",
|
|
1113
|
-
label: "City",
|
|
1114
|
-
name: "city",
|
|
1115
|
-
variant: "outlined"
|
|
1116
|
-
}, field, {
|
|
1117
|
-
fullWidth: true,
|
|
1118
|
-
value: city,
|
|
1119
|
-
onChange: function onChange(val) {
|
|
1120
|
-
setCity(val.currentTarget.value);
|
|
1121
|
-
}
|
|
1122
|
-
})), react_hook_form_errors != null && react_hook_form_errors.city && react_hook_form_errors.city.type === 'required' && /*#__PURE__*/_react["default"].createElement(Typography, {
|
|
1123
|
-
sx: {
|
|
1124
|
-
color: "red"
|
|
1125
|
-
}
|
|
1126
|
-
}, "City is required."));
|
|
1127
|
-
}
|
|
1128
1088
|
}))), /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
|
|
1129
1089
|
item: true,
|
|
1130
1090
|
xs: 6
|
|
1131
|
-
}, /*#__PURE__*/_react["default"].createElement(_system.Box, null,
|
|
1091
|
+
}, /*#__PURE__*/_react["default"].createElement(_system.Box, null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
|
1132
1092
|
id: "outlined-basic",
|
|
1133
1093
|
label: "State",
|
|
1134
1094
|
name: "state",
|
|
@@ -1138,36 +1098,11 @@ var GooglePlacesModal = function GooglePlacesModal(_ref4) {
|
|
|
1138
1098
|
onChange: function onChange(val) {
|
|
1139
1099
|
setState(val.currentTarget.value);
|
|
1140
1100
|
}
|
|
1141
|
-
}), react_hook_form_Control != null && /*#__PURE__*/_react["default"].createElement(_reactHookForm.Controller, {
|
|
1142
|
-
control: react_hook_form_Control,
|
|
1143
|
-
rules: {
|
|
1144
|
-
required: true
|
|
1145
|
-
},
|
|
1146
|
-
name: "state",
|
|
1147
|
-
render: function render(_ref6) {
|
|
1148
|
-
var field = _ref6.field;
|
|
1149
|
-
return /*#__PURE__*/_react["default"].createElement(_Stack["default"], null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], _extends({
|
|
1150
|
-
id: "outlined-basic",
|
|
1151
|
-
label: "State"
|
|
1152
|
-
}, field, {
|
|
1153
|
-
name: "state",
|
|
1154
|
-
variant: "outlined",
|
|
1155
|
-
fullWidth: true,
|
|
1156
|
-
value: state,
|
|
1157
|
-
onChange: function onChange(val) {
|
|
1158
|
-
setState(val.currentTarget.value);
|
|
1159
|
-
}
|
|
1160
|
-
})), react_hook_form_errors != null && react_hook_form_errors.state && react_hook_form_errors.state.type === 'required' && /*#__PURE__*/_react["default"].createElement(Typography, {
|
|
1161
|
-
sx: {
|
|
1162
|
-
color: "red"
|
|
1163
|
-
}
|
|
1164
|
-
}, "State is required."));
|
|
1165
|
-
}
|
|
1166
1101
|
})))), /*#__PURE__*/_react["default"].createElement(_system.Box, {
|
|
1167
1102
|
sx: {
|
|
1168
1103
|
marginTop: 2
|
|
1169
1104
|
}
|
|
1170
|
-
},
|
|
1105
|
+
}, /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
|
1171
1106
|
id: "outlined-basic",
|
|
1172
1107
|
label: "Postal code",
|
|
1173
1108
|
name: "postalCode",
|
|
@@ -1177,31 +1112,6 @@ var GooglePlacesModal = function GooglePlacesModal(_ref4) {
|
|
|
1177
1112
|
onChange: function onChange(val) {
|
|
1178
1113
|
setPostalcode(val.currentTarget.value);
|
|
1179
1114
|
}
|
|
1180
|
-
}), react_hook_form_Control != null && /*#__PURE__*/_react["default"].createElement(_reactHookForm.Controller, {
|
|
1181
|
-
control: react_hook_form_Control,
|
|
1182
|
-
rules: {
|
|
1183
|
-
required: true
|
|
1184
|
-
},
|
|
1185
|
-
name: "postalCode",
|
|
1186
|
-
render: function render(_ref7) {
|
|
1187
|
-
var field = _ref7.field;
|
|
1188
|
-
return /*#__PURE__*/_react["default"].createElement(_Stack["default"], null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], _extends({
|
|
1189
|
-
id: "outlined-basic",
|
|
1190
|
-
label: "Postal code"
|
|
1191
|
-
}, field, {
|
|
1192
|
-
name: "postalCode",
|
|
1193
|
-
variant: "outlined",
|
|
1194
|
-
fullWidth: true,
|
|
1195
|
-
value: zip,
|
|
1196
|
-
onChange: function onChange(val) {
|
|
1197
|
-
setPostalcode(val.currentTarget.value);
|
|
1198
|
-
}
|
|
1199
|
-
})), react_hook_form_errors != null && react_hook_form_errors.postalCode && react_hook_form_errors.postalCode.type === 'required' && /*#__PURE__*/_react["default"].createElement(Typography, {
|
|
1200
|
-
sx: {
|
|
1201
|
-
color: "red"
|
|
1202
|
-
}
|
|
1203
|
-
}, "Postal Code is required."));
|
|
1204
|
-
}
|
|
1205
1115
|
}))));
|
|
1206
1116
|
};
|
|
1207
1117
|
exports.GooglePlacesModal = GooglePlacesModal;
|
package/package.json
CHANGED
|
@@ -2,7 +2,35 @@ import React, {useEffect, useState} from 'react';
|
|
|
2
2
|
import { DataGrid, GridActionsCellItem } from "@mui/x-data-grid";
|
|
3
3
|
import { Box } from '@mui/material';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const EditableDatagrid = ({loadedUser, url, columns, isCellEditable = null, onCellEdited = null, sx = {}, height="50vh", pageSize = 50, rowsPerPage = [25, 50, 100], rowHeight = 70}) => {
|
|
6
|
+
|
|
7
|
+
const [rows, setRows] = useState([]);
|
|
8
|
+
const [totalRows, setTotalRows] = useState(0);
|
|
9
|
+
const [offset, setOffset] = useState(1);
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
|
|
13
|
+
if (loadedUser)
|
|
14
|
+
{
|
|
15
|
+
reloadDataGrid();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}, [loadedUser]);
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const reloadDataGrid = async () => {
|
|
22
|
+
let response = await apiService().post(url,
|
|
23
|
+
{
|
|
24
|
+
offset: offset,
|
|
25
|
+
length: pageSize
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (response != null && response.status == 200)
|
|
29
|
+
{
|
|
30
|
+
setTotalRows(response.data.recordsTotal);
|
|
31
|
+
setRows(response.data.data);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
6
34
|
|
|
7
35
|
const handleCellEditCommit = React.useCallback(() => async (params) => {
|
|
8
36
|
|
|
@@ -17,13 +45,17 @@ export const EditableDatagrid = ({columns, rows, isCellEditable, onCellEdited, h
|
|
|
17
45
|
<Box sx={{height}}>
|
|
18
46
|
<DataGrid
|
|
19
47
|
rows={rows}
|
|
48
|
+
sx={sx}
|
|
20
49
|
columns={columns}
|
|
50
|
+
rowCount={totalRows}
|
|
51
|
+
paginationMode="server"
|
|
21
52
|
getRowHeight={() => {
|
|
22
53
|
return rowHeight;
|
|
23
54
|
}}
|
|
24
55
|
pageSize={pageSize}
|
|
56
|
+
onPageChange={(newPage) => setOffset(newPage)}
|
|
25
57
|
rowsPerPageOptions={rowsPerPage}
|
|
26
|
-
disableSelectionOnClick
|
|
58
|
+
disableSelectionOnClick={true}
|
|
27
59
|
onCellEditCommit={handleCellEditCommit()}
|
|
28
60
|
isCellEditable={(params) => {
|
|
29
61
|
|
|
@@ -37,4 +69,6 @@ export const EditableDatagrid = ({columns, rows, isCellEditable, onCellEdited, h
|
|
|
37
69
|
</Box>
|
|
38
70
|
)
|
|
39
71
|
|
|
40
|
-
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default EditableDatagrid;
|
|
@@ -19,7 +19,7 @@ import usePlacesAutocomplete, {
|
|
|
19
19
|
getLatLng,
|
|
20
20
|
} from "use-places-autocomplete";
|
|
21
21
|
|
|
22
|
-
const AutoCompleteDialog = ({placeholder, onSelected, defaultValue,
|
|
22
|
+
const AutoCompleteDialog = ({placeholder, onSelected, defaultValue, onChange}) => {
|
|
23
23
|
|
|
24
24
|
const txtAddressField = useRef(null);
|
|
25
25
|
|
|
@@ -51,11 +51,11 @@ const AutoCompleteDialog = ({placeholder, onSelected, defaultValue, react_hook_f
|
|
|
51
51
|
onChange(e.target.value);
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
useEffect(() => {
|
|
54
|
+
// useEffect(() => {
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
// setValue(defaultValue) // test this!!!!
|
|
57
57
|
|
|
58
|
-
}, [defaultValue])
|
|
58
|
+
// }, [defaultValue])
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
const determineComponentType = (component) => {
|
|
@@ -258,51 +258,6 @@ const AutoCompleteDialog = ({placeholder, onSelected, defaultValue, react_hook_f
|
|
|
258
258
|
.catch((error) => {
|
|
259
259
|
alert(error);
|
|
260
260
|
});
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
// When user selects a place, we can replace the keyword without request data from API
|
|
264
|
-
// by setting the second parameter to "false"
|
|
265
|
-
//setValue(description, false);
|
|
266
|
-
// clearSuggestions();
|
|
267
|
-
|
|
268
|
-
// var parseUSAddress = parser.parseLocation(description);
|
|
269
|
-
|
|
270
|
-
// // Get latitude and longitude via utility functions
|
|
271
|
-
// getGeocode({ address: description }).then((results) => {
|
|
272
|
-
// const { lat, lng } = getLatLng(results[0]);
|
|
273
|
-
// //console.log("📍 Coordinates: ", { lat, lng });
|
|
274
|
-
|
|
275
|
-
// const zipCode = getZipCode(results[0], false);
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
// let address = "";
|
|
279
|
-
// if (parseUSAddress.number != null)
|
|
280
|
-
// {
|
|
281
|
-
// address += parseUSAddress.number + " ";
|
|
282
|
-
// }
|
|
283
|
-
|
|
284
|
-
// if (parseUSAddress.street != null)
|
|
285
|
-
// {
|
|
286
|
-
// address += parseUSAddress.street + " ";
|
|
287
|
-
// }
|
|
288
|
-
|
|
289
|
-
// if (parseUSAddress.type != null)
|
|
290
|
-
// {
|
|
291
|
-
// address += parseUSAddress.type;
|
|
292
|
-
// }
|
|
293
|
-
|
|
294
|
-
// onSelected({
|
|
295
|
-
// address: address,
|
|
296
|
-
// city: parseUSAddress.city,
|
|
297
|
-
// state: parseUSAddress.state,
|
|
298
|
-
// zip: zipCode,
|
|
299
|
-
// lat: lat,
|
|
300
|
-
// lng: lng
|
|
301
|
-
// });
|
|
302
|
-
|
|
303
|
-
// setValue(address, false);
|
|
304
|
-
|
|
305
|
-
// });
|
|
306
261
|
};
|
|
307
262
|
|
|
308
263
|
const renderSuggestions = () =>
|
|
@@ -325,36 +280,9 @@ const AutoCompleteDialog = ({placeholder, onSelected, defaultValue, react_hook_f
|
|
|
325
280
|
return (
|
|
326
281
|
<>
|
|
327
282
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
{react_hook_form_errors != null && react_hook_form_errors.address &&
|
|
332
|
-
react_hook_form_errors.address.type === 'required'
|
|
333
|
-
&& <Typography sx={{color: "red"}}>Address is required.</Typography>}
|
|
334
|
-
</Stack>
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
{react_hook_form_Control != null &&
|
|
338
|
-
<Controller
|
|
339
|
-
control={react_hook_form_Control}
|
|
340
|
-
rules={{ required: true }}
|
|
341
|
-
name="address"
|
|
342
|
-
render={({ field }) => (
|
|
343
|
-
<Stack>
|
|
344
|
-
<TextField ref={txtAddressField} name="address" {...field} autoComplete="new-password" label={placeholder} variant="outlined" fullWidth={true} value={value} onChange={handleInput} />
|
|
345
|
-
{react_hook_form_errors != null && react_hook_form_errors.address &&
|
|
346
|
-
react_hook_form_errors.address.type === 'required'
|
|
347
|
-
&& <Typography sx={{color: "red"}}>Address is required.</Typography>}
|
|
348
|
-
</Stack>
|
|
349
|
-
)}
|
|
350
|
-
/>
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
283
|
+
<Stack>
|
|
284
|
+
<TextField ref={txtAddressField} defaultValue={defaultValue} name="address" autoComplete="new-password" label={placeholder} variant="outlined" fullWidth={true} value={value} onChange={handleInput} />
|
|
285
|
+
</Stack>
|
|
358
286
|
|
|
359
287
|
{status == "OK" &&
|
|
360
288
|
<MenuList ref={ref} sx={{position:"absolute", zIndex:9999, backgroundColor:"white", border:"1px solid black"}}>
|
|
@@ -370,9 +298,7 @@ export const GooglePlacesModal = ({
|
|
|
370
298
|
_address = "",
|
|
371
299
|
_city = "",
|
|
372
300
|
_state = "",
|
|
373
|
-
_postalCode = ""
|
|
374
|
-
react_hook_form_Control = null,
|
|
375
|
-
react_hook_form_errors = null
|
|
301
|
+
_postalCode = ""
|
|
376
302
|
}) => {
|
|
377
303
|
const [address, setAddress] = useState(_address);
|
|
378
304
|
const [city, setCity] = useState(_city);
|
|
@@ -387,8 +313,6 @@ export const GooglePlacesModal = ({
|
|
|
387
313
|
<Box>
|
|
388
314
|
<AutoCompleteDialog
|
|
389
315
|
placeholder={"Address"}
|
|
390
|
-
react_hook_form_Control={react_hook_form_Control}
|
|
391
|
-
react_hook_form_errors={react_hook_form_errors}
|
|
392
316
|
defaultValue={address}
|
|
393
317
|
onSelected={(data) => {
|
|
394
318
|
setAddress(data.address);
|
|
@@ -409,48 +333,17 @@ export const GooglePlacesModal = ({
|
|
|
409
333
|
<Grid item xs={6}>
|
|
410
334
|
<Box>
|
|
411
335
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
/>
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
{react_hook_form_Control != null &&
|
|
427
|
-
<Controller
|
|
428
|
-
control={react_hook_form_Control}
|
|
429
|
-
rules={{ required: true }}
|
|
430
|
-
name="city"
|
|
431
|
-
render={({ field }) => (
|
|
432
|
-
<Stack>
|
|
433
|
-
<TextField
|
|
434
|
-
id="outlined-basic"
|
|
435
|
-
label="City"
|
|
436
|
-
name="city"
|
|
437
|
-
variant="outlined"
|
|
438
|
-
{...field}
|
|
439
|
-
fullWidth={true}
|
|
440
|
-
value={city}
|
|
441
|
-
onChange={(val) => {
|
|
442
|
-
setCity(val.currentTarget.value);
|
|
443
|
-
}}
|
|
444
|
-
/>
|
|
445
|
-
|
|
446
|
-
{react_hook_form_errors != null && react_hook_form_errors.city &&
|
|
447
|
-
react_hook_form_errors.city.type === 'required'
|
|
448
|
-
&& <Typography sx={{color: "red"}}>City is required.</Typography>}
|
|
449
|
-
</Stack>
|
|
450
|
-
)}
|
|
451
|
-
/>
|
|
452
|
-
}
|
|
453
|
-
|
|
336
|
+
<TextField
|
|
337
|
+
id="outlined-basic"
|
|
338
|
+
label="City"
|
|
339
|
+
name="city"
|
|
340
|
+
variant="outlined"
|
|
341
|
+
fullWidth={true}
|
|
342
|
+
value={city}
|
|
343
|
+
onChange={(val) => {
|
|
344
|
+
setCity(val.currentTarget.value);
|
|
345
|
+
}}
|
|
346
|
+
/>
|
|
454
347
|
|
|
455
348
|
</Box>
|
|
456
349
|
</Grid>
|
|
@@ -458,52 +351,17 @@ export const GooglePlacesModal = ({
|
|
|
458
351
|
<Grid item xs={6}>
|
|
459
352
|
<Box>
|
|
460
353
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}}
|
|
473
|
-
/>
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
{react_hook_form_Control != null &&
|
|
477
|
-
<Controller
|
|
478
|
-
control={react_hook_form_Control}
|
|
479
|
-
rules={{ required: true }}
|
|
480
|
-
name="state"
|
|
481
|
-
render={({ field }) => (
|
|
482
|
-
<Stack>
|
|
483
|
-
|
|
484
|
-
<TextField
|
|
485
|
-
id="outlined-basic"
|
|
486
|
-
label="State"
|
|
487
|
-
{...field}
|
|
488
|
-
name="state"
|
|
489
|
-
variant="outlined"
|
|
490
|
-
fullWidth={true}
|
|
491
|
-
value={state}
|
|
492
|
-
onChange={(val) => {
|
|
493
|
-
setState(val.currentTarget.value);
|
|
494
|
-
}}
|
|
495
|
-
/>
|
|
496
|
-
|
|
497
|
-
{react_hook_form_errors != null && react_hook_form_errors.state &&
|
|
498
|
-
react_hook_form_errors.state.type === 'required'
|
|
499
|
-
&& <Typography sx={{color: "red"}}>State is required.</Typography>}
|
|
500
|
-
</Stack>
|
|
501
|
-
)}
|
|
502
|
-
/>
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
354
|
+
<TextField
|
|
355
|
+
id="outlined-basic"
|
|
356
|
+
label="State"
|
|
357
|
+
name="state"
|
|
358
|
+
variant="outlined"
|
|
359
|
+
fullWidth={true}
|
|
360
|
+
value={state}
|
|
361
|
+
onChange={(val) => {
|
|
362
|
+
setState(val.currentTarget.value);
|
|
363
|
+
}}
|
|
364
|
+
/>
|
|
507
365
|
|
|
508
366
|
</Box>
|
|
509
367
|
</Grid>
|
|
@@ -511,9 +369,6 @@ export const GooglePlacesModal = ({
|
|
|
511
369
|
|
|
512
370
|
<Box sx={{ marginTop: 2 }}>
|
|
513
371
|
|
|
514
|
-
|
|
515
|
-
{react_hook_form_Control == null &&
|
|
516
|
-
|
|
517
372
|
<TextField
|
|
518
373
|
id="outlined-basic"
|
|
519
374
|
label="Postal code"
|
|
@@ -525,38 +380,7 @@ export const GooglePlacesModal = ({
|
|
|
525
380
|
setPostalcode(val.currentTarget.value);
|
|
526
381
|
}}
|
|
527
382
|
/>
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
{react_hook_form_Control != null &&
|
|
531
|
-
<Controller
|
|
532
|
-
control={react_hook_form_Control}
|
|
533
|
-
rules={{ required: true }}
|
|
534
|
-
name="postalCode"
|
|
535
|
-
render={({ field }) => (
|
|
536
|
-
<Stack>
|
|
537
|
-
|
|
538
|
-
<TextField
|
|
539
|
-
id="outlined-basic"
|
|
540
|
-
label="Postal code"
|
|
541
|
-
{...field}
|
|
542
|
-
name="postalCode"
|
|
543
|
-
variant="outlined"
|
|
544
|
-
fullWidth={true}
|
|
545
|
-
value={zip}
|
|
546
|
-
onChange={(val) => {
|
|
547
|
-
setPostalcode(val.currentTarget.value);
|
|
548
|
-
}}
|
|
549
|
-
/>
|
|
550
|
-
|
|
551
|
-
{react_hook_form_errors != null && react_hook_form_errors.postalCode &&
|
|
552
|
-
react_hook_form_errors.postalCode.type === 'required'
|
|
553
|
-
&& <Typography sx={{color: "red"}}>Postal Code is required.</Typography>}
|
|
554
|
-
</Stack>
|
|
555
|
-
)}
|
|
556
|
-
/>
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
|
|
383
|
+
|
|
560
384
|
</Box>
|
|
561
385
|
|
|
562
386
|
{/* <Box sx={{ marginTop: 1, textAlign: "right" }}>
|