touchstudy-core 0.1.5 → 0.1.7
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/Selects/CustomSelect.d.ts +3 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +102 -101
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +102 -104
- package/dist/index.modern.js.map +1 -1
- package/dist/utils/constants.d.ts +2 -1
- package/dist/utils/types.d.ts +1 -3
- package/dist/utils/useGoogleSignOut.d.ts +1 -0
- package/package.json +2 -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';
|
@@ -14,6 +13,7 @@ import i18n from 'i18next';
|
|
14
13
|
import { initReactI18next, useTranslation } from 'react-i18next';
|
15
14
|
export { I18nextProvider, useTranslation } from 'react-i18next';
|
16
15
|
import { IoChevronDown } from 'react-icons/io5';
|
16
|
+
import Select from 'react-select';
|
17
17
|
|
18
18
|
var setLoading = createAction("common/setLoading");
|
19
19
|
var setAlert = createAction("common/setAlert");
|
@@ -24,17 +24,17 @@ var reset = createAction("common/reset");
|
|
24
24
|
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
25
|
|
26
26
|
var GOOGLE_CLIENT_ID = "64118819726-0qlur4qjrs9jbuu6rnoa0u91g680lmpg.apps.googleusercontent.com";
|
27
|
-
var GOOGLE_RECAPTCHA_ID = "6LfNtLUaAAAAAL24lbBV11jS-gBtt1mhtxb4NXs0";
|
28
27
|
var ACCESS_TOKEN = "ACCESS_TOKEN";
|
29
28
|
var DATE_MIN_VALUE = "0001-01-01T00:00:00+00:00";
|
30
29
|
var BASE_URL = function () {
|
31
|
-
return isLocalHost ? "https://localhost:7045" : "api.studypeak.io";
|
30
|
+
return isLocalHost ? "https://localhost:7045" : "https://api.studypeak.io";
|
32
31
|
}();
|
33
32
|
var PUSHER_CONFIG = {
|
34
33
|
cluster: "ap1",
|
35
34
|
key: "9018c77328885a14150b"
|
36
35
|
};
|
37
|
-
var EXAM_CHANNEL = "
|
36
|
+
var EXAM_CHANNEL = "presence-exam-channel";
|
37
|
+
var EXAM_STUDENT_CHANNEL = "EXAM-CHANNEL-{examCode}-STUDENT-{studentId}";
|
38
38
|
var getAccessToken = function getAccessToken() {
|
39
39
|
try {
|
40
40
|
return localStorage.getItem(ACCESS_TOKEN);
|
@@ -191,88 +191,64 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
191
191
|
onNavigate = _ref.onNavigate,
|
192
192
|
isTeacher = _ref.isTeacher;
|
193
193
|
var dispatch = useDispatch();
|
194
|
-
var
|
195
|
-
|
196
|
-
|
194
|
+
var _useGoogleSignOut = useGoogleSignOut({
|
195
|
+
onNavigate: onNavigate
|
196
|
+
}),
|
197
197
|
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
198
|
var onSuccessGoogle = function onSuccessGoogle(res) {
|
220
199
|
try {
|
221
|
-
|
200
|
+
var _temp3 = function () {
|
222
201
|
if (!!(res !== null && res !== void 0 && res.accessToken)) {
|
202
|
+
var _temp2 = function _temp2() {
|
203
|
+
dispatch(setLoading(false));
|
204
|
+
};
|
223
205
|
var _res$profileObj = res.profileObj,
|
224
206
|
email = _res$profileObj.email,
|
225
207
|
imageUrl = _res$profileObj.imageUrl,
|
226
208
|
name = _res$profileObj.name;
|
227
209
|
var accessToken = res.tokenObj.id_token;
|
228
210
|
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;
|
211
|
+
var infoLogin = {
|
212
|
+
imageUrl: imageUrl,
|
213
|
+
fullName: name,
|
214
|
+
email: email,
|
215
|
+
token: accessToken,
|
216
|
+
googleId: googleId
|
217
|
+
};
|
218
|
+
var role = isTeacher ? "Teacher" : "Student";
|
219
|
+
dispatch(setLoading(true));
|
220
|
+
var _temp = _catch(function () {
|
221
|
+
return Promise.resolve(apiLoginGoogle(infoLogin, role)).then(function (res1) {
|
222
|
+
var isFirstLogin = res1.data.isFirstLogin;
|
223
|
+
var tokenJWT = res1.data.token;
|
224
|
+
localStorage.setItem("USER_INFORMATION", JSON.stringify(infoLogin));
|
225
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
226
|
+
if (!isTeacher && isFirstLogin) {
|
227
|
+
onNavigate("/register/info");
|
265
228
|
} 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;
|
229
|
+
onNavigate("/");
|
268
230
|
}
|
269
|
-
message && alert(message);
|
270
|
-
handleSignOut();
|
271
231
|
});
|
272
|
-
|
232
|
+
}, function (error) {
|
233
|
+
var _error$response, _error$response$data;
|
234
|
+
var message = undefined;
|
235
|
+
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;
|
236
|
+
if (type === AuthenticationMessage.NotAllowedToRegister) {
|
237
|
+
alert("가입 권한이 없는 계정입니다. 관리자에게 문의하세요.");
|
238
|
+
} else if (type) {
|
239
|
+
var _error$response2, _error$response2$data;
|
240
|
+
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;
|
241
|
+
} else {
|
242
|
+
var _error$response3;
|
243
|
+
message = (error === null || error === void 0 ? void 0 : (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || ERROR_MESSAGE;
|
244
|
+
}
|
245
|
+
message && alert(message);
|
246
|
+
handleSignOut();
|
273
247
|
});
|
248
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
274
249
|
}
|
275
|
-
}()
|
250
|
+
}();
|
251
|
+
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
|
276
252
|
} catch (e) {
|
277
253
|
return Promise.reject(e);
|
278
254
|
}
|
@@ -284,16 +260,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
284
260
|
return React.createElement(Formik, {
|
285
261
|
initialValues: defaultInfo,
|
286
262
|
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
|
-
}
|
263
|
+
onSubmit: function onSubmit() {}
|
297
264
|
}, function (formikProps) {
|
298
265
|
var handleSubmit = formikProps.handleSubmit;
|
299
266
|
return React.createElement(Row, {
|
@@ -308,10 +275,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
308
275
|
}, React.createElement("img", {
|
309
276
|
src: "/images/logo.jpeg",
|
310
277
|
className: "" + styles["img-login-rectangle"]
|
311
|
-
}), React.createElement(
|
312
|
-
action: "login",
|
313
|
-
onVerify: handleVerify
|
314
|
-
})), React.createElement(Col, {
|
278
|
+
}), React.createElement(Col, {
|
315
279
|
className: "p-0 mt-1 mb-4"
|
316
280
|
}, React.createElement(GoogleLogin, {
|
317
281
|
clientId: GOOGLE_CLIENT_ID,
|
@@ -390,19 +354,11 @@ var Login = function Login(_ref) {
|
|
390
354
|
md: 12,
|
391
355
|
xs: 12,
|
392
356
|
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
357
|
}, React.createElement(BlockLogin, {
|
402
358
|
defaultInfo: defaultInfo,
|
403
359
|
onNavigate: onNavigate,
|
404
360
|
isTeacher: isTeacher
|
405
|
-
}))))
|
361
|
+
}))));
|
406
362
|
};
|
407
363
|
|
408
364
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
@@ -747,8 +703,11 @@ var getInfo = function getInfo() {
|
|
747
703
|
|
748
704
|
var LayoutContext = function LayoutContext(_ref) {
|
749
705
|
var children = _ref.children,
|
750
|
-
role = _ref.role
|
751
|
-
|
706
|
+
role = _ref.role,
|
707
|
+
onNavigate = _ref.onNavigate;
|
708
|
+
var _useGoogleSignOut = useGoogleSignOut({
|
709
|
+
onNavigate: onNavigate
|
710
|
+
}),
|
752
711
|
handleSignOut = _useGoogleSignOut.handleSignOut;
|
753
712
|
var dispatch = useDispatch();
|
754
713
|
var user = useSelector(function (state) {
|
@@ -1003,10 +962,8 @@ var ExamEvent;
|
|
1003
962
|
(function (ExamEvent) {
|
1004
963
|
ExamEvent["StartExam"] = "start-exam";
|
1005
964
|
ExamEvent["TerminateExam"] = "terminate-exam";
|
1006
|
-
ExamEvent["JoinExam"] = "join-exam";
|
1007
965
|
ExamEvent["AddExtraDuration"] = "add-extra-duration-exam";
|
1008
|
-
ExamEvent["
|
1009
|
-
ExamEvent["StudentDisconnectChannel"] = "student-disconnect-channel";
|
966
|
+
ExamEvent["TeacherKickOutStudent"] = "teacher-kick-out-student";
|
1010
967
|
})(ExamEvent || (ExamEvent = {}));
|
1011
968
|
|
1012
969
|
var problem_solving = "문제풀기";
|
@@ -1065,6 +1022,7 @@ var internet_connection_was_lost = "인터넷 연결이 끊어졌습니다";
|
|
1065
1022
|
var problem = "문제";
|
1066
1023
|
var problem_solving_time = "문제풀이 시간";
|
1067
1024
|
var minutes = "분";
|
1025
|
+
var correct_rate = "정확한 비율";
|
1068
1026
|
var lang_ko = {
|
1069
1027
|
problem_solving: problem_solving,
|
1070
1028
|
my_story: my_story,
|
@@ -1121,7 +1079,8 @@ var lang_ko = {
|
|
1121
1079
|
internet_connection_was_lost: internet_connection_was_lost,
|
1122
1080
|
problem: problem,
|
1123
1081
|
problem_solving_time: problem_solving_time,
|
1124
|
-
minutes: minutes
|
1082
|
+
minutes: minutes,
|
1083
|
+
correct_rate: correct_rate
|
1125
1084
|
};
|
1126
1085
|
|
1127
1086
|
var problem_solving$1 = "Problem Solving";
|
@@ -1180,6 +1139,7 @@ var internet_connection_was_lost$1 = "Internet connection was lost";
|
|
1180
1139
|
var problem$1 = "Problem ";
|
1181
1140
|
var problem_solving_time$1 = "Problem solving time";
|
1182
1141
|
var minutes$1 = "m";
|
1142
|
+
var correct_rate$1 = "Correct rate";
|
1183
1143
|
var lang_en = {
|
1184
1144
|
problem_solving: problem_solving$1,
|
1185
1145
|
my_story: my_story$1,
|
@@ -1236,7 +1196,8 @@ var lang_en = {
|
|
1236
1196
|
internet_connection_was_lost: internet_connection_was_lost$1,
|
1237
1197
|
problem: problem$1,
|
1238
1198
|
problem_solving_time: problem_solving_time$1,
|
1239
|
-
minutes: minutes$1
|
1199
|
+
minutes: minutes$1,
|
1200
|
+
correct_rate: correct_rate$1
|
1240
1201
|
};
|
1241
1202
|
|
1242
1203
|
i18n.use(initReactI18next).init({
|
@@ -1381,7 +1342,44 @@ var canAccess = function canAccess(userRoles, componentRoles) {
|
|
1381
1342
|
return true;
|
1382
1343
|
};
|
1383
1344
|
|
1345
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
1346
|
+
if (source == null) return {};
|
1347
|
+
var target = {};
|
1348
|
+
var sourceKeys = Object.keys(source);
|
1349
|
+
var key, i;
|
1350
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
1351
|
+
key = sourceKeys[i];
|
1352
|
+
if (excluded.indexOf(key) >= 0) continue;
|
1353
|
+
target[key] = source[key];
|
1354
|
+
}
|
1355
|
+
return target;
|
1356
|
+
}
|
1357
|
+
|
1358
|
+
var _excluded = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
|
1359
|
+
var CustomSelect = function CustomSelect(_ref) {
|
1360
|
+
var options = _ref.options,
|
1361
|
+
isDisabled = _ref.isDisabled,
|
1362
|
+
scrollBottom = _ref.scrollBottom,
|
1363
|
+
value = _ref.value,
|
1364
|
+
isMulti = _ref.isMulti,
|
1365
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
1366
|
+
var initialValues = Array.isArray(value) ? options.filter(function (i) {
|
1367
|
+
return value.includes(i.value);
|
1368
|
+
}) : isMulti ? options.filter(function (i) {
|
1369
|
+
return i.value == value;
|
1370
|
+
}) : options.find(function (i) {
|
1371
|
+
return i.value == value;
|
1372
|
+
});
|
1373
|
+
return React.createElement(Select, Object.assign({
|
1374
|
+
isDisabled: isDisabled,
|
1375
|
+
options: options,
|
1376
|
+
value: initialValues,
|
1377
|
+
menuPlacement: scrollBottom ? "top" : "auto",
|
1378
|
+
isMulti: isMulti
|
1379
|
+
}, rest));
|
1380
|
+
};
|
1381
|
+
|
1384
1382
|
var historyCore = createBrowserHistory();
|
1385
1383
|
|
1386
|
-
export { ACCESS_TOKEN, BASE_URL, CommonAlert, CommonDialog, ConfirmDialog, CustomPagination, DATE_MIN_VALUE, EXAM_CHANNEL, ExamEvent, LayoutContext, Loading, Login, NotFound, PUSHER_CONFIG, TheLanguageDropdown, api$1 as api, canAccess as canAccessRoute, diffFromNow, formatTime, historyCore, i18n, minutesToTimeSpan, setAlert, setLanguage, setLoading, setUser, store, toISOString, useGoogleSignOut, utcToLocalTime };
|
1384
|
+
export { ACCESS_TOKEN, BASE_URL, CommonAlert, CommonDialog, ConfirmDialog, CustomPagination, CustomSelect, DATE_MIN_VALUE, EXAM_CHANNEL, EXAM_STUDENT_CHANNEL, ExamEvent, LayoutContext, Loading, Login, NotFound, PUSHER_CONFIG, TheLanguageDropdown, api$1 as api, canAccess as canAccessRoute, diffFromNow, formatTime, getAccessToken$1 as getAccessToken, historyCore, i18n, minutesToTimeSpan, setAlert, setLanguage, setLoading, setUser, store, toISOString, useGoogleSignOut, utcToLocalTime };
|
1387
1385
|
//# sourceMappingURL=index.modern.js.map
|