touchstudy-core 0.1.78 → 0.1.80

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.
@@ -6,6 +6,7 @@ declare type LoginInfo = {
6
6
  rememberMe: boolean;
7
7
  };
8
8
  declare const useLogin: (homeAcademyUrl: string, homeUrl: string) => {
9
+ clientId: string | undefined;
9
10
  defaultInfo: LoginInfo;
10
11
  openLogin: boolean;
11
12
  toggle: () => void;
@@ -7,6 +7,7 @@ interface Props {
7
7
  homeAcademyUrl: string;
8
8
  homeUrl: string;
9
9
  registerUrl?: string;
10
+ clientId: string;
10
11
  }
11
12
  declare const BlockLogin: FC<Props & INavigateProps>;
12
13
  export default BlockLogin;
package/dist/index.js CHANGED
@@ -724,7 +724,8 @@ var BlockLogin = function BlockLogin(_ref) {
724
724
  role = _ref$role === void 0 ? exports.Role.Student : _ref$role,
725
725
  homeAcademyUrl = _ref.homeAcademyUrl,
726
726
  homeUrl = _ref.homeUrl,
727
- registerUrl = _ref.registerUrl;
727
+ registerUrl = _ref.registerUrl,
728
+ clientId = _ref.clientId;
728
729
  var language = reactRedux.useSelector(function (state) {
729
730
  var _state$common;
730
731
  return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.language;
@@ -794,7 +795,7 @@ var BlockLogin = function BlockLogin(_ref) {
794
795
  })), React__default.createElement("div", {
795
796
  className: "p-0 mt-1 mb-4"
796
797
  }, React__default.createElement(GoogleLogin__default, {
797
- clientId: GOOGLE_CLIENT_ID,
798
+ clientId: clientId,
798
799
  buttonText: t("sign_in_with_your_google_account"),
799
800
  onSuccess: onSuccessGoogle,
800
801
  onFailure: onFailureGoogle,
@@ -819,23 +820,29 @@ var useLogin$1 = function useLogin(homeAcademyUrl, homeUrl) {
819
820
  var _useState2 = React.useState(),
820
821
  infoUser = _useState2[0],
821
822
  setInfoUser = _useState2[1];
823
+ var _useState3 = React.useState(),
824
+ clientId = _useState3[0],
825
+ setClientId = _useState3[1];
822
826
  var _useTranslation = reactI18next.useTranslation(),
823
827
  t = _useTranslation.t;
824
828
  var toggle = React.useCallback(function () {
825
829
  setOpenLogin(!openLogin);
826
830
  }, [openLogin]);
827
- var _useState3 = React.useState(false),
828
- isShowPassword = _useState3[0],
829
- setIsShowPassword = _useState3[1];
831
+ var _useState4 = React.useState(false),
832
+ isShowPassword = _useState4[0],
833
+ setIsShowPassword = _useState4[1];
834
+ React.useEffect(function () {
835
+ setClientId(GOOGLE_CLIENT_ID);
836
+ }, []);
830
837
  React.useEffect(function () {
831
838
  var start = function start() {
832
839
  gapiScript.gapi.client.init({
833
- clientId: GOOGLE_CLIENT_ID,
840
+ clientId: clientId,
834
841
  scope: "email"
835
842
  });
836
843
  };
837
- !!gapiScript.gapi && gapiScript.gapi.load("client:auth2", start);
838
- }, [gapiScript.gapi]);
844
+ gapiScript.gapi && clientId && gapiScript.gapi.load("client:auth2", start);
845
+ }, [gapiScript.gapi, clientId]);
839
846
  React.useEffect(function () {
840
847
  var token = getAccessToken();
841
848
  var academyDomain = getAcademyDomain();
@@ -846,6 +853,7 @@ var useLogin$1 = function useLogin(homeAcademyUrl, homeUrl) {
846
853
  document.title = t("study_peak") + " | " + t(PAGE_TITLE);
847
854
  }, [t]);
848
855
  return {
856
+ clientId: clientId,
849
857
  defaultInfo: defaultInfo,
850
858
  openLogin: openLogin,
851
859
  toggle: toggle,
@@ -955,7 +963,8 @@ var Login = function Login(_ref) {
955
963
  var history = _ref.history,
956
964
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
957
965
  var _useLogin = useLogin$1(rest.homeAcademyUrl, rest.homeUrl),
958
- defaultInfo = _useLogin.defaultInfo;
966
+ defaultInfo = _useLogin.defaultInfo,
967
+ clientId = _useLogin.clientId;
959
968
  useLanguage(history);
960
969
  return React__default.createElement("div", {
961
970
  className: styles["login"] + " font-family-lato"
@@ -967,9 +976,10 @@ var Login = function Login(_ref) {
967
976
  item: true,
968
977
  xs: 12,
969
978
  className: "d-flex justify-content-center h-100 align-items-center"
970
- }, React__default.createElement(BlockLogin, Object.assign({
979
+ }, clientId && React__default.createElement(BlockLogin, Object.assign({
971
980
  defaultInfo: defaultInfo,
972
- history: history
981
+ history: history,
982
+ clientId: clientId
973
983
  }, rest)))));
974
984
  };
975
985
 
@@ -16758,9 +16768,13 @@ var PrintExamView2 = function PrintExamView2(_ref) {
16758
16768
  var examSessionId = _ref2.examSessionId,
16759
16769
  studentId = _ref2.studentId,
16760
16770
  code = _ref2.code;
16771
+ var width = 200;
16772
+ var height = 200;
16773
+ var left = window.screenX + window.outerWidth / 2 - width / 2;
16774
+ var top = window.screenY + window.outerHeight / 2 - height / 2;
16761
16775
  var url = isTeacher ? window.location.origin + "/teacher/exam-results/" + examSessionId + "/students/" + studentId + "/print" : window.location.origin + "/student/exam-results/" + code + "/print";
16762
16776
  var windowName = isTeacher ? "popup-" + examSessionId + "-" + studentId : "popup-" + code;
16763
- var windowSpecs = "left=" + (window.innerWidth - 100) + ",top=" + (window.innerHeight - 100) + ",width=100,height=100,location=yes,resizable=yes,scrollbars=yes,status=yes";
16777
+ var windowSpecs = "left=" + left + ",top=" + top + ",width=" + width + ",height=" + height + ",location=yes,resizable=yes,scrollbars=yes,status=yes";
16764
16778
  var childWindow = window.open(url, windowName, windowSpecs);
16765
16779
  if (childWindow == null) {
16766
16780
  setErrorLinks(function (prev) {