@visns-studio/visns-components 2.2.1 → 2.2.2

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,24 +1,23 @@
1
- import React, { useState } from "react";
2
- import { Link, useNavigate, useLocation } from "react-router-dom";
3
- import Reveal from "react-reveal/Reveal";
4
- import { toast } from "react-toastify";
5
- import { Person, LockOff } from "akar-icons";
1
+ import React, { useState } from 'react';
2
+ import { Link, useNavigate, useLocation } from 'react-router-dom';
3
+ import Reveal from 'react-reveal/Reveal';
4
+ import { toast } from 'react-toastify';
5
+ import { Person, LockOff } from 'akar-icons';
6
6
 
7
- import CustomFetch from "../Fetch";
7
+ import CustomFetch from '../Fetch';
8
8
 
9
9
  const Login = ({ logo, setSystemAuth, setUserProfile }) => {
10
10
  const location = useLocation();
11
- const navigate = useNavigate();
12
11
 
13
12
  const [auth, setAuth] = useState({
14
- email: "",
15
- password: "",
13
+ email: '',
14
+ password: '',
16
15
  location: location,
17
16
  });
18
17
 
19
18
  const [authClass, setAuthClass] = useState({
20
- username: "",
21
- password: "",
19
+ username: '',
20
+ password: '',
22
21
  });
23
22
 
24
23
  const handleChange = (e) => {
@@ -35,45 +34,45 @@ const Login = ({ logo, setSystemAuth, setUserProfile }) => {
35
34
  e.preventDefault();
36
35
 
37
36
  CustomFetch(
38
- "/login/authenticate",
39
- "POST",
37
+ '/login/authenticate',
38
+ 'POST',
40
39
  auth,
41
40
  (result) => {
42
- if (result.error === "") {
41
+ if (result.error === '') {
43
42
  setUserProfile(result.user);
44
- setSystemAuth(true);
45
43
 
46
44
  if (
47
45
  result.previous?.state?.referrer &&
48
- result.previous.state.referrer !== ""
46
+ result.previous.state.referrer !== ''
49
47
  ) {
50
- navigate(result.previous.state.referrer);
48
+ window.location.href =
49
+ result.previous.state.referrer;
51
50
  } else {
52
- navigate("/");
51
+ setSystemAuth(true);
53
52
  }
54
53
  } else {
55
54
  setSystemAuth(false);
56
55
  setAuthClass((prevState) => ({
57
56
  ...prevState,
58
- username: "inputError",
59
- password: "inputError",
57
+ username: 'inputError',
58
+ password: 'inputError',
60
59
  }));
61
60
 
62
61
  toast.error(
63
- "Could not log in with the supplied credentials, please try again."
62
+ 'Could not log in with the supplied credentials, please try again.'
64
63
  );
65
64
  }
66
65
  },
67
66
  (error) => {
68
67
  setAuthClass((prevState) => ({
69
68
  ...prevState,
70
- username: "inputError",
71
- password: "inputError",
69
+ username: 'inputError',
70
+ password: 'inputError',
72
71
  }));
73
72
 
74
- if (String(error) === "CSRF token mismatch.") {
73
+ if (String(error) === 'CSRF token mismatch.') {
75
74
  toast.error(
76
- "Auth token has timed out, please reload the page before attempting to log back in."
75
+ 'Auth token has timed out, please reload the page before attempting to log back in.'
77
76
  );
78
77
  } else {
79
78
  toast.error(String(error));
@@ -142,7 +141,7 @@ const Login = ({ logo, setSystemAuth, setUserProfile }) => {
142
141
  </div>
143
142
  <div className="formItem fwItem lastItem forgotten">
144
143
  <span>
145
- Forgot your password?{" "}
144
+ Forgot your password?{' '}
146
145
  <Link to="/reset">Click Here</Link>
147
146
  </span>
148
147
  </div>
package/package.json CHANGED
@@ -40,7 +40,7 @@
40
40
  "react-dom": "^17.0.1"
41
41
  },
42
42
  "name": "@visns-studio/visns-components",
43
- "version": "2.2.1",
43
+ "version": "2.2.2",
44
44
  "description": "Various packages to assist in the development of our Custom Applications.",
45
45
  "main": "index.js",
46
46
  "scripts": {