touchstudy-core 0.1.4 → 0.1.6
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/index.js +64 -103
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +58 -97
- package/dist/index.modern.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/isLocalHost.d.ts +2 -0
- package/dist/utils/useGoogleSignOut.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
import { createBrowserHistory } from 'history';
|
2
2
|
import { createAction, createReducer, configureStore } from '@reduxjs/toolkit';
|
3
3
|
import moment from 'moment';
|
4
|
-
import React, {
|
5
|
-
import {
|
6
|
-
import { Row, Col, Form, FormGroup, Modal, ModalHeader, ModalBody, ModalFooter, Button, Alert, Pagination, PaginationItem, PaginationLink, Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
|
4
|
+
import React, { useState, useCallback, useEffect, Fragment, useRef, useMemo } from 'react';
|
5
|
+
import { Row, Col, Form, Modal, ModalHeader, ModalBody, ModalFooter, Button, Alert, Pagination, PaginationItem, PaginationLink, Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
|
7
6
|
import { Formik } from 'formik';
|
8
7
|
import { object, string, boolean } from 'yup';
|
9
8
|
import GoogleLogin, { useGoogleLogout } from '@leecheuk/react-google-login';
|
@@ -21,11 +20,14 @@ var setUser = createAction("common/setUser");
|
|
21
20
|
var setLanguage = createAction("common/setLanguage");
|
22
21
|
var reset = createAction("common/reset");
|
23
22
|
|
23
|
+
var isLocalHost = Boolean(window.location.hostname === "localhost" || window.location.hostname === "[::1]" || window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));
|
24
|
+
|
24
25
|
var GOOGLE_CLIENT_ID = "64118819726-0qlur4qjrs9jbuu6rnoa0u91g680lmpg.apps.googleusercontent.com";
|
25
|
-
var GOOGLE_RECAPTCHA_ID = "6LfNtLUaAAAAAL24lbBV11jS-gBtt1mhtxb4NXs0";
|
26
26
|
var ACCESS_TOKEN = "ACCESS_TOKEN";
|
27
27
|
var DATE_MIN_VALUE = "0001-01-01T00:00:00+00:00";
|
28
|
-
var BASE_URL =
|
28
|
+
var BASE_URL = function () {
|
29
|
+
return isLocalHost ? "https://localhost:7045" : "https://api.studypeak.io";
|
30
|
+
}();
|
29
31
|
var PUSHER_CONFIG = {
|
30
32
|
cluster: "ap1",
|
31
33
|
key: "9018c77328885a14150b"
|
@@ -187,88 +189,64 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
187
189
|
onNavigate = _ref.onNavigate,
|
188
190
|
isTeacher = _ref.isTeacher;
|
189
191
|
var dispatch = useDispatch();
|
190
|
-
var
|
191
|
-
|
192
|
-
|
192
|
+
var _useGoogleSignOut = useGoogleSignOut({
|
193
|
+
onNavigate: onNavigate
|
194
|
+
}),
|
193
195
|
handleSignOut = _useGoogleSignOut.handleSignOut;
|
194
|
-
var clickHandler = useCallback(function () {
|
195
|
-
try {
|
196
|
-
var _exit = false;
|
197
|
-
if (!executeRecaptcha) {
|
198
|
-
return Promise.resolve();
|
199
|
-
}
|
200
|
-
return Promise.resolve(_catch(function () {
|
201
|
-
return Promise.resolve(executeRecaptcha("login")).then(function (result) {
|
202
|
-
_exit = true;
|
203
|
-
return result;
|
204
|
-
});
|
205
|
-
}, function (error) {
|
206
|
-
console.log({
|
207
|
-
error: error
|
208
|
-
});
|
209
|
-
}));
|
210
|
-
} catch (e) {
|
211
|
-
return Promise.reject(e);
|
212
|
-
}
|
213
|
-
}, [executeRecaptcha]);
|
214
|
-
var handleVerify = useCallback(function () {}, []);
|
215
196
|
var onSuccessGoogle = function onSuccessGoogle(res) {
|
216
197
|
try {
|
217
|
-
|
198
|
+
var _temp3 = function () {
|
218
199
|
if (!!(res !== null && res !== void 0 && res.accessToken)) {
|
200
|
+
var _temp2 = function _temp2() {
|
201
|
+
dispatch(setLoading(false));
|
202
|
+
};
|
219
203
|
var _res$profileObj = res.profileObj,
|
220
204
|
email = _res$profileObj.email,
|
221
205
|
imageUrl = _res$profileObj.imageUrl,
|
222
206
|
name = _res$profileObj.name;
|
223
207
|
var accessToken = res.tokenObj.id_token;
|
224
208
|
var googleId = res.googleId;
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
var isFirstLogin = res1.data.isFirstLogin;
|
243
|
-
var tokenJWT = res1.data.token;
|
244
|
-
localStorage.setItem("USER_INFORMATION", JSON.stringify(infoLogin));
|
245
|
-
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
246
|
-
if (!isTeacher && isFirstLogin) {
|
247
|
-
onNavigate("/register/info");
|
248
|
-
} else {
|
249
|
-
onNavigate("/");
|
250
|
-
}
|
251
|
-
});
|
252
|
-
}, function (error) {
|
253
|
-
var _error$response, _error$response$data;
|
254
|
-
var message = undefined;
|
255
|
-
var type = error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.type;
|
256
|
-
if (type === AuthenticationMessage.NotAllowedToRegister) {
|
257
|
-
alert("가입 권한이 없는 계정입니다. 관리자에게 문의하세요.");
|
258
|
-
} else if (type) {
|
259
|
-
var _error$response2, _error$response2$data;
|
260
|
-
message = (error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.message) || ERROR_MESSAGE;
|
209
|
+
var infoLogin = {
|
210
|
+
imageUrl: imageUrl,
|
211
|
+
fullName: name,
|
212
|
+
email: email,
|
213
|
+
token: accessToken,
|
214
|
+
googleId: googleId
|
215
|
+
};
|
216
|
+
var role = isTeacher ? "Teacher" : "Student";
|
217
|
+
dispatch(setLoading(true));
|
218
|
+
var _temp = _catch(function () {
|
219
|
+
return Promise.resolve(apiLoginGoogle(infoLogin, role)).then(function (res1) {
|
220
|
+
var isFirstLogin = res1.data.isFirstLogin;
|
221
|
+
var tokenJWT = res1.data.token;
|
222
|
+
localStorage.setItem("USER_INFORMATION", JSON.stringify(infoLogin));
|
223
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
224
|
+
if (!isTeacher && isFirstLogin) {
|
225
|
+
onNavigate("/register/info");
|
261
226
|
} else {
|
262
|
-
|
263
|
-
message = (error === null || error === void 0 ? void 0 : (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || ERROR_MESSAGE;
|
227
|
+
onNavigate("/");
|
264
228
|
}
|
265
|
-
message && alert(message);
|
266
|
-
handleSignOut();
|
267
229
|
});
|
268
|
-
|
230
|
+
}, function (error) {
|
231
|
+
var _error$response, _error$response$data;
|
232
|
+
var message = undefined;
|
233
|
+
var type = error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.type;
|
234
|
+
if (type === AuthenticationMessage.NotAllowedToRegister) {
|
235
|
+
alert("가입 권한이 없는 계정입니다. 관리자에게 문의하세요.");
|
236
|
+
} else if (type) {
|
237
|
+
var _error$response2, _error$response2$data;
|
238
|
+
message = (error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.message) || ERROR_MESSAGE;
|
239
|
+
} else {
|
240
|
+
var _error$response3;
|
241
|
+
message = (error === null || error === void 0 ? void 0 : (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || ERROR_MESSAGE;
|
242
|
+
}
|
243
|
+
message && alert(message);
|
244
|
+
handleSignOut();
|
269
245
|
});
|
246
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
270
247
|
}
|
271
|
-
}()
|
248
|
+
}();
|
249
|
+
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
|
272
250
|
} catch (e) {
|
273
251
|
return Promise.reject(e);
|
274
252
|
}
|
@@ -280,16 +258,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
280
258
|
return React.createElement(Formik, {
|
281
259
|
initialValues: defaultInfo,
|
282
260
|
validationSchema: schema,
|
283
|
-
onSubmit: function (
|
284
|
-
try {
|
285
|
-
return Promise.resolve(clickHandler()).then(function (clickHandlerRes) {
|
286
|
-
if (!clickHandlerRes) return;
|
287
|
-
values.captcha = clickHandlerRes;
|
288
|
-
});
|
289
|
-
} catch (e) {
|
290
|
-
return Promise.reject(e);
|
291
|
-
}
|
292
|
-
}
|
261
|
+
onSubmit: function onSubmit() {}
|
293
262
|
}, function (formikProps) {
|
294
263
|
var handleSubmit = formikProps.handleSubmit;
|
295
264
|
return React.createElement(Row, {
|
@@ -304,10 +273,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
304
273
|
}, React.createElement("img", {
|
305
274
|
src: "/images/logo.jpeg",
|
306
275
|
className: "" + styles["img-login-rectangle"]
|
307
|
-
}), React.createElement(
|
308
|
-
action: "login",
|
309
|
-
onVerify: handleVerify
|
310
|
-
})), React.createElement(Col, {
|
276
|
+
}), React.createElement(Col, {
|
311
277
|
className: "p-0 mt-1 mb-4"
|
312
278
|
}, React.createElement(GoogleLogin, {
|
313
279
|
clientId: GOOGLE_CLIENT_ID,
|
@@ -386,19 +352,11 @@ var Login = function Login(_ref) {
|
|
386
352
|
md: 12,
|
387
353
|
xs: 12,
|
388
354
|
className: "d-flex justify-content-center h-100 align-items-center"
|
389
|
-
}, React.createElement(GoogleReCaptchaProvider, {
|
390
|
-
useRecaptchaNet: true,
|
391
|
-
reCaptchaKey: GOOGLE_RECAPTCHA_ID,
|
392
|
-
scriptProps: {
|
393
|
-
async: true,
|
394
|
-
defer: true,
|
395
|
-
appendTo: "body"
|
396
|
-
}
|
397
355
|
}, React.createElement(BlockLogin, {
|
398
356
|
defaultInfo: defaultInfo,
|
399
357
|
onNavigate: onNavigate,
|
400
358
|
isTeacher: isTeacher
|
401
|
-
}))))
|
359
|
+
}))));
|
402
360
|
};
|
403
361
|
|
404
362
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
@@ -743,8 +701,11 @@ var getInfo = function getInfo() {
|
|
743
701
|
|
744
702
|
var LayoutContext = function LayoutContext(_ref) {
|
745
703
|
var children = _ref.children,
|
746
|
-
role = _ref.role
|
747
|
-
|
704
|
+
role = _ref.role,
|
705
|
+
onNavigate = _ref.onNavigate;
|
706
|
+
var _useGoogleSignOut = useGoogleSignOut({
|
707
|
+
onNavigate: onNavigate
|
708
|
+
}),
|
748
709
|
handleSignOut = _useGoogleSignOut.handleSignOut;
|
749
710
|
var dispatch = useDispatch();
|
750
711
|
var user = useSelector(function (state) {
|