touchstudy-core 0.1.1 → 0.1.3

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.
@@ -1,14 +1,18 @@
1
1
  import { createAction, createReducer, configureStore } from '@reduxjs/toolkit';
2
2
  import moment from 'moment';
3
- import React, { useCallback, useState, useEffect, Fragment, useRef } from 'react';
3
+ import React, { useCallback, useState, useEffect, Fragment, useRef, useMemo } from 'react';
4
4
  import { useGoogleReCaptcha, GoogleReCaptcha, GoogleReCaptchaProvider } from 'react-google-recaptcha-v3';
5
- import { Row, Col, Form, FormGroup, Modal, ModalHeader, ModalBody, ModalFooter, Button, Alert, Pagination, PaginationItem, PaginationLink } from 'reactstrap';
5
+ import { Row, Col, Form, FormGroup, Modal, ModalHeader, ModalBody, ModalFooter, Button, Alert, Pagination, PaginationItem, PaginationLink, Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
6
6
  import { Formik } from 'formik';
7
7
  import { object, string, boolean } from 'yup';
8
- import GoogleLogin from '@leecheuk/react-google-login';
8
+ import GoogleLogin, { useGoogleLogout } from '@leecheuk/react-google-login';
9
9
  import axios from 'axios';
10
10
  import { useDispatch, useSelector } from 'react-redux';
11
11
  import { gapi } from 'gapi-script';
12
+ import i18n from 'i18next';
13
+ import { initReactI18next, useTranslation } from 'react-i18next';
14
+ export { I18nextProvider, useTranslation } from 'react-i18next';
15
+ import { IoChevronDown } from 'react-icons/io5';
12
16
 
13
17
  function _extends() {
14
18
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -604,12 +608,18 @@ function createBrowserHistory(props) {
604
608
  var setLoading = createAction("common/setLoading");
605
609
  var setAlert = createAction("common/setAlert");
606
610
  var setUser = createAction("common/setUser");
611
+ var setLanguage = createAction("common/setLanguage");
607
612
 
608
613
  var GOOGLE_CLIENT_ID = "64118819726-0qlur4qjrs9jbuu6rnoa0u91g680lmpg.apps.googleusercontent.com";
609
614
  var GOOGLE_RECAPTCHA_ID = "6LfNtLUaAAAAAL24lbBV11jS-gBtt1mhtxb4NXs0";
610
615
  var ACCESS_TOKEN = "ACCESS_TOKEN";
611
616
  var DATE_MIN_VALUE = "0001-01-01T00:00:00+00:00";
612
- var BASE_URL = "https://ec0e-123-24-205-68.ngrok-free.app";
617
+ var BASE_URL = "http://api.touchstudy.kr";
618
+ var PUSHER_CONFIG = {
619
+ cluster: "ap1",
620
+ key: "9018c77328885a14150b"
621
+ };
622
+ var EXAM_CHANNEL = "EXAM-CHANNEL";
613
623
  var getAccessToken = function getAccessToken() {
614
624
  try {
615
625
  return localStorage.getItem(ACCESS_TOKEN);
@@ -658,7 +668,7 @@ function _catch(body, recover) {
658
668
  return result;
659
669
  }
660
670
 
661
- var styles = {"btn-login-google":"_2HqmH","block-login":"_wWIyO","box-login":"_38Lo1"};
671
+ var styles = {"btn-login-google":"_2HqmH","block-login":"_wWIyO","box-login":"_38Lo1","dropdown-menu":"_1krbH","header-avatar":"_RQaHE","dropdown-menu-flag":"_XK8oS","dropdown-content":"_3ys4W","dropdown-change":"_ToOW_","item-address":"_3sQlR","item-logout":"_3bqSM","title-address":"_1jgSI","img-avatar":"_35Ttz","item-contact":"_1wc7o","content-text":"_3S4f2","dropdown-content-language":"_3ajui","dropdown-item-language":"_3Y_y4","dropdown-item-language-active":"_CzNMi"};
662
672
 
663
673
  var api = axios.create({
664
674
  baseURL: BASE_URL,
@@ -693,13 +703,14 @@ var apiUpload = axios.create({
693
703
  return i.interceptors.response.use(function (response) {
694
704
  return response;
695
705
  }, function (error) {
706
+ var _error$response, _error$response2;
696
707
  console.log({
697
708
  error: error
698
709
  });
699
- if (error.response.status === 401) {
710
+ if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 401) {
700
711
  window.location.href = "/login";
701
712
  }
702
- if (error.response.status == 403) {
713
+ if (((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) == 403) {
703
714
  localStorage.removeItem(ACCESS_TOKEN);
704
715
  localStorage.removeItem("USER_EMAIL");
705
716
  window.location.href = "/login";
@@ -708,8 +719,30 @@ var apiUpload = axios.create({
708
719
  });
709
720
  });
710
721
 
711
- var apiLoginGoogle = function apiLoginGoogle(body) {
712
- return api.post(BASE_URL + "/api/auth/login", body);
722
+ var apiLoginGoogle = function apiLoginGoogle(body, role) {
723
+ return api.post(BASE_URL + "/api/auth/" + role + "/login", body);
724
+ };
725
+
726
+ var AuthenticationMessage;
727
+ (function (AuthenticationMessage) {
728
+ AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
729
+ AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
730
+ })(AuthenticationMessage || (AuthenticationMessage = {}));
731
+
732
+ var useGoogleSignOut = function useGoogleSignOut(props) {
733
+ var onLogoutSuccess = props.onLogoutSuccess,
734
+ onFailure = props.onFailure;
735
+ var _useGoogleLogout = useGoogleLogout({
736
+ clientId: GOOGLE_CLIENT_ID,
737
+ onLogoutSuccess: onLogoutSuccess,
738
+ onFailure: onFailure
739
+ }),
740
+ signOut = _useGoogleLogout.signOut,
741
+ loaded = _useGoogleLogout.loaded;
742
+ return {
743
+ signOut: signOut,
744
+ loaded: loaded
745
+ };
713
746
  };
714
747
 
715
748
  var ERROR_MESSAGE = "Login fail!";
@@ -725,6 +758,8 @@ var BlockLogin = function BlockLogin(_ref) {
725
758
  var dispatch = useDispatch();
726
759
  var _useGoogleReCaptcha = useGoogleReCaptcha(),
727
760
  executeRecaptcha = _useGoogleReCaptcha.executeRecaptcha;
761
+ var _useGoogleSignOut = useGoogleSignOut({}),
762
+ signOut = _useGoogleSignOut.signOut;
728
763
  var clickHandler = useCallback(function () {
729
764
  try {
730
765
  if (!executeRecaptcha) {
@@ -740,10 +775,6 @@ var BlockLogin = function BlockLogin(_ref) {
740
775
  var onSuccessGoogle = function onSuccessGoogle(res) {
741
776
  try {
742
777
  var _exit = false;
743
- console.log("success");
744
- console.log({
745
- res: res
746
- });
747
778
  return Promise.resolve(function () {
748
779
  if (!!(res !== null && res !== void 0 && res.accessToken)) {
749
780
  var _temp2 = function _temp2(_result) {
@@ -761,21 +792,15 @@ var BlockLogin = function BlockLogin(_ref) {
761
792
  fullName: name,
762
793
  email: email,
763
794
  token: accessToken,
764
- googleId: googleId,
765
- role: isTeacher ? "Teacher" : "Student"
795
+ googleId: googleId
766
796
  };
767
- console.log({
768
- infoLogin: infoLogin
769
- });
797
+ var role = isTeacher ? "Teacher" : "Student";
770
798
  dispatch(setLoading(true));
771
799
  var _temp = _catch(function () {
772
- return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (res1) {
800
+ return Promise.resolve(apiLoginGoogle(infoLogin, role)).then(function (res1) {
773
801
  var isFirstLogin = res1.data.isFirstLogin;
774
802
  var tokenJWT = res1.data.token;
775
803
  localStorage.setItem("USER_INFORMATION", JSON.stringify(infoLogin));
776
- console.log({
777
- res1: res1
778
- });
779
804
  localStorage.setItem(ACCESS_TOKEN, tokenJWT);
780
805
  if (isTeacher) {
781
806
  onNavigate("/teacher/overall-status/main");
@@ -789,10 +814,22 @@ var BlockLogin = function BlockLogin(_ref) {
789
814
  }
790
815
  });
791
816
  }, function (error) {
792
- var _error$response;
793
- dispatch(setAlert({
817
+ var _error$response, _error$response$data;
818
+ var message = undefined;
819
+ 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;
820
+ if (type === AuthenticationMessage.NotAllowedToRegister) {
821
+ alert("가입 권한이 없는 계정입니다. 관리자에게 문의하세요.");
822
+ } else if (type) {
823
+ var _error$response2, _error$response2$data;
824
+ 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;
825
+ } else {
826
+ var _error$response3;
827
+ message = (error === null || error === void 0 ? void 0 : (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || ERROR_MESSAGE;
828
+ }
829
+ signOut();
830
+ !!message && dispatch(setAlert({
794
831
  type: "danger",
795
- message: ((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || ERROR_MESSAGE
832
+ message: message
796
833
  }));
797
834
  });
798
835
  return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
@@ -848,7 +885,8 @@ var BlockLogin = function BlockLogin(_ref) {
848
885
  onSuccess: onSuccessGoogle,
849
886
  onFailure: onFailureGoogle,
850
887
  cookiePolicy: "single_host_origin",
851
- className: "" + styles["btn-login-google"]
888
+ className: "" + styles["btn-login-google"],
889
+ isSignedIn: true
852
890
  }))))));
853
891
  });
854
892
  };
@@ -1132,6 +1170,8 @@ var commonReducer = createReducer(initialState, function (builder) {
1132
1170
  state.alert = action.payload;
1133
1171
  }).addCase(setUser, function (state, action) {
1134
1172
  state.user = action.payload;
1173
+ }).addCase(setLanguage, function (state, action) {
1174
+ state.language = action.payload;
1135
1175
  });
1136
1176
  });
1137
1177
 
@@ -1268,9 +1308,12 @@ var getInfo = function getInfo() {
1268
1308
  var LayoutContext = function LayoutContext(_ref) {
1269
1309
  var children = _ref.children,
1270
1310
  onNavigate = _ref.onNavigate;
1311
+ var _useGoogleSignOut = useGoogleSignOut({}),
1312
+ signOut = _useGoogleSignOut.signOut;
1271
1313
  var dispatch = useDispatch();
1272
1314
  var resetAuth = function resetAuth() {
1273
1315
  localStorage.removeItem(ACCESS_TOKEN);
1316
+ signOut();
1274
1317
  onNavigate("/login");
1275
1318
  };
1276
1319
  var loadInfo = function loadInfo() {
@@ -1313,6 +1356,8 @@ var ConfirmDialog = function ConfirmDialog(_ref) {
1313
1356
  _ref$okText = _ref.okText,
1314
1357
  okText = _ref$okText === void 0 ? "Yes" : _ref$okText,
1315
1358
  isDelete = _ref.isDelete,
1359
+ _ref$title = _ref.title,
1360
+ title = _ref$title === void 0 ? "Confirmation" : _ref$title,
1316
1361
  toggle = _ref.toggle,
1317
1362
  onConfirm = _ref.onConfirm;
1318
1363
  return React.createElement(Modal, {
@@ -1321,7 +1366,7 @@ var ConfirmDialog = function ConfirmDialog(_ref) {
1321
1366
  centered: true
1322
1367
  }, React.createElement(ModalHeader, {
1323
1368
  toggle: toggle
1324
- }, "Confirmation"), React.createElement(ModalBody, null, text), React.createElement(ModalFooter, null, React.createElement(Button, {
1369
+ }, title), React.createElement(ModalBody, null, text), React.createElement(ModalFooter, null, React.createElement(Button, {
1325
1370
  color: "secondary",
1326
1371
  onClick: toggle
1327
1372
  }, cancelText), React.createElement(Button, {
@@ -1337,8 +1382,10 @@ var CommonDialog = function CommonDialog(_ref) {
1337
1382
  title = _ref.title,
1338
1383
  _ref$size = _ref.size,
1339
1384
  size = _ref$size === void 0 ? "xs" : _ref$size,
1340
- onClose = _ref.onClose;
1385
+ onClose = _ref.onClose,
1386
+ backdrop = _ref.backdrop;
1341
1387
  return React.createElement(Modal, {
1388
+ backdrop: backdrop,
1342
1389
  isOpen: open,
1343
1390
  toggle: onClose,
1344
1391
  centered: centered,
@@ -1390,10 +1437,11 @@ var formatTime = (function (time, ORIGINAL_FORMAT, FORMAT) {
1390
1437
  }
1391
1438
  });
1392
1439
 
1393
- var diffFromNow = (function (time, unitOfTime) {
1394
- if (time === DATE_MIN_VALUE) return 0;
1440
+ var diffFromNow = (function (time, unitOfTime, targetTime) {
1441
+ if (time === DATE_MIN_VALUE || targetTime === DATE_MIN_VALUE) return 0;
1395
1442
  try {
1396
- return moment().diff(moment.utc(time).local(), unitOfTime);
1443
+ var now = !!targetTime ? moment() : moment.utc(targetTime).local();
1444
+ return now.diff(moment.utc(time).local(), unitOfTime);
1397
1445
  } catch (_unused) {
1398
1446
  return "";
1399
1447
  }
@@ -1493,7 +1541,368 @@ var CustomPagination = function CustomPagination(_ref) {
1493
1541
  })));
1494
1542
  };
1495
1543
 
1544
+ var ExamEvent;
1545
+ (function (ExamEvent) {
1546
+ ExamEvent["StartExam"] = "start-exam";
1547
+ ExamEvent["TerminateExam"] = "terminate-exam";
1548
+ ExamEvent["JoinExam"] = "join-exam";
1549
+ ExamEvent["AddExtraDuration"] = "add-extra-duration-exam";
1550
+ ExamEvent["TeacherDisconnectChannel"] = "teacher-disconnect-channel";
1551
+ ExamEvent["StudentDisconnectChannel"] = "student-disconnect-channel";
1552
+ })(ExamEvent || (ExamEvent = {}));
1553
+
1554
+ var problem_solving = "문제풀기";
1555
+ var my_story = "내 스토리";
1556
+ var search_find = "검색하여 찾기";
1557
+ var test_code = "시험코드 입력";
1558
+ var login_success = "로그인 성공";
1559
+ var welcome_success = "스터디 터치에 오신 것을 환영합니다!";
1560
+ var description_success = "스터디 터치는 엄태욱 선생님의 수업에서 활용되는 학습 도구입니다.";
1561
+ var logout = "로그 아웃";
1562
+ var overall_status = "전체 현황";
1563
+ var exam_status = "시험별 현";
1564
+ var user_manager = "사용자 목록";
1565
+ var recent_exam_results = "최근 시험 결과";
1566
+ var instructor_name = "강사이름";
1567
+ var academy_name = "학원 이름";
1568
+ var total_students = "총 학생수";
1569
+ var student = "명";
1570
+ var students = "명";
1571
+ var extra_time = "추가 시간";
1572
+ var complete = "완료";
1573
+ var current_exam = "현재 시험중";
1574
+ var exam_time = "시험 시간";
1575
+ var time_remaining = "남은 시간";
1576
+ var number_results = "결과 {{number}}건";
1577
+ var number_result = "결과 {{number}}건";
1578
+ var mins_mins_seconds_seconds = "{{mins}}분 {{seconds}}초";
1579
+ var mins_mins = "{{mins}}분";
1580
+ var class_name = "반 이름";
1581
+ var create_new_exam = "새 시험 생성";
1582
+ var there_are_no_recent_exams = "최근 시험이 없습니다";
1583
+ var you_have_created_a_exam_with_code_code_do_you_want_to_continue = "코드가 {{code}}인 시험을 생성했습니다. 계속하시겠습니까?";
1584
+ var here = "여기";
1585
+ var do_you_want_to_complete_the_exam = "시험을 완료처리 하시겠습니까?";
1586
+ var are_you_sure_you_want_to_delete_the_exam = "시험을 삭제하시겠습니까?";
1587
+ var yes = "예";
1588
+ var no = "아니요";
1589
+ var cancel = "취소";
1590
+ var confirmation = "확인";
1591
+ var student_name = "학생이름";
1592
+ var full_pool_time = "전체풀이시간";
1593
+ var number_question = "{{number}}번";
1594
+ var answer_rate = "정답률";
1595
+ var seconds = "초";
1596
+ var search_placeholder = "시험 이름으로 검색하기";
1597
+ var study_touch = "영어연구소";
1598
+ var exam_information = "시험정보";
1599
+ var issue_number = "문제번호";
1600
+ var incorrect_rate = "오답률";
1601
+ var question_time_for_each_student = "학생별 문항 시간";
1602
+ var correct_answer_for_each_student = "학생별 정답 여부";
1603
+ var information_by_question = "문항별 정보";
1604
+ var no_data = "데이터 없음";
1605
+ var internet_connection_was_lost = "인터넷 연결이 끊어졌습니다";
1606
+ var problem = "문제";
1607
+ var problem_solving_time = "문제풀이 시간";
1608
+ var lang_ko = {
1609
+ problem_solving: problem_solving,
1610
+ my_story: my_story,
1611
+ search_find: search_find,
1612
+ test_code: test_code,
1613
+ login_success: login_success,
1614
+ welcome_success: welcome_success,
1615
+ description_success: description_success,
1616
+ logout: logout,
1617
+ overall_status: overall_status,
1618
+ exam_status: exam_status,
1619
+ user_manager: user_manager,
1620
+ recent_exam_results: recent_exam_results,
1621
+ instructor_name: instructor_name,
1622
+ academy_name: academy_name,
1623
+ total_students: total_students,
1624
+ student: student,
1625
+ students: students,
1626
+ extra_time: extra_time,
1627
+ complete: complete,
1628
+ current_exam: current_exam,
1629
+ exam_time: exam_time,
1630
+ time_remaining: time_remaining,
1631
+ number_results: number_results,
1632
+ number_result: number_result,
1633
+ mins_mins_seconds_seconds: mins_mins_seconds_seconds,
1634
+ mins_mins: mins_mins,
1635
+ class_name: class_name,
1636
+ create_new_exam: create_new_exam,
1637
+ there_are_no_recent_exams: there_are_no_recent_exams,
1638
+ you_have_created_a_exam_with_code_code_do_you_want_to_continue: you_have_created_a_exam_with_code_code_do_you_want_to_continue,
1639
+ here: here,
1640
+ do_you_want_to_complete_the_exam: do_you_want_to_complete_the_exam,
1641
+ are_you_sure_you_want_to_delete_the_exam: are_you_sure_you_want_to_delete_the_exam,
1642
+ yes: yes,
1643
+ no: no,
1644
+ cancel: cancel,
1645
+ confirmation: confirmation,
1646
+ student_name: student_name,
1647
+ full_pool_time: full_pool_time,
1648
+ number_question: number_question,
1649
+ answer_rate: answer_rate,
1650
+ seconds: seconds,
1651
+ search_placeholder: search_placeholder,
1652
+ study_touch: study_touch,
1653
+ exam_information: exam_information,
1654
+ issue_number: issue_number,
1655
+ incorrect_rate: incorrect_rate,
1656
+ question_time_for_each_student: question_time_for_each_student,
1657
+ correct_answer_for_each_student: correct_answer_for_each_student,
1658
+ information_by_question: information_by_question,
1659
+ no_data: no_data,
1660
+ internet_connection_was_lost: internet_connection_was_lost,
1661
+ problem: problem,
1662
+ problem_solving_time: problem_solving_time
1663
+ };
1664
+
1665
+ var problem_solving$1 = "Problem Solving";
1666
+ var my_story$1 = "My Story";
1667
+ var search_find$1 = "Search and find";
1668
+ var test_code$1 = "Enter test code";
1669
+ var login_success$1 = "Login Success";
1670
+ var welcome_success$1 = "Welcome to Study Touch!";
1671
+ var description_success$1 = "Study Touch is a learning tool used in teacher Taewook Eom's classes.";
1672
+ var logout$1 = "Logout";
1673
+ var overall_status$1 = "Overall Status";
1674
+ var exam_status$1 = "Exam Status";
1675
+ var user_manager$1 = "User Manager";
1676
+ var recent_exam_results$1 = "Recent exam";
1677
+ var instructor_name$1 = "Instructor name";
1678
+ var academy_name$1 = "Academy name";
1679
+ var total_students$1 = "Total students";
1680
+ var students$1 = "Students";
1681
+ var student$1 = "Student";
1682
+ var extra_time$1 = "Extra time";
1683
+ var complete$1 = "Complete";
1684
+ var current_exam$1 = "Current exam";
1685
+ var exam_time$1 = "Extra time";
1686
+ var time_remaining$1 = "Time remaining";
1687
+ var number_results$1 = "{{number}} Results";
1688
+ var number_result$1 = "{{number}} Result";
1689
+ var mins_mins_seconds_seconds$1 = "{{mins}}m {{seconds}}s";
1690
+ var mins_mins$1 = "{{mins}}m";
1691
+ var class_name$1 = "Class name";
1692
+ var create_new_exam$1 = "Create exam";
1693
+ var there_are_no_recent_exams$1 = "There are no recent exams";
1694
+ var you_have_created_a_exam_with_code_code_do_you_want_to_continue$1 = "You have created a exam with code {{code}}, do you want to continue?";
1695
+ var here$1 = "here";
1696
+ var do_you_want_to_complete_the_exam$1 = "Do you want to complete the exam?";
1697
+ var are_you_sure_you_want_to_delete_the_exam$1 = "Are you sure you want to delete the exam?";
1698
+ var yes$1 = "Yes";
1699
+ var no$1 = "No";
1700
+ var cancel$1 = "Cancel";
1701
+ var confirmation$1 = "Confirmation";
1702
+ var student_name$1 = "Student name";
1703
+ var full_pool_time$1 = "Full pool time";
1704
+ var number_question$1 = "No.{{number}}";
1705
+ var answer_rate$1 = "Answer rate";
1706
+ var seconds$1 = "s";
1707
+ var search_placeholder$1 = "Search by exam name";
1708
+ var study_touch$1 = "Study touch";
1709
+ var exam_information$1 = "Exam information";
1710
+ var issue_number$1 = "Issue number";
1711
+ var incorrect_rate$1 = "Incorrect rate";
1712
+ var question_time_for_each_student$1 = "Question time for each student";
1713
+ var correct_answer_for_each_student$1 = "Correct answer for each student";
1714
+ var information_by_question$1 = "Information by question";
1715
+ var no_data$1 = "No data";
1716
+ var internet_connection_was_lost$1 = "Internet connection was lost";
1717
+ var problem$1 = "Problem ";
1718
+ var problem_solving_time$1 = "Problem solving time";
1719
+ var lang_en = {
1720
+ problem_solving: problem_solving$1,
1721
+ my_story: my_story$1,
1722
+ search_find: search_find$1,
1723
+ test_code: test_code$1,
1724
+ login_success: login_success$1,
1725
+ welcome_success: welcome_success$1,
1726
+ description_success: description_success$1,
1727
+ logout: logout$1,
1728
+ overall_status: overall_status$1,
1729
+ exam_status: exam_status$1,
1730
+ user_manager: user_manager$1,
1731
+ recent_exam_results: recent_exam_results$1,
1732
+ instructor_name: instructor_name$1,
1733
+ academy_name: academy_name$1,
1734
+ total_students: total_students$1,
1735
+ students: students$1,
1736
+ student: student$1,
1737
+ extra_time: extra_time$1,
1738
+ complete: complete$1,
1739
+ current_exam: current_exam$1,
1740
+ exam_time: exam_time$1,
1741
+ time_remaining: time_remaining$1,
1742
+ number_results: number_results$1,
1743
+ number_result: number_result$1,
1744
+ mins_mins_seconds_seconds: mins_mins_seconds_seconds$1,
1745
+ mins_mins: mins_mins$1,
1746
+ class_name: class_name$1,
1747
+ create_new_exam: create_new_exam$1,
1748
+ there_are_no_recent_exams: there_are_no_recent_exams$1,
1749
+ you_have_created_a_exam_with_code_code_do_you_want_to_continue: you_have_created_a_exam_with_code_code_do_you_want_to_continue$1,
1750
+ here: here$1,
1751
+ do_you_want_to_complete_the_exam: do_you_want_to_complete_the_exam$1,
1752
+ are_you_sure_you_want_to_delete_the_exam: are_you_sure_you_want_to_delete_the_exam$1,
1753
+ yes: yes$1,
1754
+ no: no$1,
1755
+ cancel: cancel$1,
1756
+ confirmation: confirmation$1,
1757
+ student_name: student_name$1,
1758
+ full_pool_time: full_pool_time$1,
1759
+ number_question: number_question$1,
1760
+ answer_rate: answer_rate$1,
1761
+ seconds: seconds$1,
1762
+ search_placeholder: search_placeholder$1,
1763
+ study_touch: study_touch$1,
1764
+ exam_information: exam_information$1,
1765
+ issue_number: issue_number$1,
1766
+ incorrect_rate: incorrect_rate$1,
1767
+ question_time_for_each_student: question_time_for_each_student$1,
1768
+ correct_answer_for_each_student: correct_answer_for_each_student$1,
1769
+ information_by_question: information_by_question$1,
1770
+ no_data: no_data$1,
1771
+ internet_connection_was_lost: internet_connection_was_lost$1,
1772
+ problem: problem$1,
1773
+ problem_solving_time: problem_solving_time$1
1774
+ };
1775
+
1776
+ i18n.use(initReactI18next).init({
1777
+ lng: "ko",
1778
+ fallbackLng: "ko",
1779
+ interpolation: {
1780
+ escapeValue: false
1781
+ },
1782
+ resources: {
1783
+ ko: {
1784
+ translation: lang_ko
1785
+ },
1786
+ en: {
1787
+ translation: lang_en
1788
+ }
1789
+ }
1790
+ });
1791
+
1792
+ var DEFAULT_LANGUAGE_CODE = "ko";
1793
+ var LANGUAGES = [{
1794
+ code: "ko",
1795
+ fullName: "Korean",
1796
+ shortName: "Korean",
1797
+ nativeName: "Korean",
1798
+ name: "Korean",
1799
+ image: "/images/korea.png"
1800
+ }, {
1801
+ code: "en",
1802
+ fullName: "English",
1803
+ shortName: "English",
1804
+ nativeName: "English",
1805
+ name: "English",
1806
+ image: "/images/usa.png"
1807
+ }];
1808
+ var SUPPORTED_LANGUAGES_CODE = LANGUAGES.map(function (i) {
1809
+ return i.code;
1810
+ });
1811
+
1812
+ var TheLanguageDropdown = function TheLanguageDropdown() {
1813
+ var defaultLanguage = !!localStorage.getItem("language") ? localStorage.getItem("language") : navigator.language || DEFAULT_LANGUAGE_CODE;
1814
+ var dispatch = useDispatch();
1815
+ var _useTranslation = useTranslation(),
1816
+ i18n = _useTranslation.i18n;
1817
+ var _useState = useState(false),
1818
+ dropdownOpen = _useState[0],
1819
+ setDropdownOpen = _useState[1];
1820
+ var _useState2 = useState(defaultLanguage),
1821
+ language = _useState2[0],
1822
+ setItemLanguage = _useState2[1];
1823
+ var toggle = function toggle() {
1824
+ return setDropdownOpen(function (prevState) {
1825
+ return !prevState;
1826
+ });
1827
+ };
1828
+ var changeLanguageApp = function changeLanguageApp(lang) {
1829
+ if (!SUPPORTED_LANGUAGES_CODE.includes(lang)) lang = DEFAULT_LANGUAGE_CODE;
1830
+ i18n.changeLanguage(lang);
1831
+ localStorage.setItem("language", lang);
1832
+ setItemLanguage(lang);
1833
+ dispatch(setLanguage(lang));
1834
+ };
1835
+ var currentLanguage = useMemo(function () {
1836
+ var currentLang = LANGUAGES.find(function (i) {
1837
+ return i.code === language;
1838
+ });
1839
+ if (!currentLang) return null;
1840
+ return React.createElement(React.Fragment, null, React.createElement("img", {
1841
+ className: "mr-2 " + styles['dropdown-menu-flag'],
1842
+ src: currentLang.image
1843
+ }), " ", currentLang.shortName);
1844
+ }, [language]);
1845
+ useEffect(function () {
1846
+ changeLanguageApp(language);
1847
+ }, [language]);
1848
+ return React.createElement(Dropdown, {
1849
+ isOpen: dropdownOpen,
1850
+ toggle: toggle,
1851
+ className: "" + styles["dropdown-menu"]
1852
+ }, React.createElement(DropdownToggle, {
1853
+ className: styles["header-avatar"] + " d-flex align-items-center"
1854
+ }, React.createElement("span", {
1855
+ style: {
1856
+ color: "#000",
1857
+ textTransform: "capitalize",
1858
+ display: 'flex',
1859
+ alignItems: 'center'
1860
+ }
1861
+ }, currentLanguage, React.createElement(IoChevronDown, {
1862
+ className: "ml-2",
1863
+ style: {
1864
+ fontSize: '15px',
1865
+ marginLeft: "5px",
1866
+ marginTop: "2px"
1867
+ }
1868
+ }))), React.createElement(DropdownMenu, {
1869
+ className: styles["dropdown-content-language"]
1870
+ }, LANGUAGES.map(function (lang, index) {
1871
+ return React.createElement(DropdownItem, {
1872
+ key: lang.code,
1873
+ className: styles["dropdown-change"] + " px-0 py-0 " + (index === LANGUAGES.length - 1 ? "pb-2" : "pt-2"),
1874
+ onClick: function onClick() {
1875
+ return setItemLanguage(lang.code);
1876
+ }
1877
+ }, React.createElement("div", {
1878
+ className: styles["dropdown-item-language"] + " " + styles["item-logout"] + " " + (language == lang.code ? styles['dropdown-item-language-active'] : "") + " d-flex align-items-center w-100"
1879
+ }, React.createElement("span", {
1880
+ className: "mr-2 d-flex hover-opacity"
1881
+ }, React.createElement("img", {
1882
+ style: {
1883
+ width: "30px",
1884
+ marginRight: "10px"
1885
+ },
1886
+ src: lang.image
1887
+ })), lang.name));
1888
+ })));
1889
+ };
1890
+
1891
+ var minutesToTimeSpan = (function (time) {
1892
+ var h = Math.floor(time / 60);
1893
+ var m = time % 60;
1894
+ return h.toString().padStart(2, "0") + ":" + m.toString().padStart(2, "0") + ":00";
1895
+ });
1896
+
1897
+ var toISOString = (function (time) {
1898
+ try {
1899
+ return moment(time).toISOString();
1900
+ } catch (_unused) {
1901
+ return "";
1902
+ }
1903
+ });
1904
+
1496
1905
  var historyCore = createBrowserHistory();
1497
1906
 
1498
- export { ACCESS_TOKEN, BASE_URL, CommonAlert, CommonDialog, ConfirmDialog, CustomPagination, LayoutContext, Loading, Login, NotFound, api$1 as api, diffFromNow, formatTime, historyCore, setAlert, setLoading, setUser, store, utcToLocalTime };
1907
+ 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, diffFromNow, formatTime, historyCore, i18n, minutesToTimeSpan, setAlert, setLanguage, setLoading, setUser, store, toISOString, useGoogleSignOut, utcToLocalTime };
1499
1908
  //# sourceMappingURL=index.modern.js.map