acsi-core 0.1.25 → 0.1.26

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/README.md CHANGED
@@ -1,46 +1,46 @@
1
- # Getting Started with Create React App
2
-
3
- This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
-
5
- ## Available Scripts
6
-
7
- In the project directory, you can run:
8
-
9
- ### `npm start`
10
-
11
- Runs the app in the development mode.\
12
- Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13
-
14
- The page will reload if you make edits.\
15
- You will also see any lint errors in the console.
16
-
17
- ### `npm test`
18
-
19
- Launches the test runner in the interactive watch mode.\
20
- See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
-
22
- ### `npm run build`
23
-
24
- Builds the app for production to the `build` folder.\
25
- It correctly bundles React in production mode and optimizes the build for the best performance.
26
-
27
- The build is minified and the filenames include the hashes.\
28
- Your app is ready to be deployed!
29
-
30
- See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
-
32
- ### `npm run eject`
33
-
34
- **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35
-
36
- If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37
-
38
- Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39
-
40
- You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41
-
42
- ## Learn More
43
-
44
- You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
-
46
- To learn React, check out the [React documentation](https://reactjs.org/).
1
+ # Getting Started with Create React App
2
+
3
+ This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
+
5
+ ## Available Scripts
6
+
7
+ In the project directory, you can run:
8
+
9
+ ### `npm start`
10
+
11
+ Runs the app in the development mode.\
12
+ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13
+
14
+ The page will reload if you make edits.\
15
+ You will also see any lint errors in the console.
16
+
17
+ ### `npm test`
18
+
19
+ Launches the test runner in the interactive watch mode.\
20
+ See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
+
22
+ ### `npm run build`
23
+
24
+ Builds the app for production to the `build` folder.\
25
+ It correctly bundles React in production mode and optimizes the build for the best performance.
26
+
27
+ The build is minified and the filenames include the hashes.\
28
+ Your app is ready to be deployed!
29
+
30
+ See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
+
32
+ ### `npm run eject`
33
+
34
+ **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35
+
36
+ If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37
+
38
+ Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39
+
40
+ You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41
+
42
+ ## Learn More
43
+
44
+ You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
+
46
+ To learn React, check out the [React documentation](https://reactjs.org/).
package/dist/index.d.ts CHANGED
@@ -15,8 +15,9 @@ import CustomPagination from "./components/Paginations/CustomPagination";
15
15
  import useGoogleSignOut from "./utils/hooks/useGoogleSignOut";
16
16
  import { CoreButton, CoreInput, CoreSelect, CoreCheckbox, CoreRadio, CoreError, CoreModal, CoreRange, CoreTextArea, CoreSearch, CoreSelectCompact, CoreInputCompact, CoreTitleInput } from "./components";
17
17
  import { getErrorMessage } from "./utils/getErrorMessage";
18
+ import { GoogleOAuthProvider } from '@react-oauth/google';
18
19
  import CustomSelect from "./components/Selects/CustomSelect";
19
20
  import CustomAsyncSelect from "./components/Selects/CustomAsyncSelect";
20
21
  import CustomCreatable from "./components/Selects/CustomCreatable";
21
22
  import CustomSelectOption from "./components/Selects/CustomSelectOption";
22
- export { setLoading, BASE_URL, OPENSALT_BASE_URL, ACCESS_TOKEN, DATE_TIME_MIN_VALUE, Login, store, historyCore, setAlert, setUser, setMenuCollapse, setIsRefetchSidebar, Loading, NotFound, LayoutContext, api, apiUpload, ConfirmDialog, CommonDialog, ToastContainer, toast, Role, CustomPagination, useGoogleSignOut, CoreButton, CoreInput, CoreSelect, CoreCheckbox, CoreRadio, CoreError, CoreModal, CoreRange, CoreTextArea, CoreSearch, CoreSelectCompact, CoreInputCompact, CoreTitleInput, getErrorMessage, CustomSelect, CustomAsyncSelect, CustomCreatable, CustomSelectOption };
23
+ export { setLoading, BASE_URL, OPENSALT_BASE_URL, ACCESS_TOKEN, DATE_TIME_MIN_VALUE, Login, store, historyCore, setAlert, setUser, setMenuCollapse, setIsRefetchSidebar, Loading, NotFound, LayoutContext, api, apiUpload, ConfirmDialog, CommonDialog, ToastContainer, toast, Role, CustomPagination, useGoogleSignOut, CoreButton, CoreInput, CoreSelect, CoreCheckbox, CoreRadio, CoreError, CoreModal, CoreRange, CoreTextArea, CoreSearch, CoreSelectCompact, CoreInputCompact, CoreTitleInput, getErrorMessage, CustomSelect, CustomAsyncSelect, CustomCreatable, CustomSelectOption, GoogleOAuthProvider };
package/dist/index.js CHANGED
@@ -5,13 +5,12 @@ var toolkit = require('@reduxjs/toolkit');
5
5
  var React = require('react');
6
6
  var React__default = _interopDefault(React);
7
7
  var reactstrap = require('reactstrap');
8
- var GoogleLogin = require('@leecheuk/react-google-login');
9
- var GoogleLogin__default = _interopDefault(GoogleLogin);
10
8
  var axios = _interopDefault(require('axios'));
11
9
  var moment = _interopDefault(require('moment'));
12
10
  var reactRouterDom = require('react-router-dom');
13
11
  var reactRedux = require('react-redux');
14
- var gapiScript = require('gapi-script');
12
+ var google = require('@react-oauth/google');
13
+ var reactGoogleLogin = require('@leecheuk/react-google-login');
15
14
  var material = require('@mui/material');
16
15
  var reactToastify = require('react-toastify');
17
16
  var ReactSelect = require('react-select');
@@ -141,50 +140,58 @@ var BlockLogin = function BlockLogin(_ref) {
141
140
  var onNavigate = _ref.onNavigate,
142
141
  role = _ref.role;
143
142
  var dispatch = reactRedux.useDispatch();
144
- var onSuccessGoogle = function onSuccessGoogle(res) {
145
- try {
146
- return Promise.resolve(function () {
147
- if (!!(res !== null && res !== void 0 && res.accessToken)) {
148
- var _res$profileObj = res.profileObj,
149
- email = _res$profileObj.email,
150
- imageUrl = _res$profileObj.imageUrl,
151
- familyName = _res$profileObj.familyName,
152
- givenName = _res$profileObj.givenName,
153
- name = _res$profileObj.name;
154
- var accessToken = res.tokenObj.id_token;
155
- var googleId = res.googleId;
156
- var infoLogin = {
157
- imageUrl: imageUrl,
158
- fullName: name,
159
- firstName: familyName,
160
- lastName: givenName,
161
- email: email,
162
- token: accessToken,
163
- googleId: googleId,
164
- role: role
165
- };
166
- dispatch(setLoading(true));
167
- return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (res1) {
168
- var _res1$data;
169
- if (((_res1$data = res1.data) === null || _res1$data === void 0 ? void 0 : _res1$data.id) == null) {
170
- dispatch(setLoading(false));
171
- alert("Please contact admin.");
172
- return;
143
+ var googleLogin = google.useGoogleLogin({
144
+ onSuccess: function (tokenResponse) {
145
+ try {
146
+ return Promise.resolve(axios.get("https://www.googleapis.com/oauth2/v3/userinfo", {
147
+ headers: {
148
+ Authorization: "Bearer " + tokenResponse.access_token
149
+ }
150
+ })).then(function (userInfo) {
151
+ return function () {
152
+ if (userInfo && userInfo.data) {
153
+ var _userInfo$data = userInfo.data,
154
+ email = _userInfo$data.email,
155
+ picture = _userInfo$data.picture,
156
+ family_name = _userInfo$data.family_name,
157
+ given_name = _userInfo$data.given_name,
158
+ name = _userInfo$data.name,
159
+ sub = _userInfo$data.sub;
160
+ var accessToken = tokenResponse.access_token;
161
+ var infoLogin = {
162
+ imageUrl: picture,
163
+ fullName: name,
164
+ firstName: family_name,
165
+ lastName: given_name,
166
+ email: email,
167
+ token: accessToken,
168
+ googleId: sub,
169
+ role: role
170
+ };
171
+ dispatch(setLoading(true));
172
+ return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (res1) {
173
+ var _res1$data;
174
+ if (((_res1$data = res1.data) === null || _res1$data === void 0 ? void 0 : _res1$data.id) == null) {
175
+ dispatch(setLoading(false));
176
+ alert("Please contact admin.");
177
+ return;
178
+ }
179
+ var tokenJWT = res1.data.token;
180
+ localStorage.setItem(ACCESS_TOKEN, tokenJWT);
181
+ onNavigate("/dashboard");
182
+ dispatch(setLoading(false));
183
+ });
173
184
  }
174
- var tokenJWT = res1.data.token;
175
- localStorage.setItem(ACCESS_TOKEN, tokenJWT);
176
- onNavigate("/dashboard");
177
- dispatch(setLoading(false));
178
- });
179
- }
180
- }());
181
- } catch (e) {
182
- return Promise.reject(e);
185
+ }();
186
+ });
187
+ } catch (e) {
188
+ return Promise.reject(e);
189
+ }
190
+ },
191
+ onError: function onError(errorResponse) {
192
+ return console.log(errorResponse);
183
193
  }
184
- };
185
- var onFailureGoogle = function onFailureGoogle() {
186
- onNavigate("/login");
187
- };
194
+ });
188
195
  return React__default.createElement(reactstrap.Row, {
189
196
  style: {
190
197
  height: "100%"
@@ -217,25 +224,18 @@ var BlockLogin = function BlockLogin(_ref) {
217
224
  color: "#00A0DA"
218
225
  },
219
226
  className: "text-decoration-none"
220
- }, "Sign up"))), React__default.createElement(GoogleLogin__default, {
221
- clientId: GOOGLE_CLIENT_ID,
222
- render: function render(renderProps) {
223
- return React__default.createElement("div", {
224
- className: "" + styleGlobal["google_button"]
225
- }, React__default.createElement("button", {
226
- onClick: renderProps.onClick,
227
- disabled: renderProps.disabled
228
- }, React__default.createElement("img", {
229
- width: 24,
230
- height: 24,
231
- alt: "Google sign-in",
232
- src: "/images/icons/Google__G__logo.png"
233
- }), "Sign in with Google"));
234
- },
235
- onSuccess: onSuccessGoogle,
236
- onFailure: onFailureGoogle,
237
- cookiePolicy: "single_host_origin"
238
- }), role != "Admin" && React__default.createElement(React__default.Fragment, null, React__default.createElement("span", {
227
+ }, "Sign up"))), React__default.createElement("div", {
228
+ className: "" + styleGlobal["google_button"]
229
+ }, React__default.createElement("button", {
230
+ onClick: function onClick() {
231
+ return googleLogin();
232
+ }
233
+ }, React__default.createElement("img", {
234
+ width: 24,
235
+ height: 24,
236
+ alt: "Google sign-in",
237
+ src: "/images/icons/Google__G__logo.png"
238
+ }), "Sign in with Google")), role != "Admin" && React__default.createElement(React__default.Fragment, null, React__default.createElement("span", {
239
239
  className: "" + styleGlobal["box-field"]
240
240
  }, "OR"), React__default.createElement(reactstrap.Form, null, React__default.createElement("div", {
241
241
  className: "" + styleGlobal["box-input"]
@@ -327,15 +327,6 @@ var useLogin = function useLogin() {
327
327
  var _useState3 = React.useState(false),
328
328
  isShowPassword = _useState3[0],
329
329
  setIsShowPassword = _useState3[1];
330
- React.useEffect(function () {
331
- var start = function start() {
332
- gapiScript.gapi.client.init({
333
- clientId: GOOGLE_CLIENT_ID,
334
- scope: 'email'
335
- });
336
- };
337
- gapiScript.gapi.load('client:auth2', start);
338
- }, []);
339
330
  return {
340
331
  defaultInfo: defaultInfo,
341
332
  openLogin: openLogin,
@@ -739,7 +730,7 @@ var useGoogleSignOut = function useGoogleSignOut(props) {
739
730
  var handleLogoutFailure = function handleLogoutFailure() {
740
731
  onFailure === null || onFailure === void 0 ? void 0 : onFailure();
741
732
  };
742
- var _useGoogleLogout = GoogleLogin.useGoogleLogout({
733
+ var _useGoogleLogout = reactGoogleLogin.useGoogleLogout({
743
734
  clientId: GOOGLE_CLIENT_ID,
744
735
  onLogoutSuccess: handleLogoutSuccess,
745
736
  onFailure: handleLogoutFailure
@@ -2081,6 +2072,12 @@ var CustomSelectOption = function CustomSelectOption(_ref) {
2081
2072
 
2082
2073
  var historyCore = history.createBrowserHistory();
2083
2074
 
2075
+ Object.defineProperty(exports, 'GoogleOAuthProvider', {
2076
+ enumerable: true,
2077
+ get: function () {
2078
+ return google.GoogleOAuthProvider;
2079
+ }
2080
+ });
2084
2081
  Object.defineProperty(exports, 'ToastContainer', {
2085
2082
  enumerable: true,
2086
2083
  get: function () {