@stokr/components-library 2.3.44-beta.3 → 2.3.45
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/components/AdminDashboard/Table/ReactTable.js +42 -11
- package/dist/components/AdminDashboard/Table/ReactTable.stories.js +140 -9
- package/dist/components/AdminDashboard/Table/ReactTableWrapper.js +8 -2
- package/dist/components/AdminDashboard/Table/Table.styles.js +14 -2
- package/dist/components/ButtonContainer/ButtonContainer.styles.js +6 -1
- package/dist/components/CryptoAddress/CryptoAddress.js +6 -3
- package/dist/components/CryptoAddress/RadioWrap.js +2 -2
- package/dist/components/HeroBlock/HeroVideoBlock.js +108 -0
- package/dist/components/InfoIcon/InfoIcon.js +4 -2
- package/dist/components/InfoIcon/InfoIcon.styles.js +5 -1
- package/dist/components/Modal/NewVentureModal/NewVentureModal.js +104 -265
- package/dist/components/Modal/NewVentureModal/NewVentureModal.stories.js +3 -2
- package/dist/context/AuthContext.js +159 -107
- package/dist/context/Checkbox/CheckboxContext.js +164 -0
- package/dist/hooks/useNewVentureForm.js +310 -0
- package/dist/index.js +11 -0
- package/package.json +1 -1
|
@@ -9,8 +9,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _formik = require("formik");
|
|
11
11
|
var Yup = _interopRequireWildcard(require("yup"));
|
|
12
|
-
var _fetchDataPublic = _interopRequireDefault(require("../../../api/fetchDataPublic"));
|
|
13
|
-
var _htmlReactParser = _interopRequireDefault(require("html-react-parser"));
|
|
14
12
|
var _AuthContext = require("../../../context/AuthContext");
|
|
15
13
|
var _globalVariables = require("../../../constants/globalVariables");
|
|
16
14
|
var _Modal = require("../Modal");
|
|
@@ -21,41 +19,44 @@ var _ComponentWrapper = _interopRequireDefault(require("../../ComponentWrapper/C
|
|
|
21
19
|
var _Input = _interopRequireDefault(require("../../Input/Input"));
|
|
22
20
|
var _Checkbox = _interopRequireDefault(require("../../Checkbox/Checkbox"));
|
|
23
21
|
var _Button = _interopRequireDefault(require("../../Button/Button.styles"));
|
|
22
|
+
var _useNewVentureForm2 = require("../../../hooks/useNewVentureForm");
|
|
24
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
26
25
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
26
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
28
27
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
28
|
+
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); }
|
|
29
29
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
30
30
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
31
|
+
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; }
|
|
31
32
|
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
32
33
|
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); } }
|
|
33
34
|
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); }); }; }
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
35
|
+
var NewVentureModal = function NewVentureModal(props) {
|
|
36
|
+
var _useContext = (0, _react.useContext)(_AuthContext.AuthContext),
|
|
37
|
+
user = _useContext.user;
|
|
38
|
+
var _useNewVentureForm = (0, _useNewVentureForm2.useNewVentureForm)(props.project, user),
|
|
39
|
+
email = _useNewVentureForm.email,
|
|
40
|
+
name = _useNewVentureForm.name,
|
|
41
|
+
mailingList = _useNewVentureForm.mailingList,
|
|
42
|
+
privateInvestorList = _useNewVentureForm.privateInvestorList,
|
|
43
|
+
mailingListText = _useNewVentureForm.mailingListText,
|
|
44
|
+
privateInvestorListText = _useNewVentureForm.privateInvestorListText,
|
|
45
|
+
mailingListDisabled = _useNewVentureForm.mailingListDisabled,
|
|
46
|
+
privateInvestorListDisabled = _useNewVentureForm.privateInvestorListDisabled,
|
|
47
|
+
optionalCheckBox = _useNewVentureForm.optionalCheckBox,
|
|
48
|
+
optionalCheckBoxText = _useNewVentureForm.optionalCheckBoxText,
|
|
49
|
+
optionalCheckBoxChecked = _useNewVentureForm.optionalCheckBoxChecked,
|
|
50
|
+
checkedCheckboxes = _useNewVentureForm.checkedCheckboxes,
|
|
51
|
+
isSubmitting = _useNewVentureForm.isSubmitting,
|
|
52
|
+
successMessage = _useNewVentureForm.successMessage,
|
|
53
|
+
errorMessage = _useNewVentureForm.errorMessage,
|
|
54
|
+
handleSubmit = _useNewVentureForm.handleSubmit,
|
|
55
|
+
updateCheckedCheckboxes = _useNewVentureForm.updateCheckedCheckboxes;
|
|
56
|
+
var validationSchema = Yup.object().shape({
|
|
57
|
+
email: Yup.string().matches(_globalVariables.emailRegex, "Oops, that's not a valid address").required("Oops, this can't be blank"),
|
|
58
|
+
name: Yup.string().required("Oops, this can't be blank")
|
|
59
|
+
});
|
|
59
60
|
var title = props.title,
|
|
60
61
|
description = props.description,
|
|
61
62
|
isModalOpen = props.isModalOpen,
|
|
@@ -68,207 +69,10 @@ var NewVentureModal = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
68
69
|
successMsg = props.successMsg,
|
|
69
70
|
errorMsg = props.errorMsg,
|
|
70
71
|
modalBotContent = props.modalBotContent;
|
|
71
|
-
var _useState = (0, _react.useState)(initialFormValues),
|
|
72
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
73
|
-
formValues = _useState2[0],
|
|
74
|
-
setformValues = _useState2[1];
|
|
75
|
-
var _useState3 = (0, _react.useState)(undefined),
|
|
76
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
77
|
-
successMessage = _useState4[0],
|
|
78
|
-
setSuccessMessage = _useState4[1];
|
|
79
|
-
var _useState5 = (0, _react.useState)(null),
|
|
80
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
81
|
-
errorMessage = _useState6[0],
|
|
82
|
-
seterrorMessage = _useState6[1];
|
|
83
|
-
var _React$useContext = _react.default.useContext(_AuthContext.AuthContext),
|
|
84
|
-
user = _React$useContext.user,
|
|
85
|
-
setUser = _React$useContext.setUser,
|
|
86
|
-
checkIfPrivateInvestor = _React$useContext.checkIfPrivateInvestor,
|
|
87
|
-
checkIfUserSubscribed = _React$useContext.checkIfUserSubscribed;
|
|
88
|
-
var _useState7 = (0, _react.useState)(),
|
|
89
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
90
|
-
checkboxes = _useState8[0],
|
|
91
|
-
setcheckboxes = _useState8[1];
|
|
92
|
-
var _useState9 = (0, _react.useState)([]),
|
|
93
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
94
|
-
checkedCheckboxes = _useState10[0],
|
|
95
|
-
setcheckedCheckboxes = _useState10[1];
|
|
96
|
-
var _useState11 = (0, _react.useState)(false),
|
|
97
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
98
|
-
isActionLoading = _useState12[0],
|
|
99
|
-
setisActionLoading = _useState12[1];
|
|
100
|
-
(0, _react.useEffect)(function () {
|
|
101
|
-
fecthCheckboxes();
|
|
102
|
-
}, []);
|
|
103
|
-
(0, _react.useEffect)(function () {
|
|
104
|
-
//we need to check if userData is subscribed for the selected project
|
|
105
|
-
//every time the userData or project is updated
|
|
106
|
-
//check only if these userData properties weren't checked already
|
|
107
|
-
var project = props.project;
|
|
108
|
-
if (!user || !user._id || !(project && project._id)) return;
|
|
109
|
-
if (user.isPrivateInvestor === undefined) {
|
|
110
|
-
checkIfPrivateInvestor(project);
|
|
111
|
-
}
|
|
112
|
-
if (user.isSubscribed === undefined) {
|
|
113
|
-
checkIfUserSubscribed(project);
|
|
114
|
-
}
|
|
115
|
-
}, [user, props.project]);
|
|
116
|
-
(0, _react.useEffect)(function () {
|
|
117
|
-
//when the checkboxes are fetched, set the text of the checkboxes
|
|
118
|
-
if (checkboxes) {
|
|
119
|
-
var formValuesCopy = _objectSpread({}, formValues);
|
|
120
|
-
Object.values(checkboxes).forEach(function (checkbox) {
|
|
121
|
-
if (checkbox.label === 'createPrivateInvestor') {
|
|
122
|
-
formValuesCopy.privateInvestorListText = (0, _htmlReactParser.default)(checkbox.agreementText);
|
|
123
|
-
} else if (checkbox.label === 'subscribeToProject') {
|
|
124
|
-
formValuesCopy.mailingListText = (0, _htmlReactParser.default)(checkbox.agreementText);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
setformValues(formValuesCopy);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
//change text of checkboxes if user is logged in and is already subscribed
|
|
131
|
-
if (user) {
|
|
132
|
-
var _formValuesCopy = _objectSpread({}, formValues);
|
|
133
|
-
_formValuesCopy.email = user.email;
|
|
134
|
-
_formValuesCopy.name = user.username;
|
|
135
|
-
if (user.isPrivateInvestor) {
|
|
136
|
-
_formValuesCopy.privateInvestorListText = 'You are already registered on the whitelist.';
|
|
137
|
-
_formValuesCopy.privateInvestorList = true;
|
|
138
|
-
_formValuesCopy.privateInvestorListDisabled = true;
|
|
139
|
-
} else if (user.privateInvestorStatus && user.privateInvestorStatus !== 'Admitted') {
|
|
140
|
-
//if private investor status is under review
|
|
141
|
-
_formValuesCopy.privateInvestorListText = 'Your profile is under review. An account manager will reach out to you to confirm your eligibility.';
|
|
142
|
-
_formValuesCopy.privateInvestorList = true;
|
|
143
|
-
_formValuesCopy.privateInvestorListDisabled = true;
|
|
144
|
-
}
|
|
145
|
-
if (user.isSubscribed) {
|
|
146
|
-
_formValuesCopy.mailingList = true;
|
|
147
|
-
_formValuesCopy.mailingListText = 'You already subscribed to the email notification list.';
|
|
148
|
-
_formValuesCopy.mailingListDisabled = true;
|
|
149
|
-
}
|
|
150
|
-
setformValues(_formValuesCopy);
|
|
151
|
-
}
|
|
152
|
-
}, [user, checkboxes]);
|
|
153
|
-
var fecthCheckboxes = /*#__PURE__*/function () {
|
|
154
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
155
|
-
var response;
|
|
156
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
157
|
-
while (1) switch (_context.prev = _context.next) {
|
|
158
|
-
case 0:
|
|
159
|
-
_context.prev = 0;
|
|
160
|
-
_context.next = 3;
|
|
161
|
-
return (0, _fetchDataPublic.default)('compliance/get-checkbox-group', {
|
|
162
|
-
group: 'newVentureModal'
|
|
163
|
-
});
|
|
164
|
-
case 3:
|
|
165
|
-
response = _context.sent;
|
|
166
|
-
if (response != null) {
|
|
167
|
-
setcheckboxes(response);
|
|
168
|
-
}
|
|
169
|
-
_context.next = 10;
|
|
170
|
-
break;
|
|
171
|
-
case 7:
|
|
172
|
-
_context.prev = 7;
|
|
173
|
-
_context.t0 = _context["catch"](0);
|
|
174
|
-
console.log('🚀 ~ file: NewVentureModal.js:111 ~ error:', _context.t0);
|
|
175
|
-
case 10:
|
|
176
|
-
case "end":
|
|
177
|
-
return _context.stop();
|
|
178
|
-
}
|
|
179
|
-
}, _callee, null, [[0, 7]]);
|
|
180
|
-
}));
|
|
181
|
-
return function fecthCheckboxes() {
|
|
182
|
-
return _ref.apply(this, arguments);
|
|
183
|
-
};
|
|
184
|
-
}();
|
|
185
|
-
var validationSchema = Yup.object().shape({
|
|
186
|
-
email: Yup.string().matches(_globalVariables.emailRegex, "Oops, that's not a valid address").required('Oops, this can‘t be blank'),
|
|
187
|
-
name: Yup.string().required('Oops, this can‘t be blank')
|
|
188
|
-
});
|
|
189
|
-
var onSubmitButton = /*#__PURE__*/function () {
|
|
190
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(values) {
|
|
191
|
-
var project, dataToSend, response, userCopy, _error$response, _error$response$data, errorParsed;
|
|
192
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
193
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
194
|
-
case 0:
|
|
195
|
-
project = props.project;
|
|
196
|
-
dataToSend = {
|
|
197
|
-
email: values.email,
|
|
198
|
-
projectId: project._id,
|
|
199
|
-
name: values.name,
|
|
200
|
-
checkedCheckboxes: checkedCheckboxes,
|
|
201
|
-
salesChannel: salesChannel
|
|
202
|
-
};
|
|
203
|
-
setisActionLoading(true);
|
|
204
|
-
_context2.prev = 3;
|
|
205
|
-
if (values.privateInvestorList && !formValues.privateInvestorListDisabled) {
|
|
206
|
-
dataToSend.createPrivateInvestor = true;
|
|
207
|
-
}
|
|
208
|
-
if (values.mailingList && !formValues.mailingListDisabled) {
|
|
209
|
-
dataToSend.subscribeToProject = true;
|
|
210
|
-
}
|
|
211
|
-
_context2.next = 8;
|
|
212
|
-
return (0, _fetchDataPublic.default)('private-investor/public/create', dataToSend);
|
|
213
|
-
case 8:
|
|
214
|
-
response = _context2.sent;
|
|
215
|
-
setSuccessMessage(successMsg ? successMsg : "An account manager will reach out to you with further details on the offering and the investment procedure.");
|
|
216
|
-
userCopy = _objectSpread({}, user);
|
|
217
|
-
if (!userCopy.email) {
|
|
218
|
-
//add email and username when subscribing without being logged in
|
|
219
|
-
userCopy.email = values.email;
|
|
220
|
-
userCopy.username = values.name;
|
|
221
|
-
}
|
|
222
|
-
if (response !== null && response !== void 0 && response.privateInvestor) {
|
|
223
|
-
userCopy.privateInvestorStatus = response.privateInvestor.status;
|
|
224
|
-
}
|
|
225
|
-
if (response !== null && response !== void 0 && response.subscribedToProject) {
|
|
226
|
-
userCopy.isSubscribed = true;
|
|
227
|
-
}
|
|
228
|
-
setUser(userCopy);
|
|
229
|
-
_context2.next = 21;
|
|
230
|
-
break;
|
|
231
|
-
case 17:
|
|
232
|
-
_context2.prev = 17;
|
|
233
|
-
_context2.t0 = _context2["catch"](3);
|
|
234
|
-
console.log('🚀 ~ error', _context2.t0);
|
|
235
|
-
//show error message from BE only for 406 error
|
|
236
|
-
if ((_context2.t0 === null || _context2.t0 === void 0 || (_error$response = _context2.t0.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 406) {
|
|
237
|
-
errorParsed = (_error$response$data = _context2.t0.response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.substring(7);
|
|
238
|
-
seterrorMessage(errorMsg ? errorMsg : errorParsed);
|
|
239
|
-
} else {
|
|
240
|
-
seterrorMessage( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "Something went wrong. Please try again a bit later or contact us at", ' ', /*#__PURE__*/_react.default.createElement("a", {
|
|
241
|
-
href: "mailto:support@stokr.io",
|
|
242
|
-
style: {
|
|
243
|
-
color: 'inherit'
|
|
244
|
-
}
|
|
245
|
-
}, "support@stokr.io"), ' '));
|
|
246
|
-
}
|
|
247
|
-
case 21:
|
|
248
|
-
_context2.prev = 21;
|
|
249
|
-
setisActionLoading(false);
|
|
250
|
-
return _context2.finish(21);
|
|
251
|
-
case 24:
|
|
252
|
-
case "end":
|
|
253
|
-
return _context2.stop();
|
|
254
|
-
}
|
|
255
|
-
}, _callee2, null, [[3, 17, 21, 24]]);
|
|
256
|
-
}));
|
|
257
|
-
return function onSubmitButton(_x) {
|
|
258
|
-
return _ref2.apply(this, arguments);
|
|
259
|
-
};
|
|
260
|
-
}();
|
|
261
72
|
return /*#__PURE__*/_react.default.createElement(_Modal.Modal, {
|
|
262
73
|
isOpen: isModalOpen,
|
|
263
|
-
onClose: function onClose() {
|
|
264
|
-
|
|
265
|
-
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
266
|
-
mailingList: false,
|
|
267
|
-
privateInvestorList: false,
|
|
268
|
-
optionalCheckBox: false
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
onModalClose();
|
|
74
|
+
onClose: function onClose(e) {
|
|
75
|
+
onModalClose(e);
|
|
272
76
|
}
|
|
273
77
|
}, /*#__PURE__*/_react.default.createElement(_Grid.Row, null, /*#__PURE__*/_react.default.createElement(_Grid.Column, {
|
|
274
78
|
part: 8
|
|
@@ -278,42 +82,77 @@ var NewVentureModal = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
278
82
|
modalBot: true
|
|
279
83
|
}, modalBotContent)), /*#__PURE__*/_react.default.createElement(_Grid.Column, {
|
|
280
84
|
part: 8
|
|
281
|
-
}, /*#__PURE__*/_react.default.createElement(_Modal.ModalInner, null, successMessage || errorMessage ? /*#__PURE__*/_react.default.createElement(_Text.default, null, /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement("p", null, errorMessage ? errorMessage : successMessage)
|
|
282
|
-
|
|
85
|
+
}, /*#__PURE__*/_react.default.createElement(_Modal.ModalInner, null, successMessage || errorMessage ? /*#__PURE__*/_react.default.createElement(_Text.default, null, /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement("p", null, errorMessage ? errorMessage : successMessage), successMessage && /*#__PURE__*/_react.default.createElement(_ComponentWrapper.default, {
|
|
86
|
+
noPaddingHorizontal: true
|
|
87
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
88
|
+
fluid: true,
|
|
89
|
+
id: "private-investor-success-button",
|
|
90
|
+
onClick: function onClick() {
|
|
91
|
+
if (user !== null && user !== void 0 && user._id) {
|
|
92
|
+
window.location.href = "https://dashboard.".concat(process.env.REACT_APP_WEBSITE_DOMAIN, "/checklist");
|
|
93
|
+
} else {
|
|
94
|
+
window.location.href = "/signup?email=".concat(email);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, "Continue"))) : /*#__PURE__*/_react.default.createElement(_formik.Formik, {
|
|
98
|
+
initialValues: {
|
|
99
|
+
email: email || '',
|
|
100
|
+
name: name || '',
|
|
101
|
+
mailingList: mailingList || false,
|
|
102
|
+
privateInvestorList: privateInvestorList || false,
|
|
103
|
+
optionalCheckBoxChecked: optionalCheckBoxChecked || false
|
|
104
|
+
},
|
|
283
105
|
validationSchema: validationSchema,
|
|
284
106
|
onSubmit: function onSubmit(values) {
|
|
285
107
|
onFormSend(values);
|
|
286
|
-
|
|
108
|
+
handleSubmit(values);
|
|
287
109
|
},
|
|
288
110
|
id: "register-interest-form"
|
|
289
|
-
}, function (
|
|
290
|
-
var values =
|
|
291
|
-
errors =
|
|
292
|
-
touched =
|
|
293
|
-
handleBlur =
|
|
294
|
-
handleChange =
|
|
295
|
-
setFieldValue =
|
|
296
|
-
setFieldTouched =
|
|
297
|
-
var onChangeWithTouch = function
|
|
298
|
-
var
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
111
|
+
}, function (_ref) {
|
|
112
|
+
var values = _ref.values,
|
|
113
|
+
errors = _ref.errors,
|
|
114
|
+
touched = _ref.touched,
|
|
115
|
+
handleBlur = _ref.handleBlur,
|
|
116
|
+
handleChange = _ref.handleChange,
|
|
117
|
+
setFieldValue = _ref.setFieldValue,
|
|
118
|
+
setFieldTouched = _ref.setFieldTouched;
|
|
119
|
+
var onChangeWithTouch = /*#__PURE__*/function () {
|
|
120
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
|
|
121
|
+
var field;
|
|
122
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
123
|
+
while (1) switch (_context.prev = _context.next) {
|
|
124
|
+
case 0:
|
|
125
|
+
field = e.target;
|
|
126
|
+
_context.next = 3;
|
|
127
|
+
return setFieldValue(field.name, field.value, false);
|
|
128
|
+
case 3:
|
|
129
|
+
_context.next = 5;
|
|
130
|
+
return setFieldTouched(field.name);
|
|
131
|
+
case 5:
|
|
132
|
+
case "end":
|
|
133
|
+
return _context.stop();
|
|
134
|
+
}
|
|
135
|
+
}, _callee);
|
|
136
|
+
}));
|
|
137
|
+
return function onChangeWithTouch(_x) {
|
|
138
|
+
return _ref2.apply(this, arguments);
|
|
139
|
+
};
|
|
140
|
+
}();
|
|
141
|
+
var oneOfCheckbox = values.mailingList && !mailingListDisabled || values.privateInvestorList && !privateInvestorListDisabled;
|
|
142
|
+
var optionalCheckBoxForm = optionalCheckBox ? values.optionalCheckBoxChecked : true;
|
|
143
|
+
if (email && !values.email) {
|
|
144
|
+
setFieldValue('email', email);
|
|
306
145
|
setFieldTouched('email');
|
|
307
146
|
}
|
|
308
|
-
if (
|
|
309
|
-
setFieldValue('name',
|
|
147
|
+
if (name && !values.name) {
|
|
148
|
+
setFieldValue('name', name);
|
|
310
149
|
setFieldTouched('name');
|
|
311
150
|
}
|
|
312
|
-
if (
|
|
313
|
-
setFieldValue('mailingList',
|
|
151
|
+
if (mailingList && !values.mailingList) {
|
|
152
|
+
setFieldValue('mailingList', mailingList);
|
|
314
153
|
}
|
|
315
|
-
if (
|
|
316
|
-
setFieldValue('privateInvestorList',
|
|
154
|
+
if (privateInvestorList && !values.privateInvestorList) {
|
|
155
|
+
setFieldValue('privateInvestorList', privateInvestorList);
|
|
317
156
|
}
|
|
318
157
|
|
|
319
158
|
//create custom handleCheckboxChange to add the checkbox to the checkedCheckboxes array
|
|
@@ -322,17 +161,17 @@ var NewVentureModal = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
322
161
|
|
|
323
162
|
//we set id of the checkbox to be the same string as checkbox label, so we can identify the checkbox
|
|
324
163
|
if (e.target.checked) {
|
|
325
|
-
|
|
164
|
+
updateCheckedCheckboxes([].concat(_toConsumableArray(checkedCheckboxes), [e.target.id]));
|
|
326
165
|
} else {
|
|
327
|
-
|
|
166
|
+
updateCheckedCheckboxes(checkedCheckboxes.filter(function (item) {
|
|
328
167
|
return item !== e.target.id;
|
|
329
168
|
}));
|
|
330
169
|
}
|
|
331
170
|
};
|
|
332
|
-
var submitDisabled = !touched.email || !!errors.email || !touched.name || !!errors.name ||
|
|
171
|
+
var submitDisabled = !touched.email || !!errors.email || !touched.name || !!errors.name || isSubmitting || !oneOfCheckbox || !optionalCheckBoxForm;
|
|
333
172
|
return /*#__PURE__*/_react.default.createElement(_Form.default, null, /*#__PURE__*/_react.default.createElement(_ComponentWrapper.default, {
|
|
334
173
|
noPadding: true
|
|
335
|
-
}, /*#__PURE__*/_react.default.createElement(_Form.FormField, null, !user && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
174
|
+
}, /*#__PURE__*/_react.default.createElement(_Form.FormField, null, !(user !== null && user !== void 0 && user._id) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
336
175
|
id: "new-venture-email",
|
|
337
176
|
name: "email",
|
|
338
177
|
type: "email",
|
|
@@ -369,9 +208,9 @@ var NewVentureModal = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
369
208
|
id: 'createPrivateInvestor' //same as checkbox label
|
|
370
209
|
,
|
|
371
210
|
name: "privateInvestorList",
|
|
372
|
-
text:
|
|
211
|
+
text: privateInvestorListText,
|
|
373
212
|
checked: values.privateInvestorList,
|
|
374
|
-
disabled:
|
|
213
|
+
disabled: privateInvestorListDisabled,
|
|
375
214
|
onChange: handleCheckboxChange,
|
|
376
215
|
onBlur: handleBlur
|
|
377
216
|
})), /*#__PURE__*/_react.default.createElement(_Form.FormField, {
|
|
@@ -382,12 +221,12 @@ var NewVentureModal = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
382
221
|
}, /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
|
|
383
222
|
id: "subscribeToProject",
|
|
384
223
|
name: "mailingList",
|
|
385
|
-
text:
|
|
224
|
+
text: mailingListText,
|
|
386
225
|
checked: values.mailingList,
|
|
387
|
-
disabled:
|
|
226
|
+
disabled: mailingListDisabled,
|
|
388
227
|
onChange: handleCheckboxChange,
|
|
389
228
|
onBlur: handleBlur
|
|
390
|
-
})),
|
|
229
|
+
})), optionalCheckBox && /*#__PURE__*/_react.default.createElement(_Form.FormField, {
|
|
391
230
|
style: {
|
|
392
231
|
marginTop: '2rem',
|
|
393
232
|
marginBottom: -5
|
|
@@ -395,7 +234,7 @@ var NewVentureModal = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
395
234
|
}, /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
|
|
396
235
|
id: "optionalCheckBox",
|
|
397
236
|
name: "optionalCheckBoxChecked",
|
|
398
|
-
text:
|
|
237
|
+
text: optionalCheckBoxText,
|
|
399
238
|
value: values.optionalCheckBoxChecked,
|
|
400
239
|
checked: values.optionalCheckBoxChecked,
|
|
401
240
|
onChange: handleChange,
|
|
@@ -417,7 +256,7 @@ var NewVentureModal = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
417
256
|
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
418
257
|
type: "submit",
|
|
419
258
|
id: "private-investor-subscribe-button",
|
|
420
|
-
disabled: submitDisabled
|
|
259
|
+
disabled: submitDisabled
|
|
421
260
|
}, "register")), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.default, {
|
|
422
261
|
paddingVeticalHalf: true,
|
|
423
262
|
noPaddingHorizontal: true
|
|
@@ -425,7 +264,7 @@ var NewVentureModal = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
425
264
|
show: popupError
|
|
426
265
|
}, popupError)));
|
|
427
266
|
})))));
|
|
428
|
-
}
|
|
267
|
+
};
|
|
429
268
|
exports.NewVentureModal = NewVentureModal;
|
|
430
269
|
NewVentureModal.propTypes = {
|
|
431
270
|
isModalOpen: _propTypes.default.bool.isRequired,
|
|
@@ -442,7 +281,7 @@ NewVentureModal.propTypes = {
|
|
|
442
281
|
};
|
|
443
282
|
NewVentureModal.defaultProps = {
|
|
444
283
|
title: 'Register Your Interest',
|
|
445
|
-
description: '
|
|
284
|
+
description: 'Register your interest and learn more about this investment opportunity.',
|
|
446
285
|
popupError: null,
|
|
447
286
|
project: {
|
|
448
287
|
_id: '',
|
|
@@ -10,6 +10,7 @@ var _NewVentureModal = require("./NewVentureModal");
|
|
|
10
10
|
var _global = _interopRequireDefault(require("../../../styles/global"));
|
|
11
11
|
var _AuthContext = require("../../../context/AuthContext");
|
|
12
12
|
var _reactRouterDom = require("react-router-dom");
|
|
13
|
+
var _CheckboxContext = require("../../../context/Checkbox/CheckboxContext");
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -105,11 +106,11 @@ var Template = function Template(args) {
|
|
|
105
106
|
style: {
|
|
106
107
|
padding: '10px 20px'
|
|
107
108
|
}
|
|
108
|
-
}, "Open New Venture Modal"), /*#__PURE__*/_react.default.createElement(_reactRouterDom.BrowserRouter, null, /*#__PURE__*/_react.default.createElement(_AuthContext.AuthProvider, null, /*#__PURE__*/_react.default.createElement(_NewVentureModal.NewVentureModal, _extends({}, args, {
|
|
109
|
+
}, "Open New Venture Modal"), /*#__PURE__*/_react.default.createElement(_reactRouterDom.BrowserRouter, null, /*#__PURE__*/_react.default.createElement(_AuthContext.AuthProvider, null, /*#__PURE__*/_react.default.createElement(_CheckboxContext.CheckboxProvider, null, /*#__PURE__*/_react.default.createElement(_NewVentureModal.NewVentureModal, _extends({}, args, {
|
|
109
110
|
isModalOpen: isOpen,
|
|
110
111
|
onModalClose: handleModalClose,
|
|
111
112
|
onFormSend: handleFormSend
|
|
112
|
-
})))));
|
|
113
|
+
}))))));
|
|
113
114
|
};
|
|
114
115
|
var Default = Template.bind({});
|
|
115
116
|
exports.Default = Default;
|