touchstudy-core 0.1.5 → 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 +52 -95
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +54 -97
- package/dist/index.modern.js.map +1 -1
- 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';
|
@@ -24,11 +23,10 @@ var reset = createAction("common/reset");
|
|
24
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}$/));
|
25
24
|
|
26
25
|
var GOOGLE_CLIENT_ID = "64118819726-0qlur4qjrs9jbuu6rnoa0u91g680lmpg.apps.googleusercontent.com";
|
27
|
-
var GOOGLE_RECAPTCHA_ID = "6LfNtLUaAAAAAL24lbBV11jS-gBtt1mhtxb4NXs0";
|
28
26
|
var ACCESS_TOKEN = "ACCESS_TOKEN";
|
29
27
|
var DATE_MIN_VALUE = "0001-01-01T00:00:00+00:00";
|
30
28
|
var BASE_URL = function () {
|
31
|
-
return isLocalHost ? "https://localhost:7045" : "api.studypeak.io";
|
29
|
+
return isLocalHost ? "https://localhost:7045" : "https://api.studypeak.io";
|
32
30
|
}();
|
33
31
|
var PUSHER_CONFIG = {
|
34
32
|
cluster: "ap1",
|
@@ -191,88 +189,64 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
191
189
|
onNavigate = _ref.onNavigate,
|
192
190
|
isTeacher = _ref.isTeacher;
|
193
191
|
var dispatch = useDispatch();
|
194
|
-
var
|
195
|
-
|
196
|
-
|
192
|
+
var _useGoogleSignOut = useGoogleSignOut({
|
193
|
+
onNavigate: onNavigate
|
194
|
+
}),
|
197
195
|
handleSignOut = _useGoogleSignOut.handleSignOut;
|
198
|
-
var clickHandler = useCallback(function () {
|
199
|
-
try {
|
200
|
-
var _exit = false;
|
201
|
-
if (!executeRecaptcha) {
|
202
|
-
return Promise.resolve();
|
203
|
-
}
|
204
|
-
return Promise.resolve(_catch(function () {
|
205
|
-
return Promise.resolve(executeRecaptcha("login")).then(function (result) {
|
206
|
-
_exit = true;
|
207
|
-
return result;
|
208
|
-
});
|
209
|
-
}, function (error) {
|
210
|
-
console.log({
|
211
|
-
error: error
|
212
|
-
});
|
213
|
-
}));
|
214
|
-
} catch (e) {
|
215
|
-
return Promise.reject(e);
|
216
|
-
}
|
217
|
-
}, [executeRecaptcha]);
|
218
|
-
var handleVerify = useCallback(function () {}, []);
|
219
196
|
var onSuccessGoogle = function onSuccessGoogle(res) {
|
220
197
|
try {
|
221
|
-
|
198
|
+
var _temp3 = function () {
|
222
199
|
if (!!(res !== null && res !== void 0 && res.accessToken)) {
|
200
|
+
var _temp2 = function _temp2() {
|
201
|
+
dispatch(setLoading(false));
|
202
|
+
};
|
223
203
|
var _res$profileObj = res.profileObj,
|
224
204
|
email = _res$profileObj.email,
|
225
205
|
imageUrl = _res$profileObj.imageUrl,
|
226
206
|
name = _res$profileObj.name;
|
227
207
|
var accessToken = res.tokenObj.id_token;
|
228
208
|
var googleId = res.googleId;
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
var isFirstLogin = res1.data.isFirstLogin;
|
247
|
-
var tokenJWT = res1.data.token;
|
248
|
-
localStorage.setItem("USER_INFORMATION", JSON.stringify(infoLogin));
|
249
|
-
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
250
|
-
if (!isTeacher && isFirstLogin) {
|
251
|
-
onNavigate("/register/info");
|
252
|
-
} else {
|
253
|
-
onNavigate("/");
|
254
|
-
}
|
255
|
-
});
|
256
|
-
}, function (error) {
|
257
|
-
var _error$response, _error$response$data;
|
258
|
-
var message = undefined;
|
259
|
-
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;
|
260
|
-
if (type === AuthenticationMessage.NotAllowedToRegister) {
|
261
|
-
alert("가입 권한이 없는 계정입니다. 관리자에게 문의하세요.");
|
262
|
-
} else if (type) {
|
263
|
-
var _error$response2, _error$response2$data;
|
264
|
-
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");
|
265
226
|
} else {
|
266
|
-
|
267
|
-
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("/");
|
268
228
|
}
|
269
|
-
message && alert(message);
|
270
|
-
handleSignOut();
|
271
229
|
});
|
272
|
-
|
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();
|
273
245
|
});
|
246
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
274
247
|
}
|
275
|
-
}()
|
248
|
+
}();
|
249
|
+
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
|
276
250
|
} catch (e) {
|
277
251
|
return Promise.reject(e);
|
278
252
|
}
|
@@ -284,16 +258,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
284
258
|
return React.createElement(Formik, {
|
285
259
|
initialValues: defaultInfo,
|
286
260
|
validationSchema: schema,
|
287
|
-
onSubmit: function (
|
288
|
-
try {
|
289
|
-
return Promise.resolve(clickHandler()).then(function (clickHandlerRes) {
|
290
|
-
if (!clickHandlerRes) return;
|
291
|
-
values.captcha = clickHandlerRes;
|
292
|
-
});
|
293
|
-
} catch (e) {
|
294
|
-
return Promise.reject(e);
|
295
|
-
}
|
296
|
-
}
|
261
|
+
onSubmit: function onSubmit() {}
|
297
262
|
}, function (formikProps) {
|
298
263
|
var handleSubmit = formikProps.handleSubmit;
|
299
264
|
return React.createElement(Row, {
|
@@ -308,10 +273,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
308
273
|
}, React.createElement("img", {
|
309
274
|
src: "/images/logo.jpeg",
|
310
275
|
className: "" + styles["img-login-rectangle"]
|
311
|
-
}), React.createElement(
|
312
|
-
action: "login",
|
313
|
-
onVerify: handleVerify
|
314
|
-
})), React.createElement(Col, {
|
276
|
+
}), React.createElement(Col, {
|
315
277
|
className: "p-0 mt-1 mb-4"
|
316
278
|
}, React.createElement(GoogleLogin, {
|
317
279
|
clientId: GOOGLE_CLIENT_ID,
|
@@ -390,19 +352,11 @@ var Login = function Login(_ref) {
|
|
390
352
|
md: 12,
|
391
353
|
xs: 12,
|
392
354
|
className: "d-flex justify-content-center h-100 align-items-center"
|
393
|
-
}, React.createElement(GoogleReCaptchaProvider, {
|
394
|
-
useRecaptchaNet: true,
|
395
|
-
reCaptchaKey: GOOGLE_RECAPTCHA_ID,
|
396
|
-
scriptProps: {
|
397
|
-
async: true,
|
398
|
-
defer: true,
|
399
|
-
appendTo: "body"
|
400
|
-
}
|
401
355
|
}, React.createElement(BlockLogin, {
|
402
356
|
defaultInfo: defaultInfo,
|
403
357
|
onNavigate: onNavigate,
|
404
358
|
isTeacher: isTeacher
|
405
|
-
}))))
|
359
|
+
}))));
|
406
360
|
};
|
407
361
|
|
408
362
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
@@ -747,8 +701,11 @@ var getInfo = function getInfo() {
|
|
747
701
|
|
748
702
|
var LayoutContext = function LayoutContext(_ref) {
|
749
703
|
var children = _ref.children,
|
750
|
-
role = _ref.role
|
751
|
-
|
704
|
+
role = _ref.role,
|
705
|
+
onNavigate = _ref.onNavigate;
|
706
|
+
var _useGoogleSignOut = useGoogleSignOut({
|
707
|
+
onNavigate: onNavigate
|
708
|
+
}),
|
752
709
|
handleSignOut = _useGoogleSignOut.handleSignOut;
|
753
710
|
var dispatch = useDispatch();
|
754
711
|
var user = useSelector(function (state) {
|